Skip to content

Commit a5cd384

Browse files
authored
Revert "🐛 Source Dynamodb: Fix reserved words in expression (#20172)" (#23515)
This reverts commit b9b8cb0.
1 parent ea776ef commit a5cd384

File tree

11 files changed

+24
-74
lines changed

11 files changed

+24
-74
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@
474474
- name: DynamoDB
475475
sourceDefinitionId: 50401137-8871-4c5a-abb7-1f5fda35545a
476476
dockerRepository: airbyte/source-dynamodb
477-
dockerImageTag: 0.1.2
477+
dockerImageTag: 0.1.1
478478
documentationUrl: https://docs.airbyte.com/integrations/sources/dynamodb
479479
icon: dynamodb.svg
480480
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

+1-8
Original file line numberDiff line numberDiff line change
@@ -3398,7 +3398,7 @@
33983398
supportsNormalization: false
33993399
supportsDBT: false
34003400
supported_destination_sync_modes: []
3401-
- dockerImage: "airbyte/source-dynamodb:0.1.2"
3401+
- dockerImage: "airbyte/source-dynamodb:0.1.1"
34023402
spec:
34033403
documentationUrl: "https://docs.airbyte.com/integrations/sources/dynamodb"
34043404
connectionSpecification:
@@ -3464,13 +3464,6 @@
34643464
airbyte_secret: true
34653465
examples:
34663466
- "a012345678910ABCDEFGH/AbCdEfGhEXAMPLEKEY"
3467-
reserved_attribute_names:
3468-
title: "Reserved attribute names"
3469-
type: "string"
3470-
description: "Comma separated reserved attribute names present in your tables"
3471-
airbyte_secret: true
3472-
examples:
3473-
- "name, field_name, field-name"
34743467
supportsNormalization: false
34753468
supportsDBT: false
34763469
supported_destination_sync_modes: []

airbyte-integrations/connectors/source-dynamodb/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ ENV APPLICATION source-dynamodb
1717
COPY --from=build /airbyte /airbyte
1818

1919
# Airbyte's build system uses these labels to know what to name and tag the docker images produced by this Dockerfile.
20-
LABEL io.airbyte.version=0.1.2
20+
LABEL io.airbyte.version=0.1.1
2121
LABEL io.airbyte.name=airbyte/source-dynamodb

airbyte-integrations/connectors/source-dynamodb/src/main/java/io/airbyte/integrations/source/dynamodb/DynamodbConfig.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import com.fasterxml.jackson.databind.JsonNode;
88
import java.net.URI;
9-
import java.util.Arrays;
10-
import java.util.List;
119
import software.amazon.awssdk.regions.Region;
1210

1311
public record DynamodbConfig(
@@ -18,22 +16,18 @@ public record DynamodbConfig(
1816

1917
String accessKey,
2018

21-
String secretKey,
22-
23-
List<String> reservedAttributeNames
19+
String secretKey
2420

2521
) {
2622

2723
public static DynamodbConfig createDynamodbConfig(JsonNode jsonNode) {
2824
JsonNode endpoint = jsonNode.get("endpoint");
2925
JsonNode region = jsonNode.get("region");
30-
JsonNode attributeNames = jsonNode.get("reserved_attribute_names");
3126
return new DynamodbConfig(
3227
endpoint != null && !endpoint.asText().isBlank() ? URI.create(endpoint.asText()) : null,
3328
region != null && !region.asText().isBlank() ? Region.of(region.asText()) : null,
3429
jsonNode.get("access_key_id").asText(),
35-
jsonNode.get("secret_access_key").asText(),
36-
attributeNames != null ? Arrays.asList(attributeNames.asText().split("\\s*,\\s*")) : List.of());
30+
jsonNode.get("secret_access_key").asText());
3731
}
3832

3933
}

airbyte-integrations/connectors/source-dynamodb/src/main/java/io/airbyte/integrations/source/dynamodb/DynamodbOperations.java

+2-28
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
import java.time.format.DateTimeParseException;
1414
import java.util.ArrayList;
1515
import java.util.HashMap;
16-
import java.util.HashSet;
1716
import java.util.List;
1817
import java.util.Map;
1918
import java.util.Set;
20-
import java.util.stream.Collectors;
2119
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
2220
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
2321
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -32,10 +30,7 @@ public class DynamodbOperations extends AbstractDatabase implements Closeable {
3230

3331
private ObjectMapper schemaObjectMapper;
3432

35-
private DynamodbConfig dynamodbConfig;
36-
3733
public DynamodbOperations(DynamodbConfig dynamodbConfig) {
38-
this.dynamodbConfig = dynamodbConfig;
3934
this.dynamoDbClient = DynamodbUtils.createDynamoDbClient(dynamodbConfig);
4035
initMappers();
4136
}
@@ -110,31 +105,12 @@ public JsonNode inferSchema(String tableName, int sampleSize) {
110105
public List<JsonNode> scanTable(String tableName, Set<String> attributes, FilterAttribute filterAttribute) {
111106
List<JsonNode> items = new ArrayList<>();
112107

113-
String prefix = "dyndb";
114-
// remove and replace reserved attribute names
115-
Set<String> copyAttributes = new HashSet<>(attributes);
116-
dynamodbConfig.reservedAttributeNames().forEach(copyAttributes::remove);
117-
dynamodbConfig.reservedAttributeNames().stream()
118-
.filter(attributes::contains)
119-
.map(str -> str.replaceAll("[-.]", ""))
120-
.forEach(attr -> copyAttributes.add("#" + prefix + "_" + attr));
121-
122-
Map<String, String> mappingAttributes = dynamodbConfig.reservedAttributeNames().stream()
123-
.filter(attributes::contains)
124-
.collect(Collectors.toUnmodifiableMap(k -> "#" + prefix + "_" + k.replaceAll("[-.]", ""), k -> k));
125-
126-
var projectionAttributes = String.join(", ", copyAttributes);
127-
108+
var projectionAttributes = String.join(", ", attributes);
128109

129110
ScanRequest.Builder scanRequestBuilder = ScanRequest.builder()
130111
.tableName(tableName)
131112
.projectionExpression(projectionAttributes);
132113

133-
if (!mappingAttributes.isEmpty()) {
134-
scanRequestBuilder
135-
.expressionAttributeNames(mappingAttributes);
136-
}
137-
138114
if (filterAttribute != null && filterAttribute.name() != null &&
139115
filterAttribute.value() != null && filterAttribute.type() != null) {
140116

@@ -158,10 +134,8 @@ public List<JsonNode> scanTable(String tableName, Set<String> attributes, Filter
158134
comparator = ">";
159135
}
160136

161-
String filterPlaceholder = dynamodbConfig.reservedAttributeNames().contains(filterName) ?
162-
"#" + prefix + "_" + filterName.replaceAll("[-.]", "") : filterName;
163137
scanRequestBuilder
164-
.filterExpression(filterPlaceholder + " " + comparator + " :timestamp")
138+
.filterExpression(filterName + " " + comparator + " :timestamp")
165139
.expressionAttributeValues(Map.of(":timestamp", attributeValue));
166140

167141
}

airbyte-integrations/connectors/source-dynamodb/src/main/java/io/airbyte/integrations/source/dynamodb/DynamodbUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ private static AirbyteStateMessage convertStateMessage(final io.airbyte.protocol
8686

8787
record StreamState(
8888

89-
AirbyteStateMessage.AirbyteStateType airbyteStateType,
89+
AirbyteStateMessage.AirbyteStateType airbyteStateType,
9090

91-
List<AirbyteStateMessage> airbyteStateMessages) {
91+
List<AirbyteStateMessage> airbyteStateMessages) {
9292

9393
}
9494

airbyte-integrations/connectors/source-dynamodb/src/main/resources/spec.json

-7
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@
6161
"description": "The corresponding secret to the access key id.",
6262
"airbyte_secret": true,
6363
"examples": ["a012345678910ABCDEFGH/AbCdEfGhEXAMPLEKEY"]
64-
},
65-
"reserved_attribute_names": {
66-
"title": "Reserved attribute names",
67-
"type": "string",
68-
"description": "Comma separated reserved attribute names present in your tables",
69-
"airbyte_secret": true,
70-
"examples": ["name, field_name, field-name"]
7164
}
7265
}
7366
}

airbyte-integrations/connectors/source-dynamodb/src/test-integration/java/io/airbyte/integrations/source/dynamodb/DynamodbDataFactory.java

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public static JsonNode createJsonConfig(DynamodbContainer dynamodbContainer) {
8080
.put("region", dynamodbContainer.getRegion())
8181
.put("access_key_id", dynamodbContainer.getAccessKey())
8282
.put("secret_access_key", dynamodbContainer.getSecretKey())
83-
.put("reserved_attribute_names", "name, field.name, field-name")
8483
.build());
8584
}
8685

airbyte-integrations/connectors/source-dynamodb/src/test-integration/java/io/airbyte/integrations/source/dynamodb/DynamodbOperationsTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -153,29 +153,29 @@ void testScanTable() throws JsonProcessingException, JSONException {
153153
PutItemRequest putItemRequest1 = DynamodbDataFactory.putItemRequest(tableName, Map.of(
154154
"attr_1", AttributeValue.builder().s("str_4").build(),
155155
"attr_2", AttributeValue.builder().s("str_5").build(),
156-
"name", AttributeValue.builder().s("2017-12-21T17:42:34Z").build(),
156+
"attr_3", AttributeValue.builder().s("2017-12-21T17:42:34Z").build(),
157157
"attr_4", AttributeValue.builder().ns("12.5", "74.5").build()));
158158

159159
dynamoDbClient.putItem(putItemRequest1);
160160

161161
PutItemRequest putItemRequest2 = DynamodbDataFactory.putItemRequest(tableName, Map.of(
162162
"attr_1", AttributeValue.builder().s("str_6").build(),
163163
"attr_2", AttributeValue.builder().s("str_7").build(),
164-
"name", AttributeValue.builder().s("2019-12-21T17:42:34Z").build(),
164+
"attr_3", AttributeValue.builder().s("2019-12-21T17:42:34Z").build(),
165165
"attr_6", AttributeValue.builder().ss("str_1", "str_2").build()));
166166

167167
dynamoDbClient.putItem(putItemRequest2);
168168

169-
var response = dynamodbOperations.scanTable(tableName, Set.of("attr_1", "attr_2", "name"),
170-
new DynamodbOperations.FilterAttribute("name", "2018-12-21T17:42:34Z",
169+
var response = dynamodbOperations.scanTable(tableName, Set.of("attr_1", "attr_2", "attr_3"),
170+
new DynamodbOperations.FilterAttribute("attr_3", "2018-12-21T17:42:34Z",
171171
DynamodbOperations.FilterAttribute.FilterType.S));
172172

173173
assertThat(response)
174174
.hasSize(1);
175175

176176
JSONAssert.assertEquals(objectMapper.writeValueAsString(response.get(0)), """
177177
{
178-
"name": "2019-12-21T17:42:34Z",
178+
"attr_3": "2019-12-21T17:42:34Z",
179179
"attr_2": "str_7",
180180
"attr_1": "str_6"
181181
}

connectors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
| **Dockerhub** | <img alt="Dockerhub icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/dockerhub.svg" height="30" height="30"/> | Source | airbyte/source-dockerhub:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/dockerhub) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-dockerhub) | <small>`72d405a3-56d8-499f-a571-667c03406e43`</small> |
6363
| **Dremio** | <img alt="Dremio icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/dremio.svg" height="30" height="30"/> | Source | airbyte/source-dremio:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/dremio) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-dremio) | <small>`d99e9ace-8621-46c2-9144-76ae4751d64b`</small> |
6464
| **Drift** | <img alt="Drift icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/drift.svg" height="30" height="30"/> | Source | airbyte/source-drift:0.2.5 | alpha | [link](https://docs.airbyte.com/integrations/sources/drift) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-drift) | <small>`445831eb-78db-4b1f-8f1f-0d96ad8739e2`</small> |
65-
| **DynamoDB** | <img alt="DynamoDB icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/dynamodb.svg" height="30" height="30"/> | Source | airbyte/source-dynamodb:0.1.2 | alpha | [link](https://docs.airbyte.com/integrations/sources/dynamodb) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-dynamodb) | <small>`50401137-8871-4c5a-abb7-1f5fda35545a`</small> |
65+
| **DynamoDB** | <img alt="DynamoDB icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/dynamodb.svg" height="30" height="30"/> | Source | airbyte/source-dynamodb:0.1.1 | alpha | [link](https://docs.airbyte.com/integrations/sources/dynamodb) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-dynamodb) | <small>`50401137-8871-4c5a-abb7-1f5fda35545a`</small> |
6666
| **E2E Testing** | <img alt="E2E Testing icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/airbyte.svg" height="30" height="30"/> | Source | airbyte/source-e2e-test:2.1.3 | alpha | [link](https://docs.airbyte.com/integrations/sources/e2e-test) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-e2e-test) | <small>`d53f9084-fa6b-4a5a-976c-5b8392f4ad8a`</small> |
6767
| **Elasticsearch** | <img alt="Elasticsearch icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/elasticsearch.svg" height="30" height="30"/> | Source | airbyte/source-elasticsearch:0.1.1 | alpha | [link](https://docs.airbyte.com/integrations/sources/elasticsearch) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-elasticsearch) | <small>`7cf88806-25f5-4e1a-b422-b2fa9e1b0090`</small> |
6868
| **EmailOctopus** | <img alt="EmailOctopus icon" src="https://raw.githubusercontent.com/airbytehq/airbyte/master/airbyte-config/init/src/main/resources/icons/emailoctopus.svg" height="30" height="30"/> | Source | airbyte/source-emailoctopus:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/emailoctopus) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-emailoctopus) | <small>`46b25e70-c980-4590-a811-8deaf50ee09f`</small> |

docs/integrations/sources/dynamodb.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,15 @@ This guide describes in details how you can configure the connector to connect w
5151

5252
### Сonfiguration Parameters
5353

54-
* **_endpoint_**: aws endpoint of the dynamodb instance
55-
* **_region_**: the region code of the dynamodb instance
56-
* **_access_key_id_**: the access key for the IAM user with the required permissions
57-
* **_secret_access_key_**: the secret key for the IAM user with the required permissions
58-
* **_reserved_attribute_names_**: comma separated list of attribute names present in the replication tables which contain reserved words or special characters. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.ExpressionAttributeNames.html
59-
60-
## Changelog
54+
* endpoint: aws endpoint of the dynamodb instance
55+
* region: the region code of the dynamodb instance
56+
* access_key_id: the access key for the IAM user with the required permissions
57+
* secret_access_key: the secret key for the IAM user with the required permissions
6158

6259

63-
| Version | Date | Pull Request | Subject |
64-
|:--------|:-----------|:------------------------------------------------|:---------------------------------------------------------------------|
65-
| 0.1.2 | 01-19-2023 | https://github.com/airbytehq/airbyte/pull/20172 | Fix reserved words in projection expression & make them configurable |
66-
| 0.1.1 | 02-09-2023 | https://github.com/airbytehq/airbyte/pull/22682 | Fix build |
67-
| 0.1.0 | 11-14-2022 | https://github.com/airbytehq/airbyte/pull/18750 | Initial version |
60+
## Changelog
6861

62+
| Version | Date | Pull Request | Subject |
63+
|:--------|:-----------|:-------------|:----------------|
64+
| 0.1.1 | 02-09-2023 | https://github.com/airbytehq/airbyte/pull/22682 | Fix build |
65+
| 0.1.0 | 11-14-2022 | https://github.com/airbytehq/airbyte/pull/18750 | Initial version |

0 commit comments

Comments
 (0)