假设我在 BQ 中有这个 myTable
表:
[
{"name": "executionId", "type": "STRING"},
{"name":"metadata", "type":"record","fields":[
{"name":"fileName", "type":"STRING"},
{"name":"fileType", "type":"STRING"},
{"name":"errors", "type":"STRING"}
]}
]
现在我正在尝试在我的代码中获取表架构。 这是我尝试使用这个 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");
现在我该如何继续?
table
有方法吗?
最佳答案
Table延伸TableInfo ,这样你就可以得到TableDefinition来自 TableInfo 和 Schema从表定义:
Schema schema = table.getDefinition().getSchema();
关于java - 我怎样才能在java中获得bigquery表模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41261880/