Biasqo commented on code in PR #171: URL: https://github.com/apache/flink-connector-jdbc/pull/171#discussion_r4383725663
########## flink-connector-jdbc-clickhouse/src/test/java/org/apache/flink/connector/jdbc/clickhouse/table/ClickHouseDynamicTableSinkITCase.java: ########## @@ -0,0 +1,231 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.connector.jdbc.clickhouse.table; + +import org.apache.flink.connector.jdbc.clickhouse.ClickHouseTestBase; +import org.apache.flink.connector.jdbc.clickhouse.database.dialect.ClickHouseDialect; +import org.apache.flink.connector.jdbc.core.table.sink.JdbcDynamicTableSinkITCase; +import org.apache.flink.connector.jdbc.testutils.tables.TableRow; +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableEnvironment; +import org.apache.flink.table.planner.factories.TestValuesTableFactory; +import org.apache.flink.types.Row; +import org.apache.flink.types.RowKind; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import static org.apache.flink.connector.jdbc.clickhouse.ClickHouseTestBase.tableRow; +import static org.apache.flink.connector.jdbc.testutils.tables.TableBuilder.dbType; +import static org.apache.flink.connector.jdbc.testutils.tables.TableBuilder.field; +import static org.apache.flink.connector.jdbc.testutils.tables.TableBuilder.pkField; +import static org.assertj.core.api.Assertions.assertThat; + +/** The Table Sink ITCase for {@link ClickHouseDialect}. */ +class ClickHouseDynamicTableSinkITCase extends JdbcDynamicTableSinkITCase + implements ClickHouseTestBase { + + @Override + protected TableRow createUpsertOutputTable() { + return tableRow( + "dynamicSinkForUpsert", + pkField("cnt", dbType("Int64"), DataTypes.BIGINT().notNull()), + pkField("lencnt", dbType("Int64"), DataTypes.BIGINT().notNull()), + field("cTag", dbType("Int32"), DataTypes.INT().notNull()), + field("ts", dbType("DateTime64(6)"), DataTypes.TIMESTAMP())); + } + + @Override + protected TableRow createAppendOutputTable() { + return tableRow( + "dynamicSinkForAppend", + pkField("id", dbType("Int32"), DataTypes.INT().notNull()), + field("num", dbType("Int64"), DataTypes.BIGINT().notNull()), + field("ts", dbType("DateTime64(6)"), DataTypes.TIMESTAMP())); + } + + @Override + protected TableRow createBatchOutputTable() { + return tableRow( + "dynamicSinkForBatch", + field("NAME", dbType("String"), DataTypes.VARCHAR(20).notNull()), + field("SCORE", dbType("Int64"), DataTypes.BIGINT().notNull())); + } + + @Override + protected TableRow createRealOutputTable() { + return tableRow("REAL_TABLE", field("real_data", dbType("Float32"), DataTypes.FLOAT())); + } + + @Override + protected TableRow createUserOutputTable() { + return tableRow( + "USER_TABLE", + pkField("user_id", dbType("String"), DataTypes.VARCHAR(20).notNull()), + pkField("user_name", dbType("String"), DataTypes.VARCHAR(20).notNull()), + field("email", dbType("String"), DataTypes.VARCHAR(255)), + field("balance", dbType("Decimal(18, 2)"), DataTypes.DECIMAL(18, 2)), + field( + "map_col", + dbType("Map(Int, String)"), + DataTypes.MAP(DataTypes.INT(), DataTypes.STRING())), + field("array_col", dbType("Array(String)"), DataTypes.ARRAY(DataTypes.STRING())), + field("balance2", dbType("Decimal(18, 2)"), DataTypes.DECIMAL(18, 2))); + } + + @Override + protected List<Row> testUserData() { + return Arrays.asList( + Row.of( + "user1", + "Tom", + "[email protected]", + new BigDecimal("8.10"), + new HashMap<Integer, String>() { + { + put(1, "tom123"); + put(2, "tom234"); + } + }, + new String[] {"tommy", "thomas"}, + new BigDecimal("16.20")), + Row.of( + "user3", + "Bailey", + "[email protected]", + new BigDecimal("9.99"), + new HashMap<Integer, String>() { + { + put(3, "bly123"); + put(4, "bly234"); + } + }, + new String[] {"bailey", "bll"}, + new BigDecimal("19.98")), + Row.of( + "user4", + "Tina", + "[email protected]", + new BigDecimal("11.30"), + new HashMap<Integer, String>() { + { + put(3, "tina123"); + put(4, "tina3333"); + } + }, + new String[] {"tnn", "tina"}, + new BigDecimal("22.60"))); + } + + @Override + protected void testReadingFromChangelogSource() throws Exception { Review Comment: Done ########## flink-connector-jdbc-core/src/test/java/org/apache/flink/connector/jdbc/utils/JdbcTypeUtilTest.java: ########## @@ -35,7 +35,6 @@ class JdbcTypeUtilTest { void testTypeConversions() { assertThat(logicalTypeToSqlType(LogicalTypeRoot.INTEGER)).isEqualTo(Types.INTEGER); testUnsupportedType(LogicalTypeRoot.RAW); - testUnsupportedType(LogicalTypeRoot.MAP); Review Comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
