我试图将beamSql数据写入BigQuery,如下所示:
final_out1.apply(BigQueryIO.<TableRow>Write
.named("Write")
.to("my-project:data_id1.tables_test")
.withSchema(schema)
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE))
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));
我在named()上遇到错误,错误:
The method named(String) is undefined for the type BigQueryIO.Write
知道这意味着什么吗?
修改 我定义的格式函数:
final_out1.apply(BigQueryIO.<TableRow>write()
.withSchema(schema)
.to("beta-194409:data_id1.tables_test"));
/* .withFormatFunction(fin -> new TableRow().
set("SalesComponent", fin.getSalesComponent()).
set("DuetoValue", fin.getDuetoValue()).
set("ModelIteration", fin.getMo//delIteration())) */
//.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE).withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));
答案 0 :(得分:1)
类named()
没有这样的方法BigQueryIO.Write
所以这个错误是有道理的。
您可以将变换名称指定为apply()
方法的第一个参数。
final_out1.apply("Write", BigQueryIO.<TableRow>.write()
.to("my-project:data_id1.tables_test")
.withSchema(schema)
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE))
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));
注意:使用BigQueryIO.write()
代替BigQueryIO.Write
。