[Bug]: Using string in PartitionColumn throws error, tries to convert it to string #31419
Closed
2 of 16 tasks
Labels
Milestone
What happened?
Referencing JdbcIo's doc in the section for Parallel reading from a JDBC datasource, It mentions to use either of these types of column for paritioning
Beam supports partitioned reading of all data from a table. Automatic partitioning is supported for a few data types: Long, [DateTime](https://static.javadoc.io/joda-time/joda-time/2.10.10/org/joda/time/DateTime.html?is-external=true), String.
But when I am passing a string field into it, it tries to convert it into Long. As a result the code fails. Can anyone help me with this?
Beam version -> 2.56.0
JdbcIo version -> 2.56.0
Code
PCollection<LogTable> dbReadData = p.apply("ReadFromMySQL", JdbcIO.<LogTable>readWithPartitions() .withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create( "com.mysql.cj.jdbc.Driver", "jdbc:mysql://localhost:3307/exampledb") .withUsername("exampleuser") .withPassword("examplepass")) .withTable("logs_table") .withCoder(SerializableCoder.of(LogTable.class)) .withPartitionColumn("uuid") .withRowMapper(new JdbcIO.RowMapper<LogTable>() { @Override public LogTable mapRow(ResultSet resultSet) throws Exception { String uuid = resultSet.getString("uuid"); Timestamp time = resultSet.getTimestamp("time"); return new LogTable(uuid, time); } }));
table structure ->
CREATE TABLE
logs_table(
uuidvarchar(255) NOT NULL,
timetimestamp NOT NULL )
Runner used was Flink Runner
Issue Priority
Priority: 3 (minor)
Issue Components
The text was updated successfully, but these errors were encountered: