Skip to content

Commit

Permalink
Merge branch 'kaklakariada/issue34' of https://github.com/exasol/orac…
Browse files Browse the repository at this point in the history
…le-virtual-schema into kaklakariada/issue34
  • Loading branch information
kaklakariada committed Oct 5, 2023
2 parents 810fb6d + 298bbe5 commit b0aeecc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/changes/changes_2.4.2.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Virtual Schema for Oracle 2.4.2, released 2023-10-04
# Virtual Schema for Oracle 2.4.2, released 2023-10-05

Code name: Fix CVE-2023-42503 in test dependency

Expand Down
4 changes: 3 additions & 1 deletion doc/user_guide/oracle_user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ In the following matrix you find combinations of JDBC driver and dialect version

| Virtual Schema Version | Oracle Version | Driver Name | Driver Version |
|------------------------|--------------------|---------------------------|----------------|
| 2.0.0 | Oracle XE 11g | ojdbc | 8 |
| 2.0.0 | Oracle XE 11g | ojdbc8 | 19.3.0.0 |
| 2.0.0 | Oracle XE 11g | instantclient-basic-linux | x64-12.1.0.2.0 |
| 2.4.2 | Oracle XE 21c | ojdbc8 | 23.3.0.23.09 |
| 2.4.2 | Oracle XE 21c | instantclient-basic-linux | x64-12.1.0.2.0 |

