Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve] Remove deprecated code for MultipleRowTyp #8272

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import org.apache.seatunnel.api.table.catalog.schema.TableSchemaOptions;
import org.apache.seatunnel.api.table.factory.FactoryUtil;
import org.apache.seatunnel.api.table.type.BasicType;
import org.apache.seatunnel.api.table.type.MultipleRowType;
import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
import org.apache.seatunnel.api.table.type.SeaTunnelRow;
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
import org.apache.seatunnel.common.utils.SeaTunnelException;

Expand Down Expand Up @@ -148,45 +146,13 @@ public static CatalogTable buildWithConfig(Config config) {
return buildWithConfig(readonlyConfig);
}

public static SeaTunnelDataType<SeaTunnelRow> convertToDataType(
List<CatalogTable> catalogTables) {
if (catalogTables.size() == 1) {
return catalogTables.get(0).getTableSchema().toPhysicalRowDataType();
} else {
return convertToMultipleRowType(catalogTables);
}
}

@Deprecated
private static MultipleRowType convertToMultipleRowType(List<CatalogTable> catalogTables) {
Map<String, SeaTunnelRowType> rowTypeMap = new HashMap<>();
for (CatalogTable catalogTable : catalogTables) {
String tableId = catalogTable.getTableId().toTablePath().toString();
rowTypeMap.put(tableId, catalogTable.getTableSchema().toPhysicalRowDataType());
}
return new MultipleRowType(rowTypeMap);
}

// We need to use buildWithConfig(String catalogName, ReadonlyConfig readonlyConfig);
// Since this method will not inject the correct catalogName into CatalogTable
@Deprecated
public static List<CatalogTable> convertDataTypeToCatalogTables(
SeaTunnelDataType<?> seaTunnelDataType, String tableId) {
List<CatalogTable> catalogTables;
if (seaTunnelDataType instanceof MultipleRowType) {
catalogTables = new ArrayList<>();
for (String id : ((MultipleRowType) seaTunnelDataType).getTableIds()) {
catalogTables.add(
CatalogTableUtil.getCatalogTable(
id, ((MultipleRowType) seaTunnelDataType).getRowType(id)));
}
} else {
catalogTables =
Collections.singletonList(
CatalogTableUtil.getCatalogTable(
tableId, (SeaTunnelRowType) seaTunnelDataType));
}
return catalogTables;
return Collections.singletonList(
CatalogTableUtil.getCatalogTable(tableId, (SeaTunnelRowType) seaTunnelDataType));
}

public static CatalogTable buildWithConfig(ReadonlyConfig readonlyConfig) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ public enum SqlType {
FLOAT16_VECTOR,
BFLOAT16_VECTOR,
SPARSE_FLOAT_VECTOR,
ROW,
MULTIPLE_ROW;
ROW
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.seatunnel.connectors.seatunnel.jdbc.catalog;

import org.apache.seatunnel.api.table.type.MultipleRowType;
import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException;
Expand All @@ -43,8 +42,6 @@ public class DataTypeConvertorTest {
@Test
void testConvertorErrorMsgWithUnsupportedType() {
SeaTunnelRowType rowType = new SeaTunnelRowType(new String[0], new SeaTunnelDataType[0]);
MultipleRowType multipleRowType =
new MultipleRowType(new String[] {"table"}, new SeaTunnelRowType[] {rowType});

DamengDataTypeConvertor dameng = new DamengDataTypeConvertor();
SeaTunnelRuntimeException exception =
Expand Down Expand Up @@ -84,13 +81,6 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['MySQL' unsupported convert type 'UNKNOWN' of 'test' to SeaTunnel data type.]",
exception5.getMessage());
SeaTunnelRuntimeException exception6 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> mysql.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['MySQL' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception6.getMessage());

OracleDataTypeConvertor oracle = new OracleDataTypeConvertor();
SeaTunnelRuntimeException exception7 =
Expand All @@ -107,13 +97,6 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['Oracle' unsupported convert type 'UNSUPPORTED_TYPE' of 'test' to SeaTunnel data type.]",
exception8.getMessage());
SeaTunnelRuntimeException exception9 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> oracle.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['Oracle' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception9.getMessage());

PostgresDataTypeConvertor postgres = new PostgresDataTypeConvertor();
SeaTunnelRuntimeException exception10 =
Expand All @@ -132,13 +115,6 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['Postgres' unsupported convert type 'UNSUPPORTED_TYPE' of 'test' to SeaTunnel data type.]",
exception11.getMessage());
SeaTunnelRuntimeException exception12 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> postgres.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['Postgres' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception12.getMessage());

RedshiftDataTypeConvertor redshift = new RedshiftDataTypeConvertor();
SeaTunnelRuntimeException exception13 =
Expand All @@ -157,13 +133,6 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['Redshift' unsupported convert type 'UNSUPPORTED_TYPE' of 'test' to SeaTunnel data type.]",
exception14.getMessage());
SeaTunnelRuntimeException exception15 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> redshift.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['Redshift' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception15.getMessage());

