从 DataFlow 加载到现有 BigQuery 表时是否可以更新架构?

问题描述 投票:0回答:2

基本上我正在尝试在 DataFlow 中执行与此 CLI 相同的操作:

bq load  --source_format=NEWLINE_DELIMITED_JSON --schema_update_option=ALLOW_FIELD_ADDITION --schema=users.schema.json projectid:dataset.users updates/users.json

这可能吗?

google-bigquery google-cloud-dataflow
2个回答
2
投票

目前

BigQueryIO
不支持此实验选项。我已提交 JIRA 问题 来支持它。


0
投票

之前的答案中链接的JIRA似乎已解决了
另外,我可以在这里看到相关的拉取请求

可以使用此选项完成架构更新

.withSchemaUpdateOptions(EnumSet.of(BigQueryIO.Write.SchemaUpdateOption.ALLOW_FIELD_ADDITION));

在java中就像这样:

PCollection<TableRow> rows;
TableReference targetTable= <someTable>;
BigQueryIO.Write<TableRow> write = BigQueryIO.<TableRow>writeTableRows()
.to(targetTable)
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED)
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_APPEND)
.withSchemaUpdateOptions(EnumSet.of(BigQueryIO.Write.SchemaUpdateOption.ALLOW_FIELD_ADDITION));
© www.soinside.com 2019 - 2024. All rights reserved.