Skip to content

Commit

Permalink
Destination S3V2: Avro name mangling fix (take two) (#50415)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnny-schmidt authored Dec 24, 2024
1 parent 964e4da commit 6fa2301
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AirbyteTypeToAvroSchema {
.fold(builder) { acc, (name, field) ->
val converted = convert(field.type, path + name)
val propertySchema = maybeMakeNullable(field, converted)
val nameMangled = Transformations.toAlphanumericAndUnderscore(name)
val nameMangled = Transformations.toAvroSafeName(name)
acc.name(nameMangled).type(propertySchema).let {
if (field.nullable) {
it.withDefault(null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 Airbyte, Inc., all rights reserved.
*/

import io.airbyte.cdk.load.command.DestinationStream
import io.airbyte.cdk.load.data.FieldType
import io.airbyte.cdk.load.data.ObjectType
import io.airbyte.cdk.load.data.StringType
import io.airbyte.cdk.load.data.avro.toAvroSchema
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow

class AirbyteTypeToAvroSchemaTest {
@Test
fun `test name mangling`() {
val schema =
ObjectType(
properties =
linkedMapOf(
"1d_view" to FieldType(type = StringType, nullable = false),
)
)
val descriptor = DestinationStream.Descriptor("test", "stream")
assertDoesNotThrow { schema.toAvroSchema(descriptor) }
}
}

0 comments on commit 6fa2301

Please sign in to comment.