From 99479c126e3c405f107c3414689460e6447daeba Mon Sep 17 00:00:00 2001 From: Sebastian Nehls Date: Tue, 7 May 2019 07:00:10 +0200 Subject: [PATCH] #150: enabled join pushdown for oracle --- .../dialects/oracle/OracleSqlDialect.java | 3 ++- .../dialects/oracle/OracleSqlDialectIT.java | 21 +++++++++++++++++++ .../dialects/oracle/OracleSqlDialectTest.java | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/jdbc-adapter/virtualschema-jdbc-adapter/src/main/java/com/exasol/adapter/dialects/oracle/OracleSqlDialect.java b/jdbc-adapter/virtualschema-jdbc-adapter/src/main/java/com/exasol/adapter/dialects/oracle/OracleSqlDialect.java index f68d49878..cbaa58490 100644 --- a/jdbc-adapter/virtualschema-jdbc-adapter/src/main/java/com/exasol/adapter/dialects/oracle/OracleSqlDialect.java +++ b/jdbc-adapter/virtualschema-jdbc-adapter/src/main/java/com/exasol/adapter/dialects/oracle/OracleSqlDialect.java @@ -51,7 +51,8 @@ public Capabilities getCapabilities() { final Capabilities.Builder builder = Capabilities.builder(); builder.addMain(SELECTLIST_PROJECTION, SELECTLIST_EXPRESSIONS, FILTER_EXPRESSIONS, AGGREGATE_SINGLE_GROUP, AGGREGATE_GROUP_BY_COLUMN, AGGREGATE_GROUP_BY_EXPRESSION, AGGREGATE_GROUP_BY_TUPLE, AGGREGATE_HAVING, - ORDER_BY_COLUMN, ORDER_BY_EXPRESSION, LIMIT, LIMIT_WITH_OFFSET); + ORDER_BY_COLUMN, ORDER_BY_EXPRESSION, LIMIT, LIMIT_WITH_OFFSET, + JOIN, JOIN_TYPE_INNER, JOIN_TYPE_LEFT_OUTER, JOIN_TYPE_RIGHT_OUTER, JOIN_TYPE_FULL_OUTER, JOIN_CONDITION_EQUI); builder.addPredicate(AND, OR, NOT, EQUAL, NOTEQUAL, LESS, LESSEQUAL, LIKE, LIKE_ESCAPE, REGEXP_LIKE, BETWEEN, IN_CONSTLIST, IS_NULL, IS_NOT_NULL); builder.addLiteral(NULL, DATE, TIMESTAMP, TIMESTAMP_UTC, DOUBLE, EXACTNUMERIC, STRING, INTERVAL); diff --git a/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectIT.java b/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectIT.java index 52cc0344d..74dc17e4a 100644 --- a/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectIT.java +++ b/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectIT.java @@ -348,6 +348,27 @@ void fullOuterJoin() throws SQLException { assertFalse(result.next()); } + @Test + void rightJoinWithComplexCondition() throws SQLException { + final String query = String.format( + "SELECT * FROM %1$s.t1 a RIGHT OUTER JOIN %1$s.t2 b ON a.x||a.y=b.x||b.y ORDER BY a.x", VIRTUAL_SCHEMA_JDBC); + final ResultSet result = executeQuery(query); + matchNextRow(result, "2", "bbb", "2", "bbb"); + matchNextRow(result, null, null, "3", "ccc"); + assertFalse(result.next()); + } + + @Test + void fullOuterJoinWithComplexCondition() throws SQLException { + final String query = String.format( + "SELECT * FROM %1$s.t1 a FULL OUTER JOIN %1$s.t2 b ON a.x-b.x=0 ORDER BY a.x", VIRTUAL_SCHEMA_ORA); + final ResultSet result = executeQuery(query); + matchNextRow(result, "1", "aaa", null, null); + matchNextRow(result, "2", "bbb", "2", "bbb"); + matchNextRow(result, null, null, "3", "ccc"); + assertFalse(result.next()); + } + // Type Tests ------------------------------------------------------------- @Test void testColumnTypeEquivalence() throws SQLException { diff --git a/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectTest.java b/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectTest.java index 9d61bf119..eb9027b7a 100644 --- a/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectTest.java +++ b/jdbc-adapter/virtualschema-jdbc-adapter/src/test/java/com/exasol/adapter/dialects/oracle/OracleSqlDialectTest.java @@ -56,7 +56,8 @@ void testGetCapabilities() { containsInAnyOrder(SELECTLIST_PROJECTION, SELECTLIST_EXPRESSIONS, FILTER_EXPRESSIONS, AGGREGATE_SINGLE_GROUP, AGGREGATE_GROUP_BY_COLUMN, AGGREGATE_GROUP_BY_EXPRESSION, AGGREGATE_GROUP_BY_TUPLE, AGGREGATE_HAVING, ORDER_BY_COLUMN, ORDER_BY_EXPRESSION, LIMIT, - LIMIT_WITH_OFFSET)), // + LIMIT_WITH_OFFSET, JOIN, JOIN_TYPE_INNER, JOIN_TYPE_LEFT_OUTER, JOIN_TYPE_RIGHT_OUTER, + JOIN_TYPE_FULL_OUTER, JOIN_CONDITION_EQUI)), // () -> assertThat(capabilities.getLiteralCapabilities(), containsInAnyOrder(NULL, DATE, TIMESTAMP, TIMESTAMP_UTC, DOUBLE, EXACTNUMERIC, STRING, INTERVAL)),