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: fix parsing empty object in schema #19907

Merged
merged 9 commits into from
Dec 14, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ private String transformSchemaRecursive(JsonNode jsonNode) {
yield arrayType;
}
case "object" -> {
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()))
.collect(Collectors.joining(","));
objectType += (columnTypes + ">");
yield objectType;
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()))
.collect(Collectors.joining(","));
objectType += (columnTypes + ">");
yield objectType;
} else {
yield "string";
}
}
default -> type;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.base.Preconditions;

import io.airbyte.commons.functional.CheckedBiConsumer;
import io.airbyte.commons.functional.CheckedBiFunction;
import io.airbyte.commons.json.Jsons;
import io.airbyte.integrations.base.AirbyteMessageConsumer;
import io.airbyte.integrations.base.AirbyteStreamNameNamespacePair;

import io.airbyte.integrations.destination.NamingConventionTransformer;
import io.airbyte.integrations.destination.buffered_stream_consumer.BufferedStreamConsumer;
import io.airbyte.integrations.destination.buffered_stream_consumer.OnCloseFunction;
Expand All @@ -22,6 +23,7 @@
import io.airbyte.integrations.destination.s3.WriteConfig;
import io.airbyte.protocol.models.AirbyteMessage;
import io.airbyte.protocol.models.AirbyteStream;
import io.airbyte.protocol.models.AirbyteStreamNameNamespacePair;
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog;
import io.airbyte.protocol.models.ConfiguredAirbyteStream;
import io.airbyte.protocol.models.DestinationSyncMode;
Expand Down