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 S3 Glue: struct fix #24675

Merged
merged 6 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -14,5 +14,5 @@ ENV APPLICATION destination-s3-glue

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=0.1.3
LABEL io.airbyte.version=0.1.4
LABEL io.airbyte.name=airbyte/destination-s3-glue
Original file line number Diff line number Diff line change
Expand Up @@ -129,28 +129,31 @@ private String transformSchemaRecursive(JsonNode jsonNode) {
if (jsonNode.has("airbyte_type") && jsonNode.get("airbyte_type").asText().equals("integer")) {
yield "int";
}
yield "float";
yield "decimal"; // Default to use decimal as it is a more precise type and allows for large values
}
case "boolean" -> "boolean";
case "integer" -> "int";
case "array" -> {
String arrayType = "array<";
Set<String> itemTypes = filterTypes(jsonNode.get("items").get("type"));
Set<String> itemTypes;
if (jsonNode.has("items")) {
itemTypes = filterTypes(jsonNode.get("items").get("type"));
if (itemTypes.size() > 1) {
// TODO(itaseski) use union instead of array when having multiple types (rare occurrence)?
arrayType += "string>";
} else {
String subtype = transformSchemaRecursive(jsonNode.get("items"));
arrayType += (subtype + ">");
}
} else arrayType += "string>";
yield arrayType;
}
case "object" -> {
if (jsonNode.has("properties")) {
String objectType = "struct<";
Map<String, JsonNode> properties = objectMapper.convertValue(jsonNode.get("properties"), new TypeReference<>() {});
String columnTypes = properties.entrySet().stream()
.map(p -> p.getKey() + " : " + transformSchemaRecursive(p.getValue()))
.map(p -> p.getKey() + ":" + transformSchemaRecursive(p.getValue()))
.collect(Collectors.joining(","));
objectType += (columnTypes + ">");
yield objectType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static Function<ConfiguredAirbyteStream, S3GlueWriteConfig> toWriteConfi
final DestinationSyncMode syncMode = stream.getDestinationSyncMode();
final JsonNode jsonSchema = abStream.getJsonSchema();
((ObjectNode) jsonSchema.get("properties")).putPOJO(JavaBaseConstants.COLUMN_NAME_AB_ID, Map.of("type", "string"));
((ObjectNode) jsonSchema.get("properties")).putPOJO(JavaBaseConstants.COLUMN_NAME_EMITTED_AT, Map.of("type", "integer"));
((ObjectNode) jsonSchema.get("properties")).putPOJO(JavaBaseConstants.COLUMN_NAME_EMITTED_AT, Map.of("type", "number"));
final String location = "s3://" + s3Config.getBucketName() + "/" +
fullOutputPath.substring(0, fullOutputPath.lastIndexOf("/") + 1);
final S3GlueWriteConfig writeConfig =
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/destinations/s3-glue.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ Output files can be compressed. The default option is GZIP compression. If compr

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------|
| 0.1.4 | 2023-03-10 | [23950](https://github.com/airbytehq/airbyte/pull/23950) | Fix schema syntax error for struct fields and handle missing `items` in array fields |
| 0.1.3 | 2023-02-10 | [22822](https://github.com/airbytehq/airbyte/pull/22822) | Fix data type for _ab_emitted_at column in table definition |
| 0.1.2 | 2023-02-01 | [22220](https://github.com/airbytehq/airbyte/pull/22220) | Fix race condition in test, table metadata, add Airbyte sync fields to table definition |
| 0.1.1 | 2022-12-13 | [19907](https://github.com/airbytehq/airbyte/pull/19907) | Fix parsing empty object in schema |
Expand Down