如何通过Java程序获取Bigquery表的模式?

时间:2021-12-29 14:25:31

Am using DataFlow 2.0/Apache Beam as the framework to read data from BigQuery and write to a SQL database. Would like to read the schema definition from BigQuery and then create an equivalent table in the SQL definition.

我使用DataFlow 2.0 / Apache Beam作为框架从BigQuery读取数据并写入SQL数据库。想从BigQuery中读取模式定义,然后在SQL定义中创建等效表。

What is the Java API to get the BigQuery schema definition?

获取BigQuery架构定义的Java API是什么?

The docs only talk about reading the data but not the metadata.

文档只讨论阅读数据而不是元数据。

Thanks -ravi

谢谢-ravi

1 个解决方案

#1


2  

You can use the BigQuery Java client library. The schema of a table can be accessed via bigQuery.getTable(datasetId, tableId).getDefinition().getSchema().

您可以使用BigQuery Java客户端库。可以通过bigQuery.getTable(datasetId,tableId).getDefinition()。getSchema()访问表的模式。

#1


2  

You can use the BigQuery Java client library. The schema of a table can be accessed via bigQuery.getTable(datasetId, tableId).getDefinition().getSchema().

您可以使用BigQuery Java客户端库。可以通过bigQuery.getTable(datasetId,tableId).getDefinition()。getSchema()访问表的模式。