无法使用 useBeamSchema 自动将 Pcollection 转换为 table 行模式
Not able to use useBeamSchema for automatically converting Pcollection to table row schema
//以下代码从GCS bucket中读取文件,转换并写入Bigquery
PCollection<Quote> quotes = ...//get tranfrometed data
quotes.apply(BigQueryIO
.<Quote>write()
.to("my-project:my_dataset.my_table")
.useBeamSchema()
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_`enter code here`TRUNCATE));
//get error
//Exception in thread "main" java.lang.IllegalArgumentException: Unable to infer a coder and no Coder was //specified. Please set a coder by invoking Create.withCoder() explicitly or a schema by invoking //Create.withSchema().
我认为您必须在 PCollection
中设置架构。请参阅 example below.
//以下代码从GCS bucket中读取文件,转换并写入Bigquery
PCollection<Quote> quotes = ...//get tranfrometed data
quotes.apply(BigQueryIO
.<Quote>write()
.to("my-project:my_dataset.my_table")
.useBeamSchema()
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_`enter code here`TRUNCATE));
//get error
//Exception in thread "main" java.lang.IllegalArgumentException: Unable to infer a coder and no Coder was //specified. Please set a coder by invoking Create.withCoder() explicitly or a schema by invoking //Create.withSchema().
我认为您必须在 PCollection
中设置架构。请参阅 example below.