Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Destination DynamoDB: rename dynamodb_table_name to dynamodb_table_name_prefix #9314

Merged
merged 6 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"destinationDefinitionId": "8ccd8909-4e99-4141-b48d-4984b70b2d89",
"name": "DynamoDB",
"dockerRepository": "airbyte/destination-dynamodb",
"dockerImageTag": "0.1.0",
"dockerImageTag": "0.1.1",
"documentationUrl": "https://docs.airbyte.io/integrations/destinations/dynamodb",
"icon": "dynamodb.svg"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION destination-dynamodb

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.name=airbyte/destination-dynamodb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dynamodb_table_name": "paste-table-name-here",
"dynamodb_table_name_prefix": "paste-table-name-here",
"dynamodb_region": "paste-dynamodb-region-here",
"access_key_id": "paste-access-key-id-here",
"secret_access_key": "paste-secret-access-key-here"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DynamodbChecker {
private static final Logger LOGGER = LoggerFactory.getLogger(DynamodbChecker.class);

public static void attemptDynamodbWriteAndDelete(final DynamodbDestinationConfig dynamodbDestinationConfig) throws Exception {
final var prefix = dynamodbDestinationConfig.getTableName();
final var prefix = dynamodbDestinationConfig.getTableNamePrefix();
final String outputTableName = prefix + "_airbyte_connection_test_" + UUID.randomUUID().toString().replaceAll("-", "");
attemptWriteAndDeleteDynamodbItem(dynamodbDestinationConfig, outputTableName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
public class DynamodbDestinationConfig {

private final String endpoint;
private final String tableName;
private final String tableNamePrefix;
private final String accessKeyId;
private final String secretAccessKey;
private final String region;

public DynamodbDestinationConfig(
final String endpoint,
final String tableName,
final String tableNamePrefix,
final String region,
final String accessKeyId,
final String secretAccessKey) {
this.endpoint = endpoint;
this.tableName = tableName;
this.tableNamePrefix = tableNamePrefix;
this.region = region;
this.accessKeyId = accessKeyId;
this.secretAccessKey = secretAccessKey;
Expand All @@ -30,7 +30,7 @@ public DynamodbDestinationConfig(
public static DynamodbDestinationConfig getDynamodbDestinationConfig(final JsonNode config) {
return new DynamodbDestinationConfig(
config.get("dynamodb_endpoint") == null ? "" : config.get("dynamodb_endpoint").asText(),
config.get("dynamodb_table_name").asText(),
config.get("dynamodb_table_name_prefix").asText(),
config.get("dynamodb_region").asText(),
config.get("access_key_id").asText(),
config.get("secret_access_key").asText());
Expand All @@ -52,8 +52,8 @@ public String getRegion() {
return region;
}

public String getTableName() {
return tableName;
public String getTableNamePrefix() {
return tableNamePrefix;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

public class DynamodbOutputTableHelper {

public static String getOutputTableName(final String tableName, final AirbyteStream stream) {
return getOutputTableName(tableName, stream.getNamespace(), stream.getName());
public static String getOutputTableName(final String tableNamePrefix, final AirbyteStream stream) {
return getOutputTableName(tableNamePrefix, stream.getNamespace(), stream.getName());
}

public static String getOutputTableName(final String tableName, final String namespace, final String streamName) {
public static String getOutputTableName(final String tableNamePrefix, final String namespace, final String streamName) {
final List<String> paths = new LinkedList<>();

if (tableName != null) {
paths.add(tableName);
if (tableNamePrefix != null) {
paths.add(tableNamePrefix);
}
if (namespace != null) {
paths.add(new ExtendedNameTransformer().convertStreamName(namespace));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public DynamodbWriter(final DynamodbDestinationConfig config,
this.dynamodb = new DynamoDB(amazonDynamodb);
this.configuredStream = configuredStream;
this.uploadTimestamp = uploadTimestamp;
this.outputTableName = DynamodbOutputTableHelper.getOutputTableName(config.getTableName(), configuredStream.getStream());
this.outputTableName = DynamodbOutputTableHelper.getOutputTableName(config.getTableNamePrefix(), configuredStream.getStream());

final DestinationSyncMode syncMode = configuredStream.getDestinationSyncMode();
if (syncMode == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"title": "DynamoDB Destination Spec",
"type": "object",
"required": [
"dynamodb_table_name",
"dynamodb_table_name_prefix",
"dynamodb_region",
"access_key_id",
"secret_access_key"
Expand All @@ -23,10 +23,10 @@
"description": "This is your DynamoDB endpoint url.(if you are working with AWS DynamoDB, just leave empty).",
"examples": ["http://localhost:9000"]
},
"dynamodb_table_name": {
"title": "DynamoDB Table Name",
"dynamodb_table_name_prefix": {
"title": "DynamoDB table name prefix",
alafanechere marked this conversation as resolved.
Show resolved Hide resolved
"type": "string",
"description": "The name of the DynamoDB table.",
"description": "Prefix use to name DynamoDB tables.",
alafanechere marked this conversation as resolved.
Show resolved Hide resolved
"examples": ["airbyte_sync"]
},
"dynamodb_region": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected JsonNode getFailCheckConfig() {
*/
protected List<Item> getAllSyncedObjects(final String streamName, final String namespace) {
final var dynamodb = new DynamoDB(this.client);
final var tableName = DynamodbOutputTableHelper.getOutputTableName(this.config.getTableName(), streamName, namespace);
final var tableName = DynamodbOutputTableHelper.getOutputTableName(this.config.getTableNamePrefix(), streamName, namespace);
final var table = dynamodb.getTable(tableName);
final List<Item> items = new ArrayList<Item>();
final List<Item> resultItems = new ArrayList<Item>();
Expand Down Expand Up @@ -148,7 +148,7 @@ protected void tearDown(final TestDestinationEnv testEnv) {
final var dynamodb = new DynamoDB(this.client);
final List<String> tables = new ArrayList<String>();
dynamodb.listTables().forEach(o -> {
if (o.getTableName().startsWith(this.config.getTableName()))
if (o.getTableName().startsWith(this.config.getTableNamePrefix()))
tables.add(o.getTableName());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ void testGetOutputTableNameWithStream() throws Exception {
@Test
void testGetDynamodbDestinationdbConfig() throws Exception {
final JsonNode json = Jsons.deserialize("{\n" +
" \"dynamodb_table_name\": \"test_table\",\n" +
" \"dynamodb_table_name_prefix\": \"test_table\",\n" +
" \"dynamodb_region\": \"test_region\",\n" +
" \"access_key_id\": \"test_key_id\",\n" +
" \"secret_access_key\": \"test_access_key\"\n" +
"}");
final var config = DynamodbDestinationConfig.getDynamodbDestinationConfig(json);

assertEquals(config.getTableName(), "test_table");
assertEquals(config.getTableNamePrefix(), "test_table");
assertEquals(config.getRegion(), "test_region");
assertEquals(config.getAccessKeyId(), "test_key_id");
assertEquals(config.getSecretAccessKey(), "test_access_key");
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/destinations/dynamodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ This connector by default uses 10 capacity units for both Read and Write in Dyna

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.1 | 2022-12-05 | [\#9314](https://github.com/airbytehq/airbyte/pull/9314) | Rename dynamo_db_table_name to dynamo_db_table_name_prefix. |
| 0.1.0 | 2021-08-20 | [\#5561](https://github.com/airbytehq/airbyte/pull/5561) | Initial release. |