如何从java在BigQuery中创建分区表?
我想从java在BigQuery中创建一个分区表(PartitionByField,日期类型)。我搜索了很多,但是没有太多关于这个的信息。我使用的代码是如何从java在BigQuery中创建分区表?,java,google-bigquery,Java,Google Bigquery,我想从java在BigQuery中创建一个分区表(PartitionByField,日期类型)。我搜索了很多,但是没有太多关于这个的信息。我使用的代码是 TimePartitioning timePartitioning = TimePartitioning.of(TimePartitioning.Type.DAY); timePartitioning.toBuilder().setField("col3"); TableDefinition ta
TimePartitioning timePartitioning = TimePartitioning.of(TimePartitioning.Type.DAY);
timePartitioning.toBuilder().setField("col3");
TableDefinition tableDefinition = StandardTableDefinition.newBuilder().setSchema(schema2).setTimePartitioning(timePartitioning).build();
TableInfo tableInfo = TableInfo.newBuilder(tableId, tableDefinition).build();
bigquery.create(tableInfo);
这里,我有几个问题
最简单的方法是发出标准查询-如果您可以从Java进行查询(您已经这样做了吗?),只需发送如下查询:
#标准SQL
创建表`project.dataset.TABLE`
(
x INT64选项(description=“可选整数字段”),
y结构<
数组选项(description=“重复字符串字段”),
布尔
>,
日期列日期
)
按日期\列划分
按i\u推荐\u您\u选择\u群集\u列
我还没有尝试过,但我会使用表创建示例替换标准表定义的一行
TableDefinition tableDefinition = StandardTableDefinition.of(schema);
代码取自。您可以借用对您有意义的StandardTableDefinition
创建/配置选项,然后替换TimePartitioning
TimePartitioning TIME_PARTITIONING = TimePartitioning.of(TimePartitioning.Type.DAY, 42);
代码取自例如
仅当您希望禁止不利用分区的查询时,才使用.setRequirePartitionFilter(…)
TimePartitioning TIME_PARTITIONING =
TimePartitioning.newBuilder(TYPE)
.setExpirationMs(EXPIRATION_MS)
.setRequirePartitionFilter(REQUIRE_PARTITION_FILTER)
.setField(FIELD)
.build();