You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ni...@apache.org on 2019/05/08 01:53:14 UTC

[kylin] branch master updated (ab124ac -> 8957a03)

This is an automated email from the ASF dual-hosted git repository.

nic pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git.


    from ab124ac  KYLIN-3926 Code review
     new a0ed26d  KYLIN-3812 optimize the child CompareTupleFilter in a CompareTupleFilter
     new 7bfa5d1  KYLIN-3813 don't do push down when both of the children of CompareTupleFilter are CompareTupleFilter with column included
     new 8957a03  KYLIN-3812, add it query test case

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../metadata/expression/CaseTupleExpression.java   |  3 ++-
 .../kylin/metadata/filter/CompareTupleFilter.java  | 22 +++++++++++++++++++++-
 .../query01.sql => sql_casewhen/query04.sql}       | 18 ++++++++++++++++--
 .../kylin/query/relnode/OLAPAggregateRel.java      |  2 +-
 4 files changed, 40 insertions(+), 5 deletions(-)
 copy kylin-it/src/test/resources/query/{sql_dict_enumerator/query01.sql => sql_casewhen/query04.sql} (52%)


[kylin] 01/03: KYLIN-3812 optimize the child CompareTupleFilter in a CompareTupleFilter

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit a0ed26d1a733912db49775e4d5cf405a3e0bb3ae
Author: kyotoYaho <nj...@apache.org>
AuthorDate: Mon Mar 18 14:55:38 2019 +0800

    KYLIN-3812 optimize the child CompareTupleFilter in a CompareTupleFilter
---
 .../apache/kylin/metadata/filter/CompareTupleFilter.java  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
