ddebowczyk92 commented on code in PR #234:
URL:
https://github.com/apache/flink-connector-aws/pull/234#discussion_r2851812668
##########
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:
Hey @gguptp! It's diamond operator - Java infers the generic type from the
return type declaration, `<Row>` would be redundant here
--
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]