diff --git a/amazon-redshift-plugin/pom.xml b/amazon-redshift-plugin/pom.xml index 1b951bb08..e187c1ce6 100644 --- a/amazon-redshift-plugin/pom.xml +++ b/amazon-redshift-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Amazon Redshift plugin diff --git a/aurora-mysql-plugin/pom.xml b/aurora-mysql-plugin/pom.xml index 79aab9eb7..bc398a7af 100644 --- a/aurora-mysql-plugin/pom.xml +++ b/aurora-mysql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Aurora DB MySQL plugin diff --git a/aurora-postgresql-plugin/pom.xml b/aurora-postgresql-plugin/pom.xml index 4f6b0e1ad..0353433b6 100644 --- a/aurora-postgresql-plugin/pom.xml +++ b/aurora-postgresql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Aurora DB PostgreSQL plugin diff --git a/cloudsql-mysql-plugin/pom.xml b/cloudsql-mysql-plugin/pom.xml index a50760364..296110ecd 100644 --- a/cloudsql-mysql-plugin/pom.xml +++ b/cloudsql-mysql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT CloudSQL MySQL plugin diff --git a/cloudsql-postgresql-plugin/pom.xml b/cloudsql-postgresql-plugin/pom.xml index 2cb4c1a40..56b4e611e 100644 --- a/cloudsql-postgresql-plugin/pom.xml +++ b/cloudsql-postgresql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT CloudSQL PostgreSQL plugin diff --git a/database-commons/pom.xml b/database-commons/pom.xml index ee7e24bbb..559ea3423 100644 --- a/database-commons/pom.xml +++ b/database-commons/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Database Commons diff --git a/db2-plugin/pom.xml b/db2-plugin/pom.xml index 82dc22c8d..39900c4ae 100644 --- a/db2-plugin/pom.xml +++ b/db2-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT IBM DB2 plugin diff --git a/generic-database-plugin/pom.xml b/generic-database-plugin/pom.xml index 51494cd36..daa6f8715 100644 --- a/generic-database-plugin/pom.xml +++ b/generic-database-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Generic database plugin diff --git a/generic-db-argument-setter/pom.xml b/generic-db-argument-setter/pom.xml index 14c353462..239e7196f 100644 --- a/generic-db-argument-setter/pom.xml +++ b/generic-db-argument-setter/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Generic database argument setter plugin diff --git a/mariadb-plugin/pom.xml b/mariadb-plugin/pom.xml index eee9502dd..fbf3c7518 100644 --- a/mariadb-plugin/pom.xml +++ b/mariadb-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Maria DB plugin diff --git a/memsql-plugin/pom.xml b/memsql-plugin/pom.xml index 4b400c46b..63bd2fa3b 100644 --- a/memsql-plugin/pom.xml +++ b/memsql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Memsql plugin diff --git a/mssql-plugin/pom.xml b/mssql-plugin/pom.xml index e476867e4..ce876bbfc 100644 --- a/mssql-plugin/pom.xml +++ b/mssql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Microsoft SQL Server plugin diff --git a/mysql-plugin/pom.xml b/mysql-plugin/pom.xml index dbf8d82bf..7cbf437ad 100644 --- a/mysql-plugin/pom.xml +++ b/mysql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Mysql plugin diff --git a/netezza-plugin/pom.xml b/netezza-plugin/pom.xml index ba9885aa5..b14874463 100644 --- a/netezza-plugin/pom.xml +++ b/netezza-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Netezza plugin diff --git a/oracle-plugin/pom.xml b/oracle-plugin/pom.xml index 83bd315ee..7990c492a 100644 --- a/oracle-plugin/pom.xml +++ b/oracle-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT Oracle plugin diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnector.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnector.java index 3094e7152..579274e88 100644 --- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnector.java +++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnector.java @@ -114,7 +114,8 @@ protected DBConnectorPath getDBConnectorPath(String path) { protected SchemaReader getSchemaReader(String sessionID) { return new OracleSourceSchemaReader(sessionID, config.getTreatAsOldTimestamp(), config.getTreatPrecisionlessNumAsDeci(), - config.getTreatTimestampLTZAsTimestamp()); + config.getTreatTimestampLTZAsTimestamp(), + config.getXmlTypeEnabled()); } @Override diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java index 79d14215b..03dc56d6d 100644 --- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java +++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConnectorConfig.java @@ -42,14 +42,15 @@ public OracleConnectorConfig(String host, int port, String user, String password public OracleConnectorConfig(String host, int port, String user, String password, String jdbcPluginName, String connectionArguments, String connectionType, String database) { this(host, port, user, password, jdbcPluginName, connectionArguments, connectionType, database, null, null, null, - null, null); + null, null, null); } public OracleConnectorConfig(String host, int port, String user, String password, String jdbcPluginName, String connectionArguments, String connectionType, String database, String role, Boolean useSSL, @Nullable Boolean treatAsOldTimestamp, @Nullable Boolean treatPrecisionlessNumAsDeci, - @Nullable Boolean treatTimestampLTZAsTimestamp) { + @Nullable Boolean treatTimestampLTZAsTimestamp, + @Nullable Boolean enableXmlType) { this.host = host; this.port = port; @@ -64,6 +65,7 @@ public OracleConnectorConfig(String host, int port, String user, String password this.treatAsOldTimestamp = treatAsOldTimestamp; this.treatPrecisionlessNumAsDeci = treatPrecisionlessNumAsDeci; this.treatTimestampLTZAsTimestamp = treatTimestampLTZAsTimestamp; + this.enableXmlType = enableXmlType; } @Override @@ -101,10 +103,16 @@ public String getConnectionString() { public Boolean treatPrecisionlessNumAsDeci; @Name(OracleConstants.TREAT_TIMESTAMP_LTZ_AS_TIMESTAMP) - @Description("A hidden field to handle mapping of Oracle Timestamp_LTZ data type to BQ Timestamp.") + @Description("A hidden field to handle mapping of Oracle Timestamp_LTZ data type.") @Nullable public Boolean treatTimestampLTZAsTimestamp; + @Name(OracleConstants.ENABLE_XML_TYPE) + @Description("A hidden field to handle mapping of Oracle XML type.") + @Nullable + public Boolean enableXmlType; + + @Override protected int getDefaultPort() { return 1521; @@ -139,6 +147,10 @@ public Boolean getTreatTimestampLTZAsTimestamp() { return Boolean.TRUE.equals(treatTimestampLTZAsTimestamp); } + public Boolean getXmlTypeEnabled() { + return Boolean.TRUE.equals(enableXmlType); + } + @Override public Properties getConnectionArgumentsProperties() { Properties prop = super.getConnectionArgumentsProperties(); diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java index a3560e969..1a9508382 100644 --- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java +++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleConstants.java @@ -47,6 +47,7 @@ private OracleConstants() { public static final String TREAT_AS_OLD_TIMESTAMP = "treatAsOldTimestamp"; public static final String TREAT_PRECISIONLESSNUM_AS_DECI = "treatPrecisionlessNumAsDeci"; public static final String TREAT_TIMESTAMP_LTZ_AS_TIMESTAMP = "treatTimestampLTZAsTimestamp"; + public static final String ENABLE_XML_TYPE = "enableXmlType"; /** * Constructs the Oracle connection string based on the provided connection type, host, port, and database. diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSource.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSource.java index 7cde9a8e9..5df47be12 100644 --- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSource.java +++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSource.java @@ -68,9 +68,10 @@ protected SchemaReader getSchemaReader() { boolean treatAsOldTimestamp = oracleSourceConfig.getConnection().getTreatAsOldTimestamp(); boolean treatPrecisionlessNumAsDeci = oracleSourceConfig.getConnection().getTreatPrecisionlessNumAsDeci(); boolean treatTimestampLTZAsTimestamp = oracleSourceConfig.getConnection().getTreatTimestampLTZAsTimestamp(); + boolean enableXmlType = oracleSourceConfig.getConnection().getXmlTypeEnabled(); return new OracleSourceSchemaReader(null, treatAsOldTimestamp, treatPrecisionlessNumAsDeci, - treatTimestampLTZAsTimestamp); + treatTimestampLTZAsTimestamp, enableXmlType); } @Override @@ -125,10 +126,12 @@ public OracleSourceConfig(String host, int port, String user, String password, S int defaultBatchValue, int defaultRowPrefetch, String importQuery, Integer numSplits, int fetchSize, String boundingQuery, String splitBy, Boolean useSSL, Boolean treatAsOldTimestamp, - Boolean treatPrecisionlessNumAsDeci, Boolean treatTimestampLTZAsTimestamp) { + Boolean treatPrecisionlessNumAsDeci, Boolean treatTimestampLTZAsTimestamp, + Boolean enableXmlType) { this.connection = new OracleConnectorConfig(host, port, user, password, jdbcPluginName, connectionArguments, connectionType, database, role, useSSL, treatAsOldTimestamp, - treatPrecisionlessNumAsDeci, treatTimestampLTZAsTimestamp); + treatPrecisionlessNumAsDeci, treatTimestampLTZAsTimestamp, + enableXmlType); this.defaultBatchValue = defaultBatchValue; this.defaultRowPrefetch = defaultRowPrefetch; this.fetchSize = fetchSize; diff --git a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java index fabac2e3a..b23dfa031 100644 --- a/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java +++ b/oracle-plugin/src/main/java/io/cdap/plugin/oracle/OracleSourceSchemaReader.java @@ -60,6 +60,7 @@ public class OracleSourceSchemaReader extends CommonSchemaReader { BINARY_DOUBLE, BFILE, LONG, + Types.SQLXML, LONG_RAW, Types.NUMERIC, Types.DECIMAL @@ -69,16 +70,19 @@ public class OracleSourceSchemaReader extends CommonSchemaReader { private final Boolean isTimestampOldBehavior; private final Boolean isPrecisionlessNumAsDecimal; private final Boolean isTimestampLtzFieldTimestamp; + private final Boolean isXmlTypeEnabled; public OracleSourceSchemaReader() { - this(null, false, false, false); + this(null, false, false, false, false); } public OracleSourceSchemaReader(@Nullable String sessionID, boolean isTimestampOldBehavior, - boolean isPrecisionlessNumAsDecimal, boolean isTimestampLtzFieldTimestamp) { + boolean isPrecisionlessNumAsDecimal, boolean isTimestampLtzFieldTimestamp, + boolean isXmlTypeEnabled) { this.sessionID = sessionID; this.isTimestampOldBehavior = isTimestampOldBehavior; this.isPrecisionlessNumAsDecimal = isPrecisionlessNumAsDecimal; this.isTimestampLtzFieldTimestamp = isTimestampLtzFieldTimestamp; + this.isXmlTypeEnabled = isXmlTypeEnabled; } @Override @@ -103,6 +107,9 @@ public Schema getSchema(ResultSetMetaData metadata, int index) throws SQLExcepti case INTERVAL_YM: case LONG: return Schema.of(Schema.Type.STRING); + case Types.SQLXML: + // Enabling XML type support for DTS connectors only as it is not in working state in CDAP plugin. + return isXmlTypeEnabled ? Schema.of(Schema.Type.STRING) : super.getSchema(metadata, index); case Types.NUMERIC: case Types.DECIMAL: // FLOAT and REAL are returned as java.sql.Types.NUMERIC but with value that is a java.lang.Double diff --git a/oracle-plugin/src/test/java/io/cdap/plugin/oracle/OracleSchemaReaderTest.java b/oracle-plugin/src/test/java/io/cdap/plugin/oracle/OracleSchemaReaderTest.java index 1ff77c533..6dac3c6dc 100644 --- a/oracle-plugin/src/test/java/io/cdap/plugin/oracle/OracleSchemaReaderTest.java +++ b/oracle-plugin/src/test/java/io/cdap/plugin/oracle/OracleSchemaReaderTest.java @@ -27,13 +27,14 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; +import java.sql.Types; import java.util.List; public class OracleSchemaReaderTest { @Test public void getSchema_timestampLTZFieldTrue_returnTimestamp() throws SQLException { - OracleSourceSchemaReader schemaReader = new OracleSourceSchemaReader(null, false, false, true); + OracleSourceSchemaReader schemaReader = new OracleSourceSchemaReader(null, false, false, true, false); ResultSet resultSet = Mockito.mock(ResultSet.class); ResultSetMetaData metadata = Mockito.mock(ResultSetMetaData.class); @@ -64,7 +65,7 @@ public void getSchema_timestampLTZFieldTrue_returnTimestamp() throws SQLExceptio @Test public void getSchema_timestampLTZFieldFalse_returnDatetime() throws SQLException { - OracleSourceSchemaReader schemaReader = new OracleSourceSchemaReader(null, false, false, false); + OracleSourceSchemaReader schemaReader = new OracleSourceSchemaReader(null, false, false, false, false); ResultSet resultSet = Mockito.mock(ResultSet.class); ResultSetMetaData metadata = Mockito.mock(ResultSetMetaData.class); @@ -91,4 +92,37 @@ public void getSchema_timestampLTZFieldFalse_returnDatetime() throws SQLExceptio Assert.assertEquals(expectedSchemaFields.get(1).getName(), actualSchemaFields.get(1).getName()); Assert.assertEquals(expectedSchemaFields.get(1).getSchema(), actualSchemaFields.get(1).getSchema()); } + + @Test + public void getSchema_xmlField_returnString() throws SQLException { + OracleSourceSchemaReader schemaReader = new OracleSourceSchemaReader(null, false, false, false, true); + ResultSet resultSet = Mockito.mock(ResultSet.class); + ResultSetMetaData metadata = Mockito.mock(ResultSetMetaData.class); + Mockito.when(resultSet.getMetaData()).thenReturn(metadata); + Mockito.when(metadata.getColumnCount()).thenReturn(1); + Mockito.when(metadata.getColumnType(1)).thenReturn(Types.SQLXML); + Mockito.when(metadata.getColumnName(1)).thenReturn("xmlData"); + + List actualSchemaFields = schemaReader.getSchemaFields(resultSet); + + List expectedSchemaFields = Lists.newArrayList(); + expectedSchemaFields.add(Schema.Field.of("xmlData", Schema.of(Schema.Type.STRING))); + Assert.assertEquals(expectedSchemaFields.get(0).getName(), actualSchemaFields.get(0).getName()); + Assert.assertEquals(expectedSchemaFields.get(0).getSchema(), actualSchemaFields.get(0).getSchema()); + } + + @Test + public void getSchema_xmlFieldDisabled_throwsSqlException() throws SQLException { + OracleSourceSchemaReader schemaReader = new OracleSourceSchemaReader(null, + false, false, false, false); + ResultSet resultSet = Mockito.mock(ResultSet.class); + ResultSetMetaData metadata = Mockito.mock(ResultSetMetaData.class); + Mockito.when(resultSet.getMetaData()).thenReturn(metadata); + Mockito.when(metadata.getColumnCount()).thenReturn(1); + Mockito.when(metadata.getColumnType(1)).thenReturn(Types.SQLXML); + Mockito.when(metadata.getColumnName(1)).thenReturn("xmlData"); + + Assert.assertThrows(SQLException.class, () -> schemaReader.getSchemaFields(resultSet)); + + } } diff --git a/oracle-plugin/widgets/Oracle-batchsource.json b/oracle-plugin/widgets/Oracle-batchsource.json index ab35f3e8c..dba149f4f 100644 --- a/oracle-plugin/widgets/Oracle-batchsource.json +++ b/oracle-plugin/widgets/Oracle-batchsource.json @@ -177,6 +177,25 @@ ] } }, + { + "widget-type": "hidden", + "label": "Enable Xml Type", + "name": "enableXmlType", + "widget-attributes": { + "layout": "inline", + "default": "false", + "options": [ + { + "id": "true", + "label": "true" + }, + { + "id": "false", + "label": "false" + } + ] + } + }, { "name": "connectionType", "label": "Connection Type", diff --git a/oracle-plugin/widgets/Oracle-connector.json b/oracle-plugin/widgets/Oracle-connector.json index 005c3ffbd..c68b95de0 100644 --- a/oracle-plugin/widgets/Oracle-connector.json +++ b/oracle-plugin/widgets/Oracle-connector.json @@ -186,6 +186,25 @@ } ] } + }, + { + "widget-type": "hidden", + "label": "Enable Xml Type", + "name": "enableXmlType", + "widget-attributes": { + "layout": "inline", + "default": "false", + "options": [ + { + "id": "true", + "label": "true" + }, + { + "id": "false", + "label": "false" + } + ] + } } ] }, diff --git a/pom.xml b/pom.xml index 8c3168d5a..db5f4366b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ io.cdap.plugin database-plugins-parent - 1.11.12 + 1.11.13-SNAPSHOT pom Database Plugins Collection of database plugins diff --git a/postgresql-plugin/pom.xml b/postgresql-plugin/pom.xml index 2fdf59d19..7d19c4163 100644 --- a/postgresql-plugin/pom.xml +++ b/postgresql-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT PostgreSQL plugin diff --git a/saphana-plugin/pom.xml b/saphana-plugin/pom.xml index 10709cf97..2ec2dd0d1 100644 --- a/saphana-plugin/pom.xml +++ b/saphana-plugin/pom.xml @@ -20,7 +20,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT SAP HANA plugin diff --git a/teradata-plugin/pom.xml b/teradata-plugin/pom.xml index 9dfe2ca6c..dfaa8276f 100644 --- a/teradata-plugin/pom.xml +++ b/teradata-plugin/pom.xml @@ -21,7 +21,7 @@ database-plugins-parent io.cdap.plugin - 1.11.12 + 1.11.13-SNAPSHOT teradata-plugin