基本上我正在尝试在 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
这可能吗?
之前的答案中链接的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));