dannycranmer commented on code in PR #15:
URL:
https://github.com/apache/flink-connector-aws/pull/15#discussion_r1028269038
##########
flink-connector-dynamodb/src/test/java/org/apache/flink/connector/dynamodb/sink/examples/example_dynamodb.sql:
##########
@@ -0,0 +1,50 @@
+
Review Comment:
Missing copyright header
##########
flink-connector-dynamodb/src/test/java/org/apache/flink/connector/dynamodb/table/DynamoDbDynamicSinkFactoryTest.java:
##########
@@ -0,0 +1,267 @@
+package org.apache.flink.connector.dynamodb.table;
+
+import org.apache.flink.api.connector.sink2.Sink;
+import org.apache.flink.connector.dynamodb.sink.DynamoDbSink;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.Column;
+import org.apache.flink.table.catalog.ResolvedSchema;
+import org.apache.flink.table.connector.ChangelogMode;
+import org.apache.flink.table.connector.sink.SinkV2Provider;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.factories.TableOptionsBuilder;
+import org.apache.flink.table.factories.TestFormatFactory;
+import
org.apache.flink.table.runtime.connector.sink.SinkRuntimeProviderContext;
+
+import org.apache.flink.shaded.guava30.com.google.common.collect.ImmutableMap;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import static
org.apache.flink.connector.base.table.AsyncSinkConnectorOptions.FLUSH_BUFFER_SIZE;
+import static
org.apache.flink.connector.base.table.AsyncSinkConnectorOptions.FLUSH_BUFFER_TIMEOUT;
+import static
org.apache.flink.connector.base.table.AsyncSinkConnectorOptions.MAX_BATCH_SIZE;
+import static
org.apache.flink.connector.base.table.AsyncSinkConnectorOptions.MAX_BUFFERED_REQUESTS;
+import static
org.apache.flink.connector.base.table.AsyncSinkConnectorOptions.MAX_IN_FLIGHT_REQUESTS;
+import static
org.apache.flink.connector.dynamodb.table.DynamoDbConnectorOptions.FAIL_ON_ERROR;
+import static
org.apache.flink.connector.dynamodb.table.DynamoDbConnectorOptions.TABLE_NAME;
+import static
org.apache.flink.table.factories.utils.FactoryMocks.createTableSink;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
+/** Test for {@link DynamoDbDynamicSink} created by {@link
DynamoDbDynamicSinkFactory}. */
+public class DynamoDbDynamicSinkFactoryTest {
+
+ private static final String DYNAMO_DB_TABLE_NAME = "TestDynamoDBTable";
+
+ @Test
+ void testGoodPartitionedTableSink() {
+ ResolvedSchema sinkSchema =
+ ResolvedSchema.of(
+ Column.physical("partition_key", DataTypes.STRING()),
+ Column.physical("sort_key", DataTypes.BIGINT()),
+ Column.physical("payload", DataTypes.STRING()),
+ Column.physical("some_char_array",
DataTypes.ARRAY(DataTypes.CHAR(1))),
+ Column.physical(
+ "some_varchar_array",
DataTypes.ARRAY(DataTypes.VARCHAR(1))),
+ Column.physical("some_string_array",
DataTypes.ARRAY(DataTypes.STRING())),
+ Column.physical("some_boolean_array",
DataTypes.ARRAY(DataTypes.BOOLEAN())),
+ Column.physical(
+ "some_decimal_array",
DataTypes.ARRAY(DataTypes.DECIMAL(1, 1))),
+ Column.physical("some_tinyint_array",
DataTypes.ARRAY(DataTypes.TINYINT())),
+ Column.physical(
+ "some_smallint_array",
DataTypes.ARRAY(DataTypes.SMALLINT())),
+ Column.physical("some_int_array",
DataTypes.ARRAY(DataTypes.INT())),
+ Column.physical("some_bigint_array",
DataTypes.ARRAY(DataTypes.BIGINT())),
+ Column.physical("some_float_array",
DataTypes.ARRAY(DataTypes.FLOAT())),
+ Column.physical("some_date_array",
DataTypes.ARRAY(DataTypes.DATE())),
+ Column.physical("some_time_array",
DataTypes.ARRAY(DataTypes.TIME())),
+ Column.physical(
+ "some_timestamp_array",
DataTypes.ARRAY(DataTypes.TIMESTAMP())),
+ Column.physical(
+ "some_timestamp_ltz_array",
+ DataTypes.ARRAY(DataTypes.TIMESTAMP_LTZ())),
+ Column.physical(
+ "some_map", DataTypes.MAP(DataTypes.STRING(),
DataTypes.BIGINT())));
+ Map<String, String> sinkOptions = defaultSinkOptions().build();
+ List<String> partitionKeys =
Collections.singletonList("partition_key");
+
+ // Construct actual sink
+ DynamoDbDynamicSink actualSink =
+ (DynamoDbDynamicSink) createTableSink(sinkSchema,
partitionKeys, sinkOptions);
+
+ // Construct expected sink
+ Properties dynamoDbClientProperties = new Properties();
+ dynamoDbClientProperties.putAll(sinkOptions);
+ DynamoDbDynamicSink expectedSink =
+ (DynamoDbDynamicSink)
+ DynamoDbDynamicSink.builder()
+ .setTableName(DYNAMO_DB_TABLE_NAME)
+ .setOverwriteByPartitionKeys(new
HashSet<>(partitionKeys))
+
.setDynamoDbClientProperties(dynamoDbClientProperties)
+
.setPhysicalDataType(sinkSchema.toPhysicalRowDataType())
+ .build();
+
+
assertThat(actualSink).usingRecursiveComparison().isEqualTo(expectedSink);
+ assertThat(actualSink.getChangelogMode(ChangelogMode.insertOnly()))
+ .isEqualTo(ChangelogMode.upsert());
Review Comment:
ok, but what I was hinting at is that if we pass in `insertOnly`, maybe we
should throw an error if we receive any delete requests. Scope creep alert
##########
flink-connector-dynamodb/src/test/java/org/apache/flink/connector/dynamodb/sink/examples/example_dynamodb_static_partitions.sql:
##########
@@ -0,0 +1,50 @@
+
Review Comment:
Missing copyright header
##########
flink-sql-connector-dynamodb/pom.xml:
##########
@@ -77,12 +77,16 @@ under the License.
<include>org.apache.httpcomponents:*</include>
<include>io.netty:*</include>
<include>commons-logging:commons-logging</include>
+
<include>commons-codec:commons-codec</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>software.amazon</pattern>
<shadedPattern>org.apache.flink.connector.dynamodb.shaded.software.amazon</shadedPattern>
+
<excludes>
+
<exclude>software.amazon.awssdk.enhanced.**</exclude>
+
</excludes>
Review Comment:
Ah, we had this issue for EFO too. I added a custom `execution.interceptors`
for this
https://github.com/apache/flink/commit/a330d4331b2af710b6531c55f427c4b14f037d78
--
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]