din*_*ina 2 java google-bigquery
假设我myTable在 BQ 有这张表:
[
{"name": "executionId", "type": "STRING"},
{"name":"metadata", "type":"record","fields":[
{"name":"fileName", "type":"STRING"},
{"name":"fileType", "type":"STRING"},
{"name":"errors", "type":"STRING"}
]}
]
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试在我的代码中获取表架构。这是我使用这个例子尝试的:
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");
Run Code Online (Sandbox Code Playgroud)
现在我该如何继续?table有这方面的方法吗?
Table扩展了TableInfo,因此您可以从 TableInfo获取TableDefinition ,并从 TableDefinition 获取Schema :
Schema schema = table.getDefinition().getSchema();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5487 次 |
| 最近记录: |