danny0405 commented on a change in pull request #13763:
URL: https://github.com/apache/flink/pull/13763#discussion_r513135789



##########
File path: 
flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
##########
@@ -297,17 +299,22 @@ private static DataType convertToDataType(Schema schema) {
         * @return Avro's {@link Schema} matching this logical type.
         */
        public static Schema convertToSchema(LogicalType logicalType) {
-               return convertToSchema(logicalType, "record");
+               return convertToSchema(logicalType, "record", true);
        }
 
        /**
         * Converts Flink SQL {@link LogicalType} (can be nested) into an Avro 
schema.
         *
         * @param logicalType logical type
         * @param rowName     the record name
+        * @param top         whether it is parsing the root record,
+        *                    if it is, the logical type nullability would be 
ignored
         * @return Avro's {@link Schema} matching this logical type.
         */
-       public static Schema convertToSchema(LogicalType logicalType, String 
rowName) {
+       public static Schema convertToSchema(
+                       LogicalType logicalType,
+                       String rowName,
+                       boolean top) {

Review comment:
       > `In SQL the outer row is always NOT NULL`
   
   It is not true, a row (null, null) is nullable true. And i don't think it 
makes sense to change the planner behavior in general in order to fix a 
specific use case. 
   
   >// you can achieve the same with
   // Schema schema = convertToSchema(type.notNull(), "record") 
   
   I don't think we should let each invoker to decide whether to make the data 
type not null, because in current codebase, we should always do that, make the 
decision everyone is error-prone and hard to maintain.
   
   I have merge the `top` into a row type nullability switch, see 
`AvroSchemaConverter.convertToSchema(LogicalType logicalType)`.




----------------------------------------------------------------
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


Reply via email to