calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [03/11] calcite git commit: [CALCITE-1954] Column from outer join should be null, whether or not it is aliased
Date Thu, 24 Aug 2017 19:05:17 GMT
[CALCITE-1954] Column from outer join should be null, whether or not it is aliased

Close apache/calcite#522


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/22e5cfc0
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/22e5cfc0
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/22e5cfc0

Branch: refs/heads/master
Commit: 22e5cfc0d0cf05fab398e3d5aa49209d5e1424ca
Parents: f6825f0
Author: Minji Kim <minji@dremio.com>
Authored: Sat Jan 14 22:43:08 2017 -0800
Committer: Julian Hyde <jhyde@apache.org>
Committed: Wed Aug 23 11:20:35 2017 -0700

----------------------------------------------------------------------
 .../calcite/sql/validate/SqlValidatorImpl.java  |  2 +-
 .../apache/calcite/test/SqlValidatorTest.java   | 30 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/22e5cfc0/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index 9712a25..3d76bb4 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -2003,7 +2003,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
             usingScope,
             alias,
             new AliasNamespace(this, call, enclosingNode),
-            false);
+            forceNullable);
       }
       return node;
     case MATCH_RECOGNIZE:

http://git-wip-us.apache.org/repos/asf/calcite/blob/22e5cfc0/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index b30c5bb..8d0ed48 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -4127,6 +4127,36 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
             "RANK or DENSE_RANK functions require ORDER BY clause in window specification");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-1954">[CALCITE-1954]
+   * Column from outer join should be null, whether or not it is aliased</a>. */
+  @Test public void testLeftOuterJoinWithAlias() {
+    final String query = "select *\n"
+        + "from (select row_number() over (order by sal) from emp) as emp1(r1)\n"
+        + "left outer join\n"
+        + "(select  dense_rank() over(order by sal) from emp) as emp2(r2)\n"
+        + "on (emp1.r1 = emp2.r2)";
+    // In this case, R2 is nullable in the join since we have a left outer join.
+    final String type = "RecordType(BIGINT NOT NULL R1, BIGINT R2) NOT NULL";
+    sql(query).type(type);
+
+    // Similar query, without "AS t(c)"
+    final String query2 = "select *\n"
+        + "from (select row_number() over (order by sal) as r1 from emp) as emp1\n"
+        + "left outer join\n"
+        + "(select dense_rank() over(order by sal) as r2 from emp) as emp2\n"
+        + "on (emp1.r1 = emp2.r2)";
+    sql(query2).type(type);
+
+    // Similar query, without "AS t"
+    final String query3 = "select *\n"
+        + "from (select row_number() over (order by sal) as r1 from emp)\n"
+        + "left outer join\n"
+        + "(select dense_rank() over(order by sal) as r2 from emp)\n"
+        + "on r1 = r2";
+    sql(query3).type(type);
+  }
+
   @Test public void testInvalidWindowFunctionWithGroupBy() {
     sql("select max(^empno^) over () from emp\n"
         + "group by deptno")


Mime
View raw message