add test
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
cdkVersion=0.1.89
|
cdkVersion=local
|
||||||
JunitMethodExecutionTimeout=10m
|
JunitMethodExecutionTimeout=10m
|
||||||
|
|||||||
@@ -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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,24 +24,7 @@ class ClickhouseTableSchemaEvolutionTest(
|
|||||||
override val testClient: TestTableOperationsClient,
|
override val testClient: TestTableOperationsClient,
|
||||||
override val schemaFactory: TableSchemaFactory,
|
override val schemaFactory: TableSchemaFactory,
|
||||||
) : TableSchemaEvolutionSuite {
|
) : TableSchemaEvolutionSuite {
|
||||||
private val allTypesTableSchema =
|
private val allTypesTableSchema = 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),
|
|
||||||
"unknown" to ColumnType(ClickhouseSqlTypes.STRING, true),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `discover recognizes all data types`() {
|
fun `discover recognizes all data types`() {
|
||||||
@@ -115,4 +98,28 @@ class ClickhouseTableSchemaEvolutionTest(
|
|||||||
override fun `change from unknown type to string type`() {
|
override fun `change from unknown type to string type`() {
|
||||||
super.`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),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user