Skip to content

Commit

Permalink
[Feature][Oracle] Support XMLTYPE data integration apache#5716 (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonChou12138 authored Nov 3, 2023
1 parent b98b6bc commit 620f081
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 6 deletions.
20 changes: 20 additions & 0 deletions seatunnel-connectors-v2/connector-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xdb6</artifactId>
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xmlparserv2</artifactId>
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
Expand Down Expand Up @@ -210,6 +222,14 @@
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xdb6</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xmlparserv2</artifactId>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class OracleDataTypeConvertor implements DataTypeConvertor<String> {
public static final String ORACLE_ROWID = "ROWID";
public static final String ORACLE_CLOB = "CLOB";
public static final String ORACLE_NCLOB = "NCLOB";
private static final String ORACLE_XML = "XMLTYPE";
// ------------------------------time-------------------------
public static final String ORACLE_DATE = "DATE";
public static final String ORACLE_TIMESTAMP = "TIMESTAMP";
Expand Down Expand Up @@ -124,6 +125,7 @@ public SeaTunnelDataType<?> toSeaTunnelType(
case ORACLE_ROWID:
case ORACLE_NCLOB:
case ORACLE_CLOB:
case ORACLE_XML:
return BasicType.STRING_TYPE;
case ORACLE_DATE:
return LocalTimeType.LOCAL_DATE_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class OracleTypeMapper implements JdbcDialectTypeMapper {
private static final String ORACLE_ROWID = "ROWID";
private static final String ORACLE_CLOB = "CLOB";
private static final String ORACLE_NCLOB = "NCLOB";
private static final String ORACLE_XML = "SYS.XMLTYPE";

// ------------------------------time-------------------------
private static final String ORACLE_DATE = "DATE";
Expand Down Expand Up @@ -106,6 +107,7 @@ public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex)
case ORACLE_ROWID:
case ORACLE_NCLOB:
case ORACLE_CLOB:
case ORACLE_XML:
return BasicType.STRING_TYPE;
case ORACLE_DATE:
return LocalTimeType.LOCAL_DATE_TYPE;
Expand Down
12 changes: 12 additions & 0 deletions seatunnel-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,18 @@
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xdb6</artifactId>
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xmlparserv2</artifactId>
<version>${oracle.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@
<artifactId>ojdbc8</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xdb6</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.xml</groupId>
<artifactId>xmlparserv2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public class JdbcOracleIT extends AbstractJdbcIT {
+ " BINARY_DOUBLE_COL binary_double,\n"
+ " DATE_COL date,\n"
+ " TIMESTAMP_WITH_3_FRAC_SEC_COL timestamp(3),\n"
+ " TIMESTAMP_WITH_LOCAL_TZ timestamp with local time zone\n"
+ " TIMESTAMP_WITH_LOCAL_TZ timestamp with local time zone,\n"
+ " XML_TYPE_COL \"SYS\".\"XMLTYPE\"\n"
+ ")";

@Override
Expand Down Expand Up @@ -120,7 +121,7 @@ void compareResult(String executeKey) {}

@Override
String driverUrl() {
return "https://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc8/12.2.0.1/ojdbc8-12.2.0.1.jar";
return "https://repo1.maven.org/maven2/com/oracle/database/jdbc/ojdbc8/12.2.0.1/ojdbc8-12.2.0.1.jar && wget https://repo1.maven.org/maven2/com/oracle/database/xml/xdb6/12.2.0.1/xdb6-12.2.0.1.jar && wget https://repo1.maven.org/maven2/com/oracle/database/xml/xmlparserv2/12.2.0.1/xmlparserv2-12.2.0.1.jar";
}

@Override
Expand All @@ -138,7 +139,8 @@ Pair<String[], List<SeaTunnelRow>> initTestData() {
"BINARY_DOUBLE_COL",
"DATE_COL",
"TIMESTAMP_WITH_3_FRAC_SEC_COL",
"TIMESTAMP_WITH_LOCAL_TZ"
"TIMESTAMP_WITH_LOCAL_TZ",
"XML_TYPE_COL"
};

List<SeaTunnelRow> rows = new ArrayList<>();
Expand All @@ -157,7 +159,8 @@ Pair<String[], List<SeaTunnelRow>> initTestData() {
Double.parseDouble("2.2"),
Date.valueOf(LocalDate.now()),
Timestamp.valueOf(LocalDateTime.now()),
Timestamp.valueOf(LocalDateTime.now())
Timestamp.valueOf(LocalDateTime.now()),
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\"><name>SeaTunnel : E2E : Connector V2 : Oracle XMLType</name></project>"
});
rows.add(row);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ source {
url = "jdbc:oracle:thin:@e2e_oracleDb:1521/TESTUSER"
user = testUser
password = testPassword
query = "SELECT VARCHAR_10_COL,CHAR_10_COL,CLOB_COL,NUMBER_3_SF_2_DP,INTEGER_COL,FLOAT_COL,REAL_COL,BINARY_FLOAT_COL,BINARY_DOUBLE_COL,DATE_COL,TIMESTAMP_WITH_3_FRAC_SEC_COL,TIMESTAMP_WITH_LOCAL_TZ FROM E2E_TABLE_SOURCE"
query = "SELECT VARCHAR_10_COL,CHAR_10_COL,CLOB_COL,NUMBER_3_SF_2_DP,INTEGER_COL,FLOAT_COL,REAL_COL,BINARY_FLOAT_COL,BINARY_DOUBLE_COL,DATE_COL,TIMESTAMP_WITH_3_FRAC_SEC_COL,TIMESTAMP_WITH_LOCAL_TZ,XML_TYPE_COL FROM E2E_TABLE_SOURCE"
properties {
database.oracle.jdbc.timezoneAsRegion = "false"
}
Expand All @@ -49,7 +49,7 @@ sink {
url = "jdbc:oracle:thin:@e2e_oracleDb:1521/TESTUSER"
user = testUser
password = testPassword
query = "INSERT INTO E2E_TABLE_SINK (VARCHAR_10_COL,CHAR_10_COL,CLOB_COL,NUMBER_3_SF_2_DP,INTEGER_COL,FLOAT_COL,REAL_COL,BINARY_FLOAT_COL,BINARY_DOUBLE_COL,DATE_COL,TIMESTAMP_WITH_3_FRAC_SEC_COL,TIMESTAMP_WITH_LOCAL_TZ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)"
query = "INSERT INTO E2E_TABLE_SINK (VARCHAR_10_COL,CHAR_10_COL,CLOB_COL,NUMBER_3_SF_2_DP,INTEGER_COL,FLOAT_COL,REAL_COL,BINARY_FLOAT_COL,BINARY_DOUBLE_COL,DATE_COL,TIMESTAMP_WITH_3_FRAC_SEC_COL,TIMESTAMP_WITH_LOCAL_TZ,XML_TYPE_COL) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
properties {
database.oracle.jdbc.timezoneAsRegion = "false"
}
Expand Down

0 comments on commit 620f081

Please sign in to comment.