3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>23.3.0.23.09</version>
<!-- This must be in compile scope to avoid the following error when creating the virtual schema:
"java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@172.17.0.1:32805/xepdb1" -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.exasol</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public final class IntegrationTestConstants {
public static final String VIRTUAL_SCHEMAS_JAR_NAME_AND_VERSION = "virtual-schema-dist-11.0.2-oracle-2.4.2.jar";
public static final String ORACLE_CONTAINER_NAME = "gvenzl/oracle-xe:18.4.0";
public static final String ORACLE_CONTAINER_NAME = "gvenzl/oracle-xe:21.3.0";
public static final String SCHEMA_EXASOL = "SCHEMA_EXASOL";
public static final String TABLE_JOIN_1 = "TABLE_JOIN_1";
public static final String TABLE_JOIN_2 = "TABLE_JOIN_2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static com.exasol.adapter.dialects.oracle.OracleVirtualSchemaIntegrationTestSetup.createAdapterScript;
import static com.exasol.adapter.dialects.oracle.OracleVirtualSchemaIntegrationTestSetup.uploadOracleJDBCDriverAndVSToBucket;
import static com.exasol.matcher.ResultSetMatcher.matchesResultSet;
import static com.exasol.matcher.ResultSetStructureMatcher.table;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -57,7 +58,7 @@ class OracleSqlDialectIT {
private static final String TABLE_ORACLE_TIMESTAMPS = "TABLE_ORACLE_TIMESTAMPS";

@Container
private static final ExasolContainer<? extends ExasolContainer<?>> exasolContainer = new ExasolContainer<>("7.0.10") //
private static final ExasolContainer<? extends ExasolContainer<?>> exasolContainer = new ExasolContainer<>() //
.withRequiredServices(ExasolService.BUCKETFS, ExasolService.UDF).withReuse(true);
@Container
private static final OracleContainerDBA oracleContainer = new OracleContainerDBA(ORACLE_CONTAINER_NAME);
Expand Down Expand Up @@ -328,9 +329,7 @@ private Connection getExasolConnection() throws SQLException {
void testCountAll() throws SQLException {
final String qualifiedTableName = VIRTUAL_SCHEMA_JDBC + "." + TABLE_ORACLE_NUMBER_HANDLING;
final String query = "SELECT COUNT(*) FROM " + qualifiedTableName;
final ResultSet expected = getExpectedResultSet(List.of("x DECIMAL(36,0)"), //
List.of("1"));
assertThat(getActualResultSet(query), matchesResultSet(expected));
assertThat(getActualResultSet(query), table("BIGINT").row(1L).matches());
}

@Nested
Expand Down Expand Up @@ -617,16 +616,17 @@ void testAggregateSingleGroup(final String virtualSchemaName, final String expec
void testAggregateGroupByColumnJdbc() throws SQLException {
final String qualifiedActualTableName = VIRTUAL_SCHEMA_JDBC + "." + TABLE_ORACLE_ALL_DATA_TYPES;
final String query = "SELECT C5, min(C7) FROM " + qualifiedActualTableName + " GROUP BY C5 ORDER BY 1 DESC";
final ResultSet expected = getExpectedResultSet("(A VARCHAR(100), B VARCHAR(100))",
"('123456789012345678901234567890123456', '12345.12345')," //
+ "('1234567890.123456789', '12355.12345')");
final ResultSet actual = statementExasol.executeQuery(query);
final String expectedExplainVirtual = "SELECT TO_CHAR(\"" + TABLE_ORACLE_ALL_DATA_TYPES
+ "\".\"C5\"), CAST(MIN(\"" + TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C7\") AS FLOAT) FROM \""
+ SCHEMA_ORACLE + "\".\"" + TABLE_ORACLE_ALL_DATA_TYPES + "\" GROUP BY \""
+ TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C5\" ORDER BY \"" + TABLE_ORACLE_ALL_DATA_TYPES
+ "\".\"C5\" DESC";
assertAll(() -> assertThat(actual, matchesResultSet(expected)),
assertAll(
() -> assertThat(actual,
table("VARCHAR", "DECIMAL")
.row("123456789012345678901234567890123456", new BigDecimal("12345.12345"))
.row("1234567890.123456789", new BigDecimal("12355.12345")).matches()),
() -> assertExplainVirtual(query, expectedExplainVirtual));
}

Expand All @@ -653,17 +653,19 @@ void testAggregateGroupByTuple() throws SQLException {
final String qualifiedActualTableName = VIRTUAL_SCHEMA_JDBC + "." + TABLE_ORACLE_ALL_DATA_TYPES;
final String query = "SELECT C_NUMBER36, C5, min(C7) FROM " + qualifiedActualTableName
+ " GROUP BY C_NUMBER36, C5 ORDER BY C5 DESC";
final ResultSet expected = getExpectedResultSet("(A DECIMAL(36,0), B VARCHAR(100), C VARCHAR(100))",
"(123456789012345678901234567890123456, '123456789012345678901234567890123456', '12345.12345')," //
+ "(null, '1234567890.123456789', '12355.12345')");
final ResultSet actual = statementExasol.executeQuery(query);
final String expectedExplainVirtual = "SELECT \"" + TABLE_ORACLE_ALL_DATA_TYPES
+ "\".\"C_NUMBER36\", TO_CHAR(\"" + TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C5\"), CAST(MIN(\""
+ TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C7\") AS FLOAT) FROM \"" + SCHEMA_ORACLE + "\".\""
+ TABLE_ORACLE_ALL_DATA_TYPES + "\" GROUP BY \"" + TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C5\", \""
+ TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C_NUMBER36\" ORDER BY \"" + TABLE_ORACLE_ALL_DATA_TYPES
+ "\".\"C5\" DESC";
assertAll(() -> assertThat(actual, matchesResultSet(expected)),
assertAll(
() -> assertThat(actual,
table("DECIMAL", "VARCHAR", "DECIMAL")
.row(new BigDecimal("123456789012345678901234567890123456"),
"123456789012345678901234567890123456", new BigDecimal("12345.12345"))
.row(null, "1234567890.123456789", new BigDecimal("12355.12345")).matches()),
() -> assertExplainVirtual(query, expectedExplainVirtual));
}

Expand All @@ -672,15 +674,15 @@ void testAggregateHaving() throws SQLException {
final String qualifiedActualTableName = VIRTUAL_SCHEMA_JDBC + "." + TABLE_ORACLE_ALL_DATA_TYPES;
final String query = "SELECT C5, min(C7) FROM " + qualifiedActualTableName
+ " GROUP BY C5 HAVING MIN(C7) > 12350";
final ResultSet expected = getExpectedResultSet("(A VARCHAR(100), B VARCHAR(100))",
"('1234567890.123456789', '12355.12345')");
final ResultSet actual = statementExasol.executeQuery(query);
final String expectedExplainVirtual = "SELECT TO_CHAR(\"" + TABLE_ORACLE_ALL_DATA_TYPES
+ "\".\"C5\"), CAST(MIN(\"" + TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C7\") AS FLOAT) FROM \""
+ SCHEMA_ORACLE + "\".\"" + TABLE_ORACLE_ALL_DATA_TYPES + "\" GROUP BY \""
+ TABLE_ORACLE_ALL_DATA_TYPES + "\".\"C5\" HAVING 12350 < MIN(\"" + TABLE_ORACLE_ALL_DATA_TYPES
+ "\".\"C7\")";
assertAll(() -> assertThat(actual, matchesResultSet(expected)),
assertAll(
() -> assertThat(actual, table("VARCHAR", "DECIMAL")
.row("1234567890.123456789", new BigDecimal("12355.12345")).matches()),
() -> assertExplainVirtual(query, expectedExplainVirtual));
}

Expand Down
1 change: 1 addition & 0 deletions src/test/resources/integration/driver/oracle/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ DRIVERMAIN=oracle.jdbc.OracleDriver
PREFIX=jdbc:oracle:thin:
FETCHSIZE=100000
INSERTSIZE=-1
NOSECURITY=YES

0 comments on commit b0aeecc

Please sign in to comment.