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 name mangling fix (take two) #50415

Merged
merged 1 commit into from
Dec 24, 2024
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 @@ -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) }
}
}
Loading