ic4y commented on code in PR #2377: URL: https://github.com/apache/incubator-seatunnel/pull/2377#discussion_r943182844
########## seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbTypeMapper.java: ########## @@ -0,0 +1,188 @@ +/* + * 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm; + +import org.apache.seatunnel.api.table.type.BasicType; +import org.apache.seatunnel.api.table.type.DecimalType; +import org.apache.seatunnel.api.table.type.LocalTimeType; +import org.apache.seatunnel.api.table.type.PrimitiveByteArrayType; +import org.apache.seatunnel.api.table.type.SeaTunnelDataType; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; + +import java.sql.ResultSetMetaData; +import java.sql.SQLException; + +public class DmdbTypeMapper implements JdbcDialectTypeMapper { + + // ============================data types===================== + private static final String DM_BIT = "BIT"; + + // ----------------------------number------------------------- + private static final String DM_NUMERIC = "NUMERIC"; + private static final String DM_NUMBER = "NUMBER"; + private static final String DM_DECIMAL = "DECIMAL"; + /** + * same to DECIMAL + */ + private static final String DM_DEC = "DEC"; + + // ----------------------------int----------------------------- + private static final String DM_INTEGER = "INTEGER"; + private static final String DM_INT = "INT"; + private static final String DM_BIGINT = "BIGINT"; + private static final String DM_TINYINT = "TINYINT"; + private static final String DM_BYTE = "BYTE"; + private static final String DM_SMALLINT = "SMALLINT"; + + // dm float is double for Cpp. + private static final String DM_FLOAT = "FLOAT"; + private static final String DM_DOUBLE = "DOUBLE"; + private static final String DM_DOUBLE_PRECISION = "DOUBLE PRECISION"; + private static final String DM_REAL = "REAL"; + + // DM_CHAR DM_CHARACTER DM_VARCHAR DM_VARCHAR2 max is 32767 + private static final String DM_CHAR = "CHAR"; + private static final String DM_CHARACTER = "CHARACTER"; + private static final String DM_VARCHAR = "VARCHAR"; + private static final String DM_VARCHAR2 = "VARCHAR2"; + private static final String DM_LONGVARCHAR = "LONGVARCHAR"; + private static final String DM_CLOB = "CLOB"; + private static final String DM_TEXT = "TEXT"; + private static final String DM_LONG = "LONG"; + + // ------------------------------time------------------------- + private static final String DM_DATE = "DATE"; + private static final String DM_TIME = "TIME"; + private static final String DM_TIMESTAMP = "TIMESTAMP"; + + // ---------------------------binary--------------------------- + private static final String DM_BINARY = "BINARY"; + private static final String DM_VARBINARY = "VARBINARY"; + + // -------------------------time interval----------------------- + private static final String DM_INTERVAL_YEAR_TO_MONTH = "INTERVAL YEAR TO MONTH"; + private static final String DM_INTERVAL_YEAR = "INTERVAL YEAR"; + private static final String DM_INTERVAL_MONTH = "INTERVAL MONTH"; + private static final String DM_INTERVAL_DAY = "INTERVAL DAY"; + private static final String DM_INTERVAL_DAY_TO_HOUR = "INTERVAL DAY TO HOUR"; + private static final String DM_INTERVAL_DAY_TO_MINUTE = "INTERVAL DAY TO MINUTE"; + private static final String DM_INTERVAL_DAY_TO_SECOND = "INTERVAL DAY TO SECOND"; + private static final String DM_INTERVAL_HOUR = "INTERVAL HOUR"; + private static final String DM_INTERVAL_HOUR_TO_MINUTE = "INTERVAL HOUR TO MINUTE"; + private static final String DM_INTERVAL_HOUR_TO_SECOND = "INTERVAL HOUR TO SECOND"; + private static final String DM_INTERVAL_MINUTE = "INTERVAL MINUTE"; + private static final String DM_INTERVAL_MINUTE_TO_SECOND = "INTERVAL MINUTE TO SECOND"; + private static final String DM_INTERVAL_SECOND = "INTERVAL SECOND"; + // time zone + private static final String DM_TIME_WITH_TIME_ZONE = "TIME WITH TIME ZONE"; + private static final String DM_TIMESTAMP_WITH_TIME_ZONE = "TIMESTAMP WITH TIME ZONE"; + private static final String TIMESTAMP_WITH_LOCAL_TIME_ZONE = "TIMESTAMP WITH LOCAL TIME ZONE"; + + // ------------------------------blob------------------------- + public static final String DM_BLOB = "BLOB"; + public static final String DM_BFILE = "BFILE"; + public static final String DM_IMAGE = "IMAGE"; + public static final String DM_LONGVARBINARY = "LONGVARBINARY"; + + @Override + public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex) throws SQLException { + String dmdbType = metadata.getColumnTypeName(colIndex).toUpperCase(); + // String columnName = metadata.getColumnName(colIndex); Review Comment: Delete it if you don't need it ########## seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbJdbcRowConverter.java: ########## @@ -0,0 +1,39 @@ +/* + * 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm; + +import org.apache.seatunnel.api.table.type.SeaTunnelRow; +import org.apache.seatunnel.api.table.type.SeaTunnelRowType; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.AbstractJdbcRowConverter; + +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; + +public class DmdbJdbcRowConverter extends AbstractJdbcRowConverter { + + @Override + public String converterName() { + return "Dmdb"; + } + + @Override + public SeaTunnelRow toInternal(ResultSet rs, ResultSetMetaData metaData, SeaTunnelRowType typeInfo) throws SQLException { + return super.toInternal(rs, metaData, typeInfo); Review Comment: Is it OK to use the default `toInternal`?, it is recommended to test the covered data types locally ########## pom.xml: ########## @@ -352,6 +353,13 @@ <scope>test</scope> </dependency> + <dependency> + <groupId>com.dameng</groupId> + <artifactId>DmJdbcDriver18</artifactId> + <version>${dm-jdbc.version}</version> + <scope>provided</scope> Review Comment: this `scope` need to be `test`. We don't want to include DmJdbcDriver18.jar in the connector's package -- 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]
