diff --git a/airbyte-integrations/connectors/destination-clickhouse/gradle.properties b/airbyte-integrations/connectors/destination-clickhouse/gradle.properties index 99f744a7c12..0fd3ae781fc 100644 --- a/airbyte-integrations/connectors/destination-clickhouse/gradle.properties +++ b/airbyte-integrations/connectors/destination-clickhouse/gradle.properties @@ -1,2 +1,2 @@ -cdkVersion=0.1.89 +cdkVersion=local JunitMethodExecutionTimeout=10m diff --git a/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseSchemaMapperTest.kt b/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseSchemaMapperTest.kt new file mode 100644 index 00000000000..961a465dc26 --- /dev/null +++ b/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseSchemaMapperTest.kt @@ -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 + ) + } +} diff --git a/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseTableSchemaEvolutionTest.kt b/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseTableSchemaEvolutionTest.kt index 8a3cbe13624..be3b4f80b0a 100644 --- a/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseTableSchemaEvolutionTest.kt +++ b/airbyte-integrations/connectors/destination-clickhouse/src/test-integration/kotlin/io/airbyte/integrations/destination/clickhouse/component/ClickhouseTableSchemaEvolutionTest.kt @@ -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), + ) + ) + } }