[英]how can I get a bigquery table schema in java
lets say I have this myTable
table in BQ: 可以说我在BQ中有这个
myTable
表:
[
{"name": "executionId", "type": "STRING"},
{"name":"metadata", "type":"record","fields":[
{"name":"fileName", "type":"STRING"},
{"name":"fileType", "type":"STRING"},
{"name":"errors", "type":"STRING"}
]}
]
now I'm trying to get the tables schema in my code. 现在,我正在尝试在代码中获取表架构。 here is what I tried using this example :
这是我使用此示例尝试的内容:
import com.google.cloud.examples.bigquery.snippets.*;
public class MyClass {
public static void main(String[] args) throws Exception {
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
BigQuerySnippets bigQuerySnippets = new BigQuerySnippets(bigquery);
Table table = bigQuerySnippets.getTable("MY_DATASET", "myTable");
now how do I continue? 现在如何继续? does
table
have a method for this? table
有此方法吗?
Table扩展了TableInfo ,因此您可以从TableInfo获取TableDefinition ,并从TableDefinition获得Schema :
Schema schema = table.getDefinition().getSchema();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.