From 6eed260840a1331ca417f5559950e00a156c1fe5 Mon Sep 17 00:00:00 2001 From: laglangyue <373435126@qq.com> Date: Sun, 7 Aug 2022 00:27:34 +0800 Subject: [PATCH] #2367 fix code style --- .../seatunnel/jdbc/catalog/DMCatalog.java | 25 ++++++++----------- .../internal/dialect/dm/DMDialectFactory.java | 2 +- .../dialect/dm/DMJdbcRowConverter.java | 7 +++--- .../internal/dialect/dm/DMTypeMapper.java | 19 +++++++++++--- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/DMCatalog.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/DMCatalog.java index a02f4b095c8..0fab8a2e4c2 100644 --- a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/DMCatalog.java +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/DMCatalog.java @@ -18,7 +18,16 @@ package org.apache.seatunnel.connectors.seatunnel.jdbc.catalog; -import com.mysql.cj.jdbc.result.ResultSetImpl; +import org.apache.seatunnel.api.table.catalog.CatalogTable; +import org.apache.seatunnel.api.table.catalog.TableIdentifier; +import org.apache.seatunnel.api.table.catalog.TablePath; +import org.apache.seatunnel.api.table.catalog.TableSchema; +import org.apache.seatunnel.api.table.catalog.TableSchema.PrimaryKey; +import org.apache.seatunnel.api.table.catalog.exception.CatalogException; +import org.apache.seatunnel.api.table.catalog.exception.DatabaseNotExistException; +import org.apache.seatunnel.api.table.catalog.exception.TableNotExistException; +import org.apache.seatunnel.api.table.type.SeaTunnelDataType; + import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.DriverManager; @@ -33,15 +42,6 @@ import java.util.Map; import java.util.Optional; import java.util.Set; -import org.apache.seatunnel.api.table.catalog.CatalogTable; -import org.apache.seatunnel.api.table.catalog.TableIdentifier; -import org.apache.seatunnel.api.table.catalog.TablePath; -import org.apache.seatunnel.api.table.catalog.TableSchema; -import org.apache.seatunnel.api.table.catalog.TableSchema.PrimaryKey; -import org.apache.seatunnel.api.table.catalog.exception.CatalogException; -import org.apache.seatunnel.api.table.catalog.exception.DatabaseNotExistException; -import org.apache.seatunnel.api.table.catalog.exception.TableNotExistException; -import org.apache.seatunnel.api.table.type.SeaTunnelDataType; public class DMCatalog extends AbstractJdbcCatalog { @@ -141,11 +141,6 @@ public CatalogTable getTable(TablePath tablePath) throws CatalogException, Table } } - - /** - * @see com.mysql.cj.MysqlType - * @see ResultSetImpl#getObjectStoredProc(int, int) - */ private SeaTunnelDataType fromJdbcType(ResultSetMetaData metadata, int colIndex) throws SQLException { return null; } diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMDialectFactory.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMDialectFactory.java index 0956b596a1d..f0256aaefd5 100644 --- a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMDialectFactory.java +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMDialectFactory.java @@ -17,10 +17,10 @@ package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm; -import com.google.auto.service.AutoService; import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory; +import com.google.auto.service.AutoService; /** * Factory for {@link DMDialect}. diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMJdbcRowConverter.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMJdbcRowConverter.java index f66e27647a6..37e7c46963f 100644 --- a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMJdbcRowConverter.java +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMJdbcRowConverter.java @@ -17,13 +17,14 @@ package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; 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 DMJdbcRowConverter extends AbstractJdbcRowConverter { @Override diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMTypeMapper.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMTypeMapper.java index 97a0d5c0c6e..8e25063e371 100644 --- a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMTypeMapper.java +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DMTypeMapper.java @@ -17,8 +17,6 @@ package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; import org.apache.seatunnel.api.table.type.BasicType; import org.apache.seatunnel.api.table.type.DecimalType; import org.apache.seatunnel.api.table.type.LocalTimeType; @@ -26,6 +24,9 @@ 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 DMTypeMapper implements JdbcDialectTypeMapper { // ============================data types===================== @@ -101,31 +102,37 @@ public class DMTypeMapper implements JdbcDialectTypeMapper { @Override public SeaTunnelDataType mapping(ResultSetMetaData metadata, int colIndex) throws SQLException { String mysqlType = metadata.getColumnTypeName(colIndex).toUpperCase(); -// String columnName = metadata.getColumnName(colIndex); + // String columnName = metadata.getColumnName(colIndex); int precision = metadata.getPrecision(colIndex); int scale = metadata.getScale(colIndex); switch (mysqlType) { case DM_BIT: return BasicType.BOOLEAN_TYPE; + case DM_INT: case DM_INTEGER: case DM_TINYINT: case DM_SMALLINT: case DM_BYTE: return BasicType.INT_TYPE; + case DM_BIGINT: return BasicType.LONG_TYPE; + case DM_NUMERIC: case DM_NUMBER: case DM_DECIMAL: case DM_DEC: return new DecimalType(precision, scale); + case DM_REAL: return BasicType.FLOAT_TYPE; + case DM_FLOAT: case DM_DOUBLE_PRECISION: case DM_DOUBLE: return BasicType.DOUBLE_TYPE; + case DM_CHAR: case DM_CHARACTER: case DM_VARCHAR: @@ -136,12 +143,16 @@ public SeaTunnelDataType mapping(ResultSetMetaData metadata, int colIndex) th case DM_LONGVARCHAR: case DM_CLOB: return BasicType.STRING_TYPE; + case DM_TIMESTAMP: return LocalTimeType.LOCAL_DATE_TIME_TYPE; + case DM_TIME: return LocalTimeType.LOCAL_TIME_TYPE; + case DM_DATE: return LocalTimeType.LOCAL_DATE_TYPE; + // 100G-1 byte case DM_BLOB: case DM_BINARY: @@ -171,7 +182,7 @@ public SeaTunnelDataType mapping(ResultSetMetaData metadata, int colIndex) th default: final String jdbcColumnName = metadata.getColumnName(colIndex); throw new UnsupportedOperationException( - String.format("Doesn't support MySQL type '%s' on column '%s' yet.", mysqlType, jdbcColumnName)); + String.format("Doesn't support Dmdb type '%s' on column '%s' yet.", mysqlType, jdbcColumnName)); } } }