index 1c1c409..1d0c7c3 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
@@ -74,6 +74,9 @@ public class CompareTupleFilter extends TupleFilter implements IOptimizeableTupl
 
     @Override
     public void addChild(TupleFilter child) {
+        if (child instanceof CompareTupleFilter) {
+            child = optimizeChildCompareTupleFilter((CompareTupleFilter) child);
+        }
         super.addChild(child);
         if (child instanceof ColumnTupleFilter) {
             ColumnTupleFilter columnFilter = (ColumnTupleFilter) child;
@@ -283,6 +286,18 @@ public class CompareTupleFilter extends TupleFilter implements IOptimizeableTupl
         return transformer.visit(this);
     }
 
+    private TupleFilter optimizeChildCompareTupleFilter(CompareTupleFilter child) {
+        FilterOptimizeTransformer transformer = new FilterOptimizeTransformer();
+        TupleFilter result = child.acceptOptimizeTransformer(transformer);
+        if (result == ConstantTupleFilter.TRUE) {
+            // use string instead of boolean since it's encoded as string
+            result = new ConstantTupleFilter("true");
+        } else if (result == ConstantTupleFilter.FALSE) {
+            result = new ConstantTupleFilter("false");
+        }
+        return result;
+    }
+
     @Override
     public boolean equals(Object o) {
         if (this == o)


[kylin] 02/03: KYLIN-3813 don't do push down when both of the children of CompareTupleFilter are CompareTupleFilter with column included

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit 7bfa5d136fdb8cdba5cc714213e3ef4fa4f1ed62
Author: kyotoYaho <nj...@apache.org>
AuthorDate: Tue Mar 19 09:57:09 2019 +0800

    KYLIN-3813 don't do push down when both of the children of CompareTupleFilter are CompareTupleFilter with column included
---
 .../org/apache/kylin/metadata/expression/CaseTupleExpression.java  | 3 ++-
 .../java/org/apache/kylin/metadata/filter/CompareTupleFilter.java  | 7 ++++++-
 .../main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/expression/CaseTupleExpression.java b/core-metadata/src/main/java/org/apache/kylin/metadata/expression/CaseTupleExpression.java
index 6b9034b..a6122e5 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/expression/CaseTupleExpression.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/expression/CaseTupleExpression.java
@@ -47,7 +47,8 @@ public class CaseTupleExpression extends TupleExpression {
     protected boolean ifAbleToPushDown() {
         if (ifAbleToPushDown == null) {
             for (Pair<TupleFilter, TupleExpression> whenEntry : whenList) {
-                ifAbleToPushDown = whenEntry.getSecond().ifAbleToPushDown();
+                ifAbleToPushDown = TupleFilter.isEvaluableRecursively(whenEntry.getFirst())
+                        && whenEntry.getSecond().ifAbleToPushDown();
                 if (!ifAbleToPushDown) {
                     break;
                 }
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
index 1d0c7c3..6ae478f 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
@@ -38,6 +38,9 @@ public class CompareTupleFilter extends TupleFilter implements IOptimizeableTupl
         AlwaysTrue, AlwaysFalse, Unknown
     }
 
+    // if the two children are both CompareTupleFilter, isNormal will be false
+    private boolean isNormal = true;
+
     // operand 1 is either a column or a function
     private TblColRef column;
     private FunctionTupleFilter function;
@@ -237,7 +240,7 @@ public class CompareTupleFilter extends TupleFilter implements IOptimizeableTupl
 
     @Override
     public boolean isEvaluable() {
-        return (column != null || (function != null && function.isEvaluable())) //
+        return isNormal && (column != null || (function != null && function.isEvaluable())) //
                 && (!conditionValues.isEmpty() || operator == FilterOperatorEnum.ISNOTNULL || operator == FilterOperatorEnum.ISNULL) //
                 && secondColumn == null;
     }
@@ -294,6 +297,8 @@ public class CompareTupleFilter extends TupleFilter implements IOptimizeableTupl
             result = new ConstantTupleFilter("true");
         } else if (result == ConstantTupleFilter.FALSE) {
             result = new ConstantTupleFilter("false");
+        } else {
+            this.isNormal = false;
         }
         return result;
     }
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
index a6a43b9..9def697 100755
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPAggregateRel.java
@@ -278,7 +278,7 @@ public class OLAPAggregateRel extends Aggregate implements OLAPRel {
             TblColRef groupOutCol = inputColumnRowType.getColumnByIndex(i);
             if (tupleExpression instanceof ColumnTupleExpression) {
                 this.groups.add(((ColumnTupleExpression) tupleExpression).getColumn());
-            } else if (this.context.isDynamicColumnEnabled()) {
+            } else if (this.context.isDynamicColumnEnabled() && tupleExpression.ifForDynamicColumn()) {
                 Pair<Set<TblColRef>, Set<TblColRef>> cols = ExpressionColCollector.collectColumnsPair(tupleExpression);
 
                 // push down only available for the innermost aggregation


[kylin] 03/03: KYLIN-3812, add it query test case

Posted by ni...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit 8957a03006059b815eb57a905b71f51da7661479
Author: nichunen <ni...@apache.org>
AuthorDate: Tue May 7 16:53:28 2019 +0800

    KYLIN-3812, add it query test case
---
 .../test/resources/query/sql_casewhen/query04.sql  | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/kylin-it/src/test/resources/query/sql_casewhen/query04.sql b/kylin-it/src/test/resources/query/sql_casewhen/query04.sql
new file mode 100644
index 0000000..6ea8d51
--- /dev/null
+++ b/kylin-it/src/test/resources/query/sql_casewhen/query04.sql
@@ -0,0 +1,35 @@
+--
+-- 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 "TEST_KYLIN_FACT"."ORDER_ID",
+       case
+           when ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME"='Auction') = (1 = 1) then 'B'
+           when ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME"='FP-GTC') = (1 = 1) then 'C'
+           when ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME"='ABIN') = (1 = 1) then 'D'
+           else 'N'
+       end as phase
+from TEST_KYLIN_FACT
+where "TEST_KYLIN_FACT"."CAL_DT" between '2013-01-01' and '2013-01-02'
+group by "TEST_KYLIN_FACT"."ORDER_ID",
+       case
+           when ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME"='Auction') = (1 = 1) then 'B'
+           when ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME"='FP-GTC') = (1 = 1) then 'C'
+           when ("TEST_KYLIN_FACT"."LSTG_FORMAT_NAME"='ABIN') = (1 = 1) then 'D'
+           else 'N'
+       end
+