私はApache Beamを初めて使用しており、mysqlデータベースのGoogle Cloudインスタンスに接続しようとしています。以下のコードスニペットを実行すると、以下の例外がスローされます。スレッド "メイン" java.lang.IllegalArgumentExceptionがでApache Beam throw can not setCoder(null):java
Logger logger = LoggerFactory.getLogger(GoogleSQLPipeline.class);
PipelineOptions options = PipelineOptionsFactory.create();
Pipeline dataflowPipeline = Pipeline.create();
dataflowPipeline.apply(JdbcIO.<KV<Integer, String>>read().withCoder(KvCoder.of(VarIntCoder.of(), StringUtf8Coder.of()))
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration
.create("com.mysql.jdbc.Driver", "jdbc:mysql://<ip from google instance>:3306/foodmart")
.withUsername("root").withPassword("root"))
.withQuery("select accouont_id,account_description from account")
.withRowMapper(new JdbcIO.RowMapper<KV<Integer, String>>() {
@Override
public KV<Integer, String> mapRow(ResultSet resultSet) throws Exception {
// TODO Auto-generated method stub
return KV.of(resultSet.getInt(1), resultSet.getString(2));
}
}));
dataflowPipeline.run();
例外:することはできませんsetCoder(ヌル)org.apache.beam.sdk.repackaged.com.google.common.base.Preconditions.checkArgument(前提条件で 。 java:122) at org.apache.beam.sdk.values.PCollection.setCoder(PCollection.java:265) at org.apache.beam.sdk.io.jdbc.JdbcIO $ Read.expand(JdbcIO.java: 325) at org.apache.beam.sdk.io.jdbc.JdbcIO $ Read.expand(JdbcIO.java:272) at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:482) at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:422) at org.apache.beam.s dk.values.PBegin.apply(PBegin.java:44) at org.apache.beam.sdk.Pipeline.apply(Pipeline.java:164) (com.neudesic.com.GoogleSQLPipeline.main(GoogleSQLPipeline.java: 24)