Repository: kylin
Updated Branches:
  refs/heads/yang22 7564274c3 -> cdb33ca8a


KYLIN-2456 fix select * from .. join ..


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

Branch: refs/heads/yang22
Commit: cdb33ca8ab4852adb664d3b574bb210d18b2f93c
Parents: 7564274
Author: Li Yang <liy...@apache.org>
Authored: Tue Feb 21 16:13:35 2017 +0800
Committer: Li Yang <liy...@apache.org>
Committed: Tue Feb 21 16:13:35 2017 +0800

----------------------------------------------------------------------
 .../apache/calcite/sql2rel/SqlToRelConverter.java    | 15 ++++++++++++---
 .../org/apache/kylin/query/ITKylinQueryTest.java     |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/cdb33ca8/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
----------------------------------------------------------------------
diff --git 
a/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java 
b/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index c70cd20..927bc82 100644
--- 
a/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ 
b/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -602,7 +602,7 @@ public class SqlToRelConverter {
          *   LogicalSort (optional)
          *    |- LogicalProject
          *        |- LogicalFilter (optional)
-         *            |- OLAPTableScan
+         *            |- OLAPTableScan or LogicalJoin
          */
         LogicalProject rootPrj = null;
         LogicalSort rootSort = null;
@@ -617,8 +617,8 @@ public class SqlToRelConverter {
 
         RelNode input = rootPrj.getInput();
         if (!(//
-                input.getClass().getSimpleName().equals("OLAPTableScan")//
-                        || 
(input.getClass().getSimpleName().equals("LogicalFilter") && 
input.getInput(0).getClass().getSimpleName().equals("OLAPTableScan"))//
+                isAmong(input, "OLAPTableScan", "LogicalJoin")//
+                || (isAmong(input, "LogicalFilter") && 
isAmong(input.getInput(0), "OLAPTableScan", "LogicalJoin"))//
         ))
             return root;
 
@@ -654,6 +654,15 @@ public class SqlToRelConverter {
         return root;
     }
 
+    private boolean isAmong(RelNode rel, String... names) {
+        String simpleName = rel.getClass().getSimpleName();
+        for (String n : names) {
+            if (simpleName.equals(n))
+                return true;
+        }
+        return false;
+    }
+
     private static boolean isStream(SqlNode query) {
         return query instanceof SqlSelect
                 && ((SqlSelect) 
query).isKeywordPresent(SqlSelectKeyword.STREAM);

http://git-wip-us.apache.org/repos/asf/kylin/blob/cdb33ca8/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
----------------------------------------------------------------------
diff --git 
a/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java 
b/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
index 98b294d..6f1c629 100644
--- a/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
+++ b/kylin-it/src/test/java/org/apache/kylin/query/ITKylinQueryTest.java
@@ -394,5 +394,6 @@ public class ITKylinQueryTest extends KylinTestBase {
     public void testSelectStarColumnCount() throws Exception {
         execAndCompColumnCount("select * from test_kylin_fact limit 10", 9);
         execAndCompColumnCount("select * from test_kylin_fact", 9);
+        execAndCompColumnCount("select * from     test_kylin_fact left join 
edw.test_cal_dt on test_kylin_fact.cal_dt = edw.test_cal_dt.CAL_DT    limit 
10", 11);
     }
 }

Reply via email to