hlteoh37 commented on code in PR #146: URL: https://github.com/apache/flink-connector-aws/pull/146#discussion_r1670682655
########## flink-connector-aws/flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/source/serialization/DynamoDbStreamsDeserializationSchemaWrapper.java: ########## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.connector.dynamodb.source.serialization; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.common.serialization.DeserializationSchema; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.util.Collector; + +import com.fasterxml.jackson.databind.ObjectMapper; +import software.amazon.awssdk.services.dynamodb.model.Record; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +/** + * A simple wrapper for using the {@link DeserializationSchema} with the {@link + * DynamoDbStreamsDeserializationSchema} interface. + * + * @param <T> The type created by the deserialization schema. + */ +@Internal +class DynamoDbStreamsDeserializationSchemaWrapper<T> Review Comment: I think we should remove `DynamoDbStreamsDeserializationSchemaWrapper<T>` along with `RecordObjectMapper`. The current implementation doesn't really fit well into DDB CDC deserialization. Some context: - We set up `DynamoDbStreamsDeserializationSchema<T>` to provide `DDBStream Record` to customers when deserializing records into their custom `Type <T>`, as compared to Flink's default `DeserializationSchema<T>` which assumes byte array as input to deserialize into `type <T>` - In KDS, `KinesisStreamsDeserializationSchema<T>` makes sense because the payload is simply a byte array. So we can wrap directly over any of Flink's `DeserializationSchema<T>` (just drop the metadata). - For DDB, this doesn't make sense, because there is no easy way to make Record -> byte array whilst supporting more than 1 Flink's `DeserializationSchema<T>` (e.g. JSON, CSV, debezium-json). The way you implemented it only supports JSON. IMO, we should remove this for now, and implement more direct support for schemas like StringSerializationSchema / Debezium schema. We will need to think about this when implementing the Table API -- 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]
