Copilot commented on code in PR #2266:
URL: https://github.com/apache/fluss/pull/2266#discussion_r2650152599


##########
fluss-lake/fluss-lake-iceberg/src/main/java/org/apache/fluss/lake/iceberg/utils/IcebergConversions.java:
##########
@@ -125,6 +125,9 @@ private static DataType convertIcebergTypeToFlussType(Type 
icebergType) {
         } else if (icebergType instanceof Types.DecimalType) {
             Types.DecimalType decimalType = (Types.DecimalType) icebergType;
             return DataTypes.DECIMAL(decimalType.precision(), 
decimalType.scale());
+        } else if (icebergType instanceof Types.ListType) {
+            Types.ListType listType = (Types.ListType) icebergType;
+            return 
DataTypes.ARRAY(convertIcebergTypeToFlussType(listType.elementType()));

Review Comment:
   When converting from Iceberg LIST to Fluss ARRAY, the element nullability is 
not being preserved. The code should check 
`listType.elementField().isOptional()` and create the element type with the 
appropriate nullability. If the element field is optional, the element type 
should be made nullable using `.nullable()`, otherwise it should remain 
non-nullable.
   ```suggestion
               DataType elementType = 
convertIcebergTypeToFlussType(listType.elementType());
               if (listType.elementField().isOptional()) {
                   elementType = elementType.nullable();
               }
               return DataTypes.ARRAY(elementType);
   ```



##########
fluss-lake/fluss-lake-iceberg/src/main/java/org/apache/fluss/lake/iceberg/FlussDataTypeToIcebergDataType.java:
##########
@@ -129,7 +129,7 @@ public Type visit(LocalZonedTimestampType 
localZonedTimestampType) {
 
     @Override
     public Type visit(ArrayType arrayType) {
-        throw new UnsupportedOperationException("Unsupported array type");
+        return Types.ListType.ofOptional(0, 
arrayType.getElementType().accept(this));

Review Comment:
   The code always uses `Types.ListType.ofOptional()`, which creates a list 
where elements can be null. However, Fluss `ArrayType` can have non-nullable 
elements. The nullability of the element type should be checked using 
`arrayType.getElementType().isNullable()` and the appropriate method 
(`ofRequired` or `ofOptional`) should be used accordingly to preserve the 
element type's nullability semantics.
   ```suggestion
           Type elementType = arrayType.getElementType().accept(this);
           if (arrayType.getElementType().isNullable()) {
               return Types.ListType.ofOptional(0, elementType);
           } else {
               return Types.ListType.ofRequired(0, elementType);
           }
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to