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


##########
fluss-lake/fluss-lake-iceberg/src/main/java/org/apache/fluss/lake/iceberg/source/FlussRowAsIcebergRecord.java:
##########
@@ -179,6 +180,15 @@ private FlussRowToIcebergFieldConverter 
createTypeConverter(DataType flussType,
                         ? null
                         : new FlussArrayAsIcebergList(array, 
arrayType.getElementType());
             };
+        } else if (flussType instanceof RowType) {
+            RowType rowType = (RowType) flussType;
+            Types.StructType nestedStructType =
+                    (Types.StructType) 
rowType.accept(FlussDataTypeToIcebergDataType.INSTANCE);
+
+            return row -> {
+                InternalRow nestedRow = row.getRow(pos, 
rowType.getFieldCount());
+                return new FlussRowAsIcebergRecord(nestedStructType, rowType, 
nestedRow);

Review Comment:
   Potential null pointer exception if nestedRow is null. The constructor call 
should handle null values, but the lambda doesn't check before creating the 
FlussRowAsIcebergRecord. Consider returning null when nestedRow is null to 
match the pattern used in the array converter.
   ```suggestion
                   return nestedRow == null
                           ? null
                           : new FlussRowAsIcebergRecord(nestedStructType, 
rowType, nestedRow);
   ```



##########
fluss-lake/fluss-lake-iceberg/src/main/java/org/apache/fluss/lake/iceberg/utils/IcebergConversions.java:
##########
@@ -128,7 +130,16 @@ private static DataType convertIcebergTypeToFlussType(Type 
icebergType) {
         } else if (icebergType instanceof Types.ListType) {
             Types.ListType listType = (Types.ListType) icebergType;
             return 
DataTypes.ARRAY(convertIcebergTypeToFlussType(listType.elementType()));
+        } else if (icebergType.isStructType()) {
+            Types.StructType structType = icebergType.asStructType();
+            List<DataField> fields = new ArrayList<>();
+            for (Types.NestedField nestedField : structType.fields()) {
+                DataType fieldType = 
convertIcebergTypeToFlussType(nestedField.type());
+                fields.add(new DataField(nestedField.name(), fieldType));
+            }
+            return DataTypes.ROW(fields.toArray(new DataField[0]));
         }

Review Comment:
   The struct type handling is added within a sequence of if-else statements 
but the closing brace at line 139 appears disconnected from the opening at line 
133. The control flow suggests this else-if block should close at line 141, but 
line 139 has a closing brace that doesn't align with the logic structure. 
Verify the brace placement is correct.



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