Apache Beam BigqueryIO(Java)io.grpc.StatusRuntimeException:INVALID_ARGUMENT:创建 upsert 流需要主集群键

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

我正在使用 apache beam java 从一个 bigquery 表中读取数据,并使用

applyRowMutations()
写入另一个 bigquery 表,但它不起作用。

我已经使用适当的主键创建了目标表。

我正在使用这段代码。

rows.apply(BigQueryIO.applyRowMutations()
                        .to("myproject.testing.test_new")
                        .withJsonSchema(tableSchemaJson)
                        .withMethod(BigQueryIO.Write.Method.STORAGE_API_AT_LEAST_ONCE)
                .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_NEVER))

但是我观察到以下错误日志。

io.grpc.StatusRuntimeException: INVALID_ARGUMENT: The primary keys and clustering keys of the table 81082363:testing.test_new are required to create an upsert stream. Entity: projects/myproject/datasets/testing/tables/test_new/streams/_default


java.lang.RuntimeException: Append to stream projects/myproject/datasets/testing/tables/test_new/streams/_default failed with stream doesn't exist

我无法理解为什么会出现这个问题。

java google-cloud-platform google-bigquery google-cloud-dataflow apache-beam
1个回答
0
投票

项目id和数据集名称应该用冒号连接在一起,而不是用句点连接在一起。

myproject:testing.test_new
而不是
myproject.testing.test_new

上面的代码应该如下:

rows.apply(BigQueryIO.applyRowMutations()
                        .to("myproject:testing.test_new")
                        .withJsonSchema(tableSchemaJson)
                        .withMethod(BigQueryIO.Write.Method.STORAGE_API_AT_LEAST_ONCE)
                .withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_NEVER))
© www.soinside.com 2019 - 2024. All rights reserved.