Skip to content

Commit

Permalink
apache#2367 fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
laglangyue committed Aug 6, 2022
1 parent 6f0249c commit 6eed260
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

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;
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 DMTypeMapper implements JdbcDialectTypeMapper {

// ============================data types=====================
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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));
}
}
}

0 comments on commit 6eed260

Please sign in to comment.