且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

BigQuery通过查询获取表模式

更新时间:2023-02-26 10:24:14

我可以看到一些方法,尽管它们与MYSQL方法不同 - / p>

I can see a couple of approaches, though they differ from the MYSQL approach -


  1. 如果您有使用查询,只需创建一个装饰器来包装带有 limit 1 子句的查询。尽管您将收取与运行全表扫描相同的金额,但它会在响应中为您提供架构(请参阅查询作业的文档)。由于可能收取的费用不是***的方法。

  2. 如果您没有绑定到查询作业,为什么不使用表格获取方法?它返回一个包含模式的表资源对象

  1. If you have to use a query, just create a decorator to wrap a query with a limit 1 clause. While you will be charged the same amount as running a full table scan, it will give you the the schema in the response (see documentation of the query job). Not the best approach due the possibly charges it might incur.
  2. If you aren't tied to the query job, why not use the tables get method? It returns a table resource object which contains the schema