gpt4 book ai didi

google-bigquery - 如何在 Java 中创建分区 BigQuery 表

转载 作者:行者123 更新时间:2023-12-02 18:00:30 25 4
gpt4 key购买 nike

https://cloud.google.com/bigquery/docs/creating-partitioned-tables展示如何在 Python 中创建分区表。我去过那里,我已经做到了。

现在的问题是,如何使用 Java API 做同样的事情?与下面的 Python 代码执行相同操作的相应 Java 代码是什么:

{
"tableReference": {
"projectId": "myProject",
"tableId": "table1",
"datasetId": "mydataset"
},
"timePartitioning": {
"type": "DAY"
}
}

Java 缺少分区:

Job createTableJob = new Job();
JobConfiguration jobConfiguration = new JobConfiguration();
JobConfigurationLoad loadConfiguration = new JobConfigurationLoad();

createTableJob.setConfiguration(jobConfiguration);
jobConfiguration.setLoad(loadConfiguration);

TableReference tableReference = new TableReference()
.setProjectId("myProject")
.setDatasetId("mydataset")
.setTableId("table1");

loadConfiguration.setDestinationTable(tableReference);
// what should be place here to set DAY timePartitioning?

我使用的是 Maven 中央存储库中的最新 API 版本:com.google.apis:google-api-services-bigquery:v2-rev326-1.22.0

最佳答案

https://cloud.google.com/bigquery/docs/reference/v2/tables/insert https://cloud.google.com/bigquery/docs/reference/v2/tables#resource

Java 代码示例:

String projectId = "";
String datasetId = "";

Table content = new Table();
TimePartitioning timePartitioning = new TimePartitioning();
timePartitioning.setType("DAY");
timePartitioning.setExpirationMs(1L);
content.setTimePartitioning(timePartitioning);

Bigquery.Tables.Insert request = bigquery.tables().insert(projectId, datasetId, content);
Table response = request.execute();

关于google-bigquery - 如何在 Java 中创建分区 BigQuery 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40212167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com