You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/11/08 21:39:14 UTC

[GitHub] [flink-connector-aws] dannycranmer opened a new pull request, #16: [FLINK-29937][Connectors/DynamoDB] Enhanced DynamoDB Element Converter

dannycranmer opened a new pull request, #16:
URL: https://github.com/apache/flink-connector-aws/pull/16

   ## What is the purpose of the change
   
   Add an `ElementConverter` based on the dynamodb-enhanced client.
   
   ## Brief change log
   
   * Added a new Element Converter `DynamoDBEnhancedElementConverter`
   * Add sample job
   * Added unit test
   * Updated NOTICE file
   
   ## Verifying this change
   
   Run locally and persisted rows to DynamoDB
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): yes
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? will follow up 
   


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


[GitHub] [flink-connector-aws] dannycranmer commented on a diff in pull request #16: [FLINK-29937][Connectors/DynamoDB] Enhanced DynamoDB Element Converter

Posted by GitBox <gi...@apache.org>.
dannycranmer commented on code in PR #16:
URL: https://github.com/apache/flink-connector-aws/pull/16#discussion_r1017185669


##########
flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/sink/DynamoDBEnhancedElementConverter.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.sink;
+
+import org.apache.flink.api.connector.sink2.SinkWriter;
+import org.apache.flink.connector.base.sink.writer.ElementConverter;
+
+import software.amazon.awssdk.enhanced.dynamodb.mapper.BeanTableSchema;
+import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
+
+/**
+ * A generic {@link ElementConverter} that uses the dynamodb-enhanced client to build a {@link
+ * DynamoDbWriteRequest} from a POJO annotated with {@link DynamoDbBean}.
+ *
+ * @param <InputT> The
+ */
+public class DynamoDBEnhancedElementConverter<InputT>
+        implements ElementConverter<InputT, DynamoDbWriteRequest> {
+
+    private static final long serialVersionUID = 1L;
+
+    private final Class<InputT> recordType;
+    private final boolean ignoreNulls;
+    private transient BeanTableSchema<InputT> tableSchema;
+
+    public DynamoDBEnhancedElementConverter(final Class<InputT> recordType) {
+        this(recordType, false);
+    }
+
+    public DynamoDBEnhancedElementConverter(
+            final Class<InputT> recordType, final boolean ignoreNulls) {
+        this.recordType = recordType;
+        this.ignoreNulls = ignoreNulls;
+
+        // Attempt to create a table schema now to bubble up errors before starting job
+        createTableSchema(recordType);
+    }
+
+    @Override
+    public DynamoDbWriteRequest apply(InputT element, SinkWriter.Context context) {
+        if (tableSchema == null) {
+            // We have to lazily initialise this because BeanTableSchema is not serializable and

Review Comment:
   Raised https://issues.apache.org/jira/browse/FLINK-29938



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


[GitHub] [flink-connector-aws] dannycranmer merged pull request #16: [FLINK-29937][Connectors/DynamoDB] Enhanced DynamoDB Element Converter

Posted by GitBox <gi...@apache.org>.
dannycranmer merged PR #16:
URL: https://github.com/apache/flink-connector-aws/pull/16


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