wuchong commented on a change in pull request #10745: 
[FLINK-15445][connectors/jdbc] JDBC Table Source didn't work for Type…
URL: https://github.com/apache/flink/pull/10745#discussion_r376195245
 
 

 ##########
 File path: 
flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCTableSource.java
 ##########
 @@ -73,17 +75,23 @@ private JDBCTableSource(
                this.selectFields = selectFields;
 
                final TypeInformation<?>[] schemaTypeInfos = 
schema.getFieldTypes();
+               final DataType[] schemaDataTypes = schema.getFieldDataTypes();
                final String[] schemaFieldNames = schema.getFieldNames();
                if (selectFields != null) {
                        TypeInformation<?>[] typeInfos = new 
TypeInformation[selectFields.length];
-                       String[] typeNames = new String[selectFields.length];
+                       DataType[] dataTypes = new 
DataType[selectFields.length];
+                       String[] fieldNames = new String[selectFields.length];
                        for (int i = 0; i < selectFields.length; i++) {
                                typeInfos[i] = schemaTypeInfos[selectFields[i]];
-                               typeNames[i] = 
schemaFieldNames[selectFields[i]];
+                               dataTypes[i] = schemaDataTypes[selectFields[i]];
+                               fieldNames[i] = 
schemaFieldNames[selectFields[i]];
                        }
-                       this.returnType = new RowTypeInfo(typeInfos, typeNames);
+                       this.returnType = new RowTypeInfo(typeInfos, 
fieldNames);
 
 Review comment:
   Can we remove the `returnType` member field?
   It's error-prone to maintain two objects. The returnType is only used in 
`getDataStream` and can be derived via 
`TypeConversions.fromDataTypeToLegacyInfo(producedDataType)`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to