SnowflakeDataTypeConvertor snowflake = new SnowflakeDataTypeConvertor();
SeaTunnelRuntimeException exception16 =
Expand All @@ -182,13 +151,6 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['Snowflake' unsupported convert type 'UNSUPPORTED_TYPE' of 'test' to SeaTunnel data type.]",
exception17.getMessage());
SeaTunnelRuntimeException exception18 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> snowflake.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['Snowflake' unsupported convert type 'MULTIPLE_ROW' of 'test' to SeaTunnel data type.]",
exception18.getMessage());

SqlServerDataTypeConvertor sqlserver = new SqlServerDataTypeConvertor();
SeaTunnelRuntimeException exception19 =
Expand All @@ -207,13 +169,6 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['SqlServer' unsupported convert type 'UNKNOWN' of 'test' to SeaTunnel data type.]",
exception20.getMessage());
SeaTunnelRuntimeException exception21 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> sqlserver.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['SqlServer' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception21.getMessage());

TiDBDataTypeConvertor tidb = new TiDBDataTypeConvertor();
SeaTunnelRuntimeException exception22 =
Expand All @@ -230,12 +185,5 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['TiDB' unsupported convert type 'UNKNOWN' of 'test' to SeaTunnel data type.]",
exception23.getMessage());
SeaTunnelRuntimeException exception24 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> tidb.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['TiDB' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception24.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.apache.seatunnel.api.table.type.BasicType;
import org.apache.seatunnel.api.table.type.MapType;
import org.apache.seatunnel.api.table.type.MultipleRowType;
import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException;
Expand Down Expand Up @@ -79,8 +78,6 @@ public void getIdentity() {
@Test
public void testConvertorErrorMsgWithUnsupportedType() {
SeaTunnelRowType rowType = new SeaTunnelRowType(new String[0], new SeaTunnelDataType[0]);
MultipleRowType multipleRowType =
new MultipleRowType(new String[] {"table"}, new SeaTunnelRowType[] {rowType});
MaxComputeDataTypeConvertor maxCompute = new MaxComputeDataTypeConvertor();
SeaTunnelRuntimeException exception =
Assertions.assertThrows(
Expand All @@ -98,12 +95,5 @@ public void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['Maxcompute' unsupported convert type 'INTERVAL_DAY_TIME' of 'test' to SeaTunnel data type.]",
exception2.getMessage());
SeaTunnelRuntimeException exception3 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> maxCompute.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['Maxcompute' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception3.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ public String serialize(SeaTunnelRow row) {
for (int i = 0; i < row.getFields().length; i++) {
SqlType sqlType = seaTunnelRowType.getFieldType(i).getSqlType();
Object value;
if (sqlType == SqlType.ARRAY
|| sqlType == SqlType.MAP
|| sqlType == SqlType.ROW
|| sqlType == SqlType.MULTIPLE_ROW) {
if (sqlType == SqlType.ARRAY || sqlType == SqlType.MAP || sqlType == SqlType.ROW) {
// If the field type is complex type, we should keep the origin value.
// It will be transformed to json string in the next step
// JsonUtils.toJsonString(rowMap).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.seatunnel.connectors.seatunnel.starrocks.catalog;

import org.apache.seatunnel.api.table.type.MultipleRowType;
import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
import org.apache.seatunnel.common.exception.SeaTunnelRuntimeException;
Expand All @@ -34,8 +33,6 @@ public class DataTypeConvertorTest {
@Test
void testConvertorErrorMsgWithUnsupportedType() {
SeaTunnelRowType rowType = new SeaTunnelRowType(new String[0], new SeaTunnelDataType[0]);
MultipleRowType multipleRowType =
new MultipleRowType(new String[] {"table"}, new SeaTunnelRowType[] {rowType});
StarRocksDataTypeConvertor starrocks = new StarRocksDataTypeConvertor();
SeaTunnelRuntimeException exception =
Assertions.assertThrows(
Expand All @@ -51,12 +48,5 @@ void testConvertorErrorMsgWithUnsupportedType() {
Assertions.assertEquals(
"ErrorCode:[COMMON-17], ErrorDescription:['StarRocks' unsupported convert type 'UNKNOWN' of 'test' to SeaTunnel data type.]",
exception2.getMessage());
SeaTunnelRuntimeException exception3 =
Assertions.assertThrows(
SeaTunnelRuntimeException.class,
() -> starrocks.toConnectorType("test", multipleRowType, new HashMap<>()));
Assertions.assertEquals(
"ErrorCode:[COMMON-19], ErrorDescription:['StarRocks' unsupported convert SeaTunnel data type 'MULTIPLE_ROW' of 'test' to connector data type.]",
exception3.getMessage());
}
}
Loading
Loading