wuchong commented on a change in pull request #10403: [FLINK-14645][table] 
Support to keep nullability and precision when converting DataTypes to 
properties
URL: https://github.com/apache/flink/pull/10403#discussion_r354691466
 
 

 ##########
 File path: 
flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/descriptors/OldCsv.java
 ##########
 @@ -123,17 +142,41 @@ public OldCsv field(String fieldName, TypeInformation<?> 
fieldType) {
         * This method can be called multiple times. The call order of this 
method defines
         * also the order of the fields in the format.
         *
+        * <p>NOTE: the fieldType string should follow the type string defined 
in {@link LogicalTypeParser}.
+        * This method also keeps compatible with old type string defined in 
{@link TypeStringUtils} but
+        * will be dropped in future versions as it uses the old type system.
+        *
         * @param fieldName the field name
         * @param fieldType the type string of the field
         */
        public OldCsv field(String fieldName, String fieldType) {
+               if (isLegacyTypeString(fieldType)) {
+                       // fallback to legacy parser
+                       TypeInformation<?> typeInfo = 
TypeStringUtils.readTypeInfo(fieldType);
+                       return field(fieldName, 
TypeConversions.fromLegacyInfoToDataType(typeInfo));
+               } else {
+                       return addField(fieldName, fieldType);
+               }
+       }
+
+       private OldCsv addField(String fieldName, String fieldType) {
                if (schema.containsKey(fieldName)) {
                        throw new ValidationException("Duplicate field name " + 
fieldName + ".");
                }
                schema.put(fieldName, fieldType);
                return this;
        }
 
+       private boolean isLegacyTypeString(String fieldType) {
+               try {
+                       LogicalTypeParser.parse(fieldType);
 
 Review comment:
   Sorry, I updated `Schema` but forgot to update `OldCsv`.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to