1
0
mirror of synced 2025-12-19 10:00:34 -05:00
This commit is contained in:
Edward Gao
2025-12-18 16:15:39 -08:00
parent 3f8ef034d3
commit f199cbe2f3
3 changed files with 98 additions and 19 deletions

View File

@@ -1,2 +1,2 @@
cdkVersion=0.1.89
cdkVersion=local
JunitMethodExecutionTimeout=10m

View File

@@ -0,0 +1,72 @@
/*
* Copyright (c) 2025 Airbyte, Inc., all rights reserved.
*/
package io.airbyte.integrations.destination.clickhouse.component
import io.airbyte.cdk.load.component.SchemaMapperSuite
import io.airbyte.cdk.load.schema.TableSchemaMapper
import io.airbyte.cdk.load.schema.model.TableName
import io.micronaut.test.extensions.junit5.annotation.MicronautTest
import org.junit.jupiter.api.Test
@MicronautTest(environments = ["component"])
class ClickhouseSchemaMapperTest(override val tableSchemaMapper: TableSchemaMapper) :
SchemaMapperSuite {
@Test
fun `simple table name`() {
super.`simple table name`(TableName("namespace_test", "table_test"))
}
@Test
fun `funky chars in table name`() {
super.`funky chars in table name`(
TableName(
"namespace_test___________________________________",
"table_test___________________________________"
)
)
}
@Test
fun `table name starts with non-letter character`() {
super.`table name starts with non-letter character`(TableName("_1foo", "_1foo"))
}
@Test
fun `table name is reserved keyword`() {
super.`table name is reserved keyword`(TableName("table", "table"))
}
@Test
fun `simple temp table name`() {
super.`simple temp table name`(TableName("foo", "foobar601b8ba9fdecdc2856c1983a55e6a8cf"))
}
@Test
fun `simple column name`() {
super.`simple column name`("column_test")
}
@Test
fun `column name with funky chars`() {
super.`column name with funky chars`("column_test___________________________________")
}
@Test
fun `column name starts with non-letter character`() {
super.`column name starts with non-letter character`("_1foo")
}
@Test
fun `column name is reserved keyword`() {
super.`column name is reserved keyword`("table")
}
@Test
fun `column types support all airbyte types`() {
super.`column types support all airbyte types`(
ClickhouseTableSchemaEvolutionTest.allTypesSchema.columns
)
}
}

View File

@@ -24,24 +24,7 @@ class ClickhouseTableSchemaEvolutionTest(
override val testClient: TestTableOperationsClient,
override val schemaFactory: TableSchemaFactory,
) : TableSchemaEvolutionSuite {
private val allTypesTableSchema =
TableSchema(
mapOf(
"string" to ColumnType(ClickhouseSqlTypes.STRING, true),
"boolean" to ColumnType(ClickhouseSqlTypes.BOOL, true),
"integer" to ColumnType(ClickhouseSqlTypes.INT64, true),
"number" to ColumnType(ClickhouseSqlTypes.DECIMAL_WITH_PRECISION_AND_SCALE, true),
"date" to ColumnType(ClickhouseSqlTypes.DATE32, true),
"timestamp_tz" to ColumnType(ClickhouseSqlTypes.DATETIME_WITH_PRECISION, true),
"timestamp_ntz" to ColumnType(ClickhouseSqlTypes.DATETIME_WITH_PRECISION, true),
"time_tz" to ColumnType(ClickhouseSqlTypes.STRING, true),
"time_ntz" to ColumnType(ClickhouseSqlTypes.STRING, true),
// yes, these three are different
"array" to ColumnType(ClickhouseSqlTypes.STRING, true),
"object" to ColumnType(ClickhouseSqlTypes.JSON, true),
"unknown" to ColumnType(ClickhouseSqlTypes.STRING, true),
)
)
private val allTypesTableSchema = allTypesSchema
@Test
fun `discover recognizes all data types`() {
@@ -115,4 +98,28 @@ class ClickhouseTableSchemaEvolutionTest(
override fun `change from unknown type to string type`() {
super.`change from unknown type to string type`()
}
companion object {
val allTypesSchema =
TableSchema(
mapOf(
"string" to ColumnType(ClickhouseSqlTypes.STRING, true),
"boolean" to ColumnType(ClickhouseSqlTypes.BOOL, true),
"integer" to ColumnType(ClickhouseSqlTypes.INT64, true),
"number" to
ColumnType(ClickhouseSqlTypes.DECIMAL_WITH_PRECISION_AND_SCALE, true),
"date" to ColumnType(ClickhouseSqlTypes.DATE32, true),
"timestamp_tz" to ColumnType(ClickhouseSqlTypes.DATETIME_WITH_PRECISION, true),
"timestamp_ntz" to ColumnType(ClickhouseSqlTypes.DATETIME_WITH_PRECISION, true),
"time_tz" to ColumnType(ClickhouseSqlTypes.STRING, true),
"time_ntz" to ColumnType(ClickhouseSqlTypes.STRING, true),
// yes, these three are different
"array" to ColumnType(ClickhouseSqlTypes.STRING, true),
"object" to ColumnType(ClickhouseSqlTypes.JSON, true),
"union" to ColumnType(ClickhouseSqlTypes.STRING, true),
"legacy_union" to ColumnType(ClickhouseSqlTypes.STRING, true),
"unknown" to ColumnType(ClickhouseSqlTypes.STRING, true),
)
)
}
}