Dezhi Cai created FLINK-14987:
--------------------------------- Summary: JDBCTableSource can't support DataTypes.DECIMAL Key: FLINK-14987 URL: https://issues.apache.org/jira/browse/FLINK-14987 Project: Flink Issue Type: Bug Components: Connectors / JDBC, Table SQL / API Affects Versions: 1.9.1, 1.9.0 Reporter: Dezhi Cai below sample code fail ValidationException. After investigation, i find that the root cause may be related to the conversion between DecimalType and TypeInformation<BigDecimal>. LegacyTypeInfoDataTypeConverter.toLegacyTypeInfo LegacyTypeInfoDataTypeConverter.toDataType sampe code 1: {code:java} public static void main(String[] args) { JDBCOptions options = JDBCOptions.builder() .setDBUrl("jdbc:mysql://127.0.0.1/test") .setTableName("table1") .setDriverName("com.mysql.jdbc.Driver") .setUsername("root") .setPassword("password") .build(); TableSchema schema = TableSchema.builder() .field("a", DataTypes.INT()) .field("b", DataTypes.BIGINT()) .field("c", DataTypes.FLOAT()) .field("d", DataTypes.DOUBLE()) .field("e", DataTypes.DECIMAL(24,3)) .field("f", DataTypes.TIMESTAMP(3)) .build(); JDBCTableSource source = JDBCTableSource.builder() .setOptions(options) .setSchema(schema) .build(); TableSourceValidation.validateTableSource(source); } {code} Exception in thread "main" org.apache.flink.table.api.ValidationException: Type DECIMAL(24, 3) of table field 'LEGACY(BigDecimal)' does not match with type 'e; of the field 'LEGACY(BigDecimal)' of the TableSource return type.Exception in thread "main" org.apache.flink.table.api.ValidationException: Type DECIMAL(24, 3) of table field 'LEGACY(BigDecimal)' does not match with type 'e; of the field 'LEGACY(BigDecimal)' of the TableSource return type. at org.apache.flink.table.sources.TableSourceValidation.validateLogicalTypeEqualsPhysical(TableSourceValidation.java:184) at org.apache.flink.table.sources.TableSourceValidation.validateLogicalToPhysicalMapping(TableSourceValidation.java:156) at org.apache.flink.table.sources.TableSourceValidation.validateTableSource(TableSourceValidation.java:69) at com.moodys.demo.Demo.main(Demo.java:43) sample code 2 : {code:java} public static void main(String[] args) { DataType originalDataType = DataTypes.DECIMAL(24,3); TypeInformation legacyType = LegacyTypeInfoDataTypeConverter.toLegacyTypeInfo(originalDataType); DataType dataType = LegacyTypeInfoDataTypeConverter.toDataType(legacyType); System.out.println(originalDataType.equals(dataType)); } // output: false{code} -- This message was sent by Atlassian Jira (v8.3.4#803005) |
Free forum by Nabble | Edit this page |