KYLIN-2599 select * in subquery fail due to bug in hackSelectStar

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

Branch: refs/heads/master
Commit: c3d81832f796ab281526d3ac1cd97b11eb986a92
Parents: 9dc6553
Author: Hongbin Ma <mahong...@apache.org>
Authored: Tue May 9 21:42:47 2017 +0800
Committer: liyang-gmt8 <liy...@apache.org>
Committed: Wed May 10 09:41:40 2017 +0800

----------------------------------------------------------------------
 .../calcite/sql2rel/SqlToRelConverter.java      | 11 +++++++++
 .../src/test/resources/query/sql/query105.sql   | 26 ++++++++++++++++++++
 2 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/c3d81832/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 c199c31..a520aa6 100644
--- 
a/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ 
b/atopcalcite/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -47,6 +47,7 @@ import org.apache.calcite.rel.core.Project;
 import org.apache.calcite.rel.core.RelFactories;
 import org.apache.calcite.rel.core.Sample;
 import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.TableScan;
 import org.apache.calcite.rel.core.Uncollect;
 import org.apache.calcite.rel.logical.LogicalAggregate;
 import org.apache.calcite.rel.logical.LogicalCorrelate;
@@ -611,6 +612,16 @@ public class SqlToRelConverter {
         } else {
             return root;
         }
+
+        RelNode tableScanOrJoin = null;
+        RelNode rootProjInput = rootPrj.getInput(0) instanceof LogicalFilter ? 
rootPrj.getInput(0).getInput(0): rootPrj.getInput(0);
+        if(rootProjInput instanceof TableScan || rootProjInput instanceof 
LogicalJoin) { 
+            tableScanOrJoin = rootProjInput;
+        }
+        if(tableScanOrJoin == null) {
+            return root;
+        }
+        
         //
         RelNode input = rootPrj.getInput();
         //        if (!(//

http://git-wip-us.apache.org/repos/asf/kylin/blob/c3d81832/kylin-it/src/test/resources/query/sql/query105.sql
----------------------------------------------------------------------
diff --git a/kylin-it/src/test/resources/query/sql/query105.sql 
b/kylin-it/src/test/resources/query/sql/query105.sql
new file mode 100644
index 0000000..a467b65
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql/query105.sql
@@ -0,0 +1,26 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+select fact.lstg_format_name from 
+ 
+ (select * from test_kylin_fact where cal_dt > date'2010-01-01' ) as fact
+ 
+ group by fact.lstg_format_name 
+ 
+ order by CASE WHEN fact.lstg_format_name IS NULL THEN 'sdf' ELSE 
fact.lstg_format_name END 
+ 

Reply via email to