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

[BUG][Connector-V2][Jdbc] support postgresql xml type #5724

Merged
merged 5 commits into from
Oct 27, 2023
Merged
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 @@ -108,6 +108,7 @@ public class PostgresDataTypeConvertor implements DataTypeConvertor<String> {
public static final String PG_GEOGRAPHY = "geography";
public static final String PG_JSON = "json";
public static final String PG_JSONB = "jsonb";
public static final String PG_XML = "xml";

@Override
public SeaTunnelDataType<?> toSeaTunnelType(String connectorDataType) {
Expand Down Expand Up @@ -165,6 +166,7 @@ public SeaTunnelDataType<?> toSeaTunnelType(
case PG_GEOGRAPHY:
case PG_JSON:
case PG_JSONB:
case PG_XML:
return BasicType.STRING_TYPE;
case PG_CHAR_ARRAY:
case PG_CHARACTER_ARRAY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class PostgresTypeMapper implements JdbcDialectTypeMapper {
private static final String PG_GEOGRAPHY = "geography";
private static final String PG_JSON = "json";
private static final String PG_JSONB = "jsonb";
private static final String PG_XML = "xml";

@Override
public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex)
Expand Down Expand Up @@ -142,6 +143,7 @@ public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex)
case PG_GEOGRAPHY:
case PG_JSON:
case PG_JSONB:
case PG_XML:
return BasicType.STRING_TYPE;
case PG_CHAR_ARRAY:
case PG_CHARACTER_ARRAY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public class JdbcPostgresIT extends TestSuiteBase implements TestResource {
+ " geometrycollection geometry(GEOMETRYCOLLECTION, 4326),\n"
+ " geog geography(POINT, 4326),\n"
+ " json_col json NOT NULL,\n"
+ " jsonb_col jsonb NOT NULL\n"
+ " jsonb_col jsonb NOT NULL,\n"
+ " xml_col xml NOT NULL\n"
+ ")";
private static final String PG_SINK_DDL =
"CREATE TABLE IF NOT EXISTS pg_e2e_sink_table (\n"
Expand Down Expand Up @@ -137,7 +138,8 @@ public class JdbcPostgresIT extends TestSuiteBase implements TestResource {
+ " geometrycollection varchar(2000) NULL,\n"
+ " geog varchar(2000) NULL,\n"
+ " json_col json NOT NULL \n,"
+ " jsonb_col jsonb NOT NULL\n"
+ " jsonb_col jsonb NOT NULL,\n"
+ " xml_col xml NOT NULL\n"
+ " )";
private static final String SOURCE_SQL =
"select \n"
Expand Down Expand Up @@ -170,7 +172,8 @@ public class JdbcPostgresIT extends TestSuiteBase implements TestResource {
+ "geometrycollection,\n"
+ "geog,\n"
+ "json_col,\n"
+ "jsonb_col\n"
+ "jsonb_col,\n"
+ " cast(xml_col as varchar) \n"
+ "from pg_e2e_source_table";
private static final String SINK_SQL =
"select\n"
Expand Down Expand Up @@ -203,7 +206,8 @@ public class JdbcPostgresIT extends TestSuiteBase implements TestResource {
+ " cast(geometrycollection as geometry) as geometrycollection,\n"
+ " cast(geog as geography) as geog,\n"
+ " json_col,\n"
+ " jsonb_col\n"
+ " jsonb_col,\n"
+ " cast(xml_col as varchar) \n"
+ "from\n"
+ " pg_e2e_sink_table";

Expand Down Expand Up @@ -333,7 +337,8 @@ private void initializeJdbcTable() {
+ " geometrycollection,\n"
+ " geog,\n"
+ " json_col,\n"
+ " jsonb_col \n"
+ " jsonb_col, \n"
+ " xml_col \n"
+ " )\n"
+ "VALUES\n"
+ " (\n"
Expand Down Expand Up @@ -386,7 +391,8 @@ private void initializeJdbcTable() {
+ " ),\n"
+ " ST_GeographyFromText('POINT(-122.3452 47.5925)'),\n"
+ " '{\"key\":\"test\"}',\n"
+ " '{\"key\":\"test\"}'\n"
+ " '{\"key\":\"test\"}',\n"
+ " '<XX:NewSize>test</XX:NewSize>'\n"
+ " )");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source{
password = "test"
query ="""select gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col, double_precision_col,
smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point, linestring, polygon_colums, multipoint,
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col from pg_e2e_source_table"""
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col,xml_col from pg_e2e_source_table"""
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source{
password = "test"
query ="""select gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col, double_precision_col,
smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point, linestring, polygon_colums, multipoint,
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col from pg_e2e_source_table"""
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col,xml_col from pg_e2e_source_table"""
partition_column= "gid"

result_table_name = "jdbc"
Expand All @@ -47,7 +47,7 @@ sink {
connection_check_timeout_sec = 100
query ="""INSERT INTO pg_e2e_sink_table ( gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col,
double_precision_col, smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point,
linestring, polygon_colums, multipoint, multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col)
VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"""
linestring, polygon_colums, multipoint, multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col,xml_col)
VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,? )"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source{
password = "test"
query ="""select gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col, double_precision_col,
smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point, linestring, polygon_colums, multipoint,
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col from pg_e2e_source_table"""
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col,xml_col from pg_e2e_source_table"""
partition_column= "gid"

result_table_name = "jdbc"
Expand All @@ -51,7 +51,7 @@ sink {
connection_check_timeout_sec = 100
query ="""INSERT INTO pg_e2e_sink_table ( gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col,
double_precision_col, smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point,
linestring, polygon_colums, multipoint, multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col )
VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"""
linestring, polygon_colums, multipoint, multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col,xml_col )
VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?)"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ source {
password = "test"
query ="""select gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col, double_precision_col,
smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point, linestring, polygon_colums, multipoint,
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col from pg_e2e_source_table"""
multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col ,xml_col from pg_e2e_source_table"""
}
}

Expand All @@ -45,8 +45,8 @@ sink {
max_retries = 0
query ="""INSERT INTO pg_e2e_sink_table ( gid, text_col, varchar_col, char_col, boolean_col, smallint_col, integer_col, bigint_col, decimal_col, numeric_col, real_col,
double_precision_col, smallserial_col, serial_col, bigserial_col, date_col, timestamp_col, bpchar_col, age, name, point,
linestring, polygon_colums, multipoint, multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col )
VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"""
linestring, polygon_colums, multipoint, multilinestring, multipolygon, geometrycollection, geog, json_col, jsonb_col ,xml_col)
VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)"""

is_exactly_once = "true"

Expand Down