dzikosc commented on code in PR #157:
URL:
https://github.com/apache/flink-connector-aws/pull/157#discussion_r1757263194
##########
flink-connector-aws/flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/sink/DynamoDbSinkWriter.java:
##########
@@ -149,7 +150,7 @@ public DynamoDbSinkWriter(
maxRecordSizeInBytes,
states);
this.failOnError = failOnError;
- this.tableName = tableName;
+ this.table = tableArn != null ? tableArn : tableName;
Review Comment:
What if both parameters are set? If we rely on the Builder class to run the
validations, should we make this method package private?
Nit: can we make the name more explicit? Something like tableArnOrName?
##########
flink-connector-aws/flink-connector-dynamodb/src/main/java/org/apache/flink/connector/dynamodb/sink/DynamoDbSink.java:
##########
@@ -106,18 +109,29 @@ protected DynamoDbSink(
maxBatchSizeInBytes,
maxTimeInBufferMS,
maxRecordSizeInBytes);
- checkNotNull(
- tableName,
- "Destination table name must be set when initializing the
DynamoDB Sink.");
- checkArgument(
- !tableName.isEmpty(),
- "Destination table name must be set when initializing the
DynamoDB Sink.");
checkArgument(
maxBatchSize <= 25,
"DynamoDB client supports only up to 25 elements in the
batch.");
checkNotNull(dynamoDbClientProperties, "DynamoDB client properties
must be set.");
+
+ // Ensure that either tableName or tableArn is set. If both are set,
tableArn takes
+ // precedence.
+ if (tableArn != null) {
+ final Arn arn = Arn.fromString(tableArn);
+ this.tableArn = arn.toString();
+ this.tableName = arn.resource().resource();
+ } else {
+ this.tableArn = null;
+ checkNotNull(
+ tableName,
+ "Destination table name must be set when initializing the
DynamoDB Sink.");
Review Comment:
Should we update the error message to mention both ARN and name as possible
options?
--
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]