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 S3V2: Avro does not fail on unsupported string formats #50420

Merged
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -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? {
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Loading