代码之家  ›  专栏  ›  技术社区  ›  Nagesh Singh Chauhan

无法将beamSql数据写入BigQuery

  •  0
  • Nagesh Singh Chauhan  · 技术社区  · 6 年前

    我正在尝试将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)); 
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Andrew Nguonly    6 年前

    没有这样的方法 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。写 .