Skip to content
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
2 changes: 1 addition & 1 deletion amazon-redshift-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Amazon Redshift plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion aurora-mysql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Aurora DB MySQL plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion aurora-postgresql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Aurora DB PostgreSQL plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion cloudsql-mysql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>CloudSQL MySQL plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion cloudsql-postgresql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>CloudSQL PostgreSQL plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion database-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Database Commons</name>
Expand Down
2 changes: 1 addition & 1 deletion db2-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>IBM DB2 plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion generic-database-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Generic database plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion generic-db-argument-setter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Generic database argument setter plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion mariadb-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Maria DB plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion memsql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Memsql plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion mssql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Microsoft SQL Server plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion mysql-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Mysql plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion netezza-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Netezza plugin</name>
Expand Down
2 changes: 1 addition & 1 deletion oracle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>database-plugins-parent</artifactId>
<groupId>io.cdap.plugin</groupId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
</parent>

<name>Oracle plugin</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class OracleSourceSchemaReader extends CommonSchemaReader {
BINARY_DOUBLE,
BFILE,
LONG,
Types.SQLXML,
LONG_RAW,
Types.NUMERIC,
Types.DECIMAL
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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<Schema.Field> actualSchemaFields = schemaReader.getSchemaFields(resultSet);

List<Schema.Field> 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));

}
}
19 changes: 19 additions & 0 deletions oracle-plugin/widgets/Oracle-batchsource.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 19 additions & 0 deletions oracle-plugin/widgets/Oracle-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<groupId>io.cdap.plugin</groupId>
<artifactId>database-plugins-parent</artifactId>
<version>1.11.12</version>
<version>1.11.13-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Database Plugins</name>
<description>Collection of database plugins</description>
Expand Down
Loading
Loading