From eb1e08c56c003ecc5e7db0e24b7bb8443fde8e60 Mon Sep 17 00:00:00 2001 From: Johnny Schmidt Date: Tue, 24 Dec 2024 15:20:04 -0800 Subject: [PATCH] Destination S3V2: Avro does not fail on unsupported string formats --- .../airbyte/cdk/load/data/json/JsonSchemaToAirbyteType.kt | 8 +++++++- .../load/data/json/JsonSchemaToAirbyteSchemaTypeTest.kt | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteType.kt b/airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteType.kt index 4f9736282172..f3a0ba33ffbd 100644 --- a/airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteType.kt +++ b/airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteType.kt @@ -8,8 +8,11 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.JsonNodeFactory import com.fasterxml.jackson.databind.node.ObjectNode import io.airbyte.cdk.load.data.* +import io.github.oshai.kotlinlogging.KotlinLogging class JsonSchemaToAirbyteType { + private val log = KotlinLogging.logger {} + fun convert(schema: JsonNode): AirbyteType = convertInner(schema)!! private fun convertInner(schema: JsonNode): AirbyteType? { @@ -87,7 +90,10 @@ class JsonSchemaToAirbyteType { TimestampTypeWithTimezone } null -> StringType - else -> UnknownType(schema) + else -> { + log.warn { "Ignoring unrecognized string format: ${schema.get("format").asText()}" } + StringType + } } private fun fromNumber(schema: ObjectNode): AirbyteType = diff --git a/airbyte-cdk/bulk/core/load/src/test/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteSchemaTypeTest.kt b/airbyte-cdk/bulk/core/load/src/test/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteSchemaTypeTest.kt index 59e8ccd33bd8..2b6cc39f0fd0 100644 --- a/airbyte-cdk/bulk/core/load/src/test/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteSchemaTypeTest.kt +++ b/airbyte-cdk/bulk/core/load/src/test/kotlin/io/airbyte/cdk/load/data/json/JsonSchemaToAirbyteSchemaTypeTest.kt @@ -251,4 +251,11 @@ class JsonSchemaToAirbyteSchemaTypeTest { val airbyteType = JsonSchemaToAirbyteType().convert(inputSchema) Assertions.assertEquals(UnionType.of(StringType, IntegerType), airbyteType) } + + @Test + fun testUnrecognizedStringFormats() { + val schemaNode = ofType("string").put("format", "foo") + val airbyteType = JsonSchemaToAirbyteType().convert(schemaNode) + Assertions.assertTrue(airbyteType is StringType) + } }