You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2016/07/25 12:12:34 UTC

[02/50] [abbrv] kylin git commit: KYLIN 1792 it fixed when join contains subquery, kylin will return no results.

KYLIN 1792 it fixed when join contains subquery, kylin will return no results.


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

Branch: refs/heads/1.5.x-HBase1.x
Commit: 6f6d7790532668a5d30c2f5ad4e2c3062353ea87
Parents: bac0aa1
Author: Cheng Wang <ch...@kyligence.io>
Authored: Tue Jul 5 10:16:20 2016 +0800
Committer: Li Yang <li...@apache.org>
Committed: Tue Jul 5 10:44:37 2016 +0800

----------------------------------------------------------------------
 .../org/apache/kylin/query/relnode/OLAPJoinRel.java  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/6f6d7790/query/src/main/java/org/apache/kylin/query/relnode/OLAPJoinRel.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPJoinRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPJoinRel.java
index dc16dad..f66351b 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPJoinRel.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPJoinRel.java
@@ -117,11 +117,14 @@ public class OLAPJoinRel extends EnumerableJoin implements OLAPRel {
         this.isTopJoin = !this.context.hasJoin;
         this.context.hasJoin = true;
 
+        int nJoinPossibility = 0;
+
         // as we keep the first table as fact table, we need to visit from left to right
         implementor.visitChild(this.left, this);
         if (this.context != implementor.getContext() || ((OLAPRel) this.left).hasSubQuery()) {
             this.hasSubQuery = true;
             // if child is also an OLAPJoin, then the context has already been popped
+            nJoinPossibility--;
             if (this.context != implementor.getContext()) {
                 implementor.freeContext();
             }
@@ -129,6 +132,7 @@ public class OLAPJoinRel extends EnumerableJoin implements OLAPRel {
         implementor.visitChild(this.right, this);
         if (this.context != implementor.getContext() || ((OLAPRel) this.right).hasSubQuery()) {
             this.hasSubQuery = true;
+            nJoinPossibility++;
             // if child is also an OLAPJoin, then the context has already been popped
             if (this.context != implementor.getContext()) {
                 implementor.freeContext();
@@ -136,6 +140,7 @@ public class OLAPJoinRel extends EnumerableJoin implements OLAPRel {
         }
 
         this.columnRowType = buildColumnRowType();
+
         if (isTopJoin) {
             this.context.afterJoin = true;
         }
@@ -152,6 +157,16 @@ public class OLAPJoinRel extends EnumerableJoin implements OLAPRel {
             join.setType(joinType);
 
             this.context.joins.add(join);
+        } else if (0 != nJoinPossibility) {
+            //When join contains subquery, the join-condition fields of fact_table will add into context.
+            Map<TblColRef, TblColRef> joinCol = new HashMap<TblColRef, TblColRef>();
+            translateJoinColumn((RexCall) this.getCondition(), joinCol);
+
+            for (Map.Entry<TblColRef, TblColRef> columnPair : joinCol.entrySet()) {
+                TblColRef fromCol = (-1 == nJoinPossibility ? columnPair.getValue() : columnPair.getKey());
+                this.context.groupByColumns.add(fromCol);
+            }
+            joinCol.clear();
         }
     }