You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "gguptp (via GitHub)" <gi...@apache.org> on 2026/02/25 08:54:24 UTC

Re: [PR] [FLINK-39106] Support ROW and ARRAY data types in DynamoDB API / SQL sink [flink-connector-aws]

gguptp commented on code in PR #234:
URL: https://github.com/apache/flink-connector-aws/pull/234#discussion_r2851643719


##########
flink-connector-aws/flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/table/RowDataToAttributeValueConverter.java:
##########
@@ -84,18 +91,64 @@ private StaticTableSchema.Builder<RowData> addAttribute(
             DataTypes.Field field,
             RowData.FieldGetter fieldGetter) {
 
+        EnhancedType<Object> enhancedType = getEnhancedType(field.getDataType());
         return builder.addAttribute(
-                getEnhancedType(field.getDataType()),
-                a ->
-                        a.name(field.getName())
-                                .getter(
-                                        rowData ->
-                                                DataStructureConverters.getConverter(
-                                                                field.getDataType())
-                                                        .toExternalOrNull(
-                                                                fieldGetter.getFieldOrNull(
-                                                                        rowData)))
-                                .setter(((rowData, t) -> {})));
+                enhancedType,
+                a -> {
+                    a.name(field.getName())
+                            .getter(
+                                    rowData ->
+                                            DataStructureConverters.getConverter(
+                                                            field.getDataType())
+                                                    .toExternalOrNull(
+                                                            fieldGetter.getFieldOrNull(rowData)))
+                            .setter(((rowData, t) -> {}));
+                    buildRowAttributeConverter(field.getDataType())
+                            .ifPresent(a::attributeConverter);
+                });
+    }
+
+    private java.util.Optional<AttributeConverter> buildRowAttributeConverter(DataType dataType) {
+        if (LogicalTypeRoot.ROW.equals(dataType.getLogicalType().getTypeRoot())) {
+            return java.util.Optional.of(
+                    createRowDocumentConverter(buildRowTableSchema(dataType)));
+        }
+        if (dataType instanceof CollectionDataType) {
+            DataType elementDataType = ((CollectionDataType) dataType).getElementDataType();
+            if (LogicalTypeRoot.ROW.equals(elementDataType.getLogicalType().getTypeRoot())) {
+                AttributeConverter<Row> elementConverter =
+                        createRowDocumentConverter(buildRowTableSchema(elementDataType));
+                return java.util.Optional.of(
+                        new ArrayAttributeConverter<>(
+                                elementConverter, EnhancedType.of(Row[].class)));
+            }
+        }
+        return java.util.Optional.empty();
+    }
+
+    private static AttributeConverter<Row> createRowDocumentConverter(
+            TableSchema<Row> tableSchema) {
+        return new AttributeConverter<>() {

Review Comment:
   i think it should be 
   
   ```
   return new AttributeConverter<Row>()
   ``` 
   instead



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org