You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/02/21 12:52:09 UTC
[14/52] [abbrv] kylin git commit: KYLIN-1372 Query using
PrepareStatement failed with multi OR clause
KYLIN-1372 Query using PrepareStatement failed with multi OR clause
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/0c13797e
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/0c13797e
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/0c13797e
Branch: refs/heads/1.x-HBase1.1.3
Commit: 0c13797e11984ba0411f0c0e3c42540a822e847a
Parents: d697447
Author: sunyerui <su...@gmail.com>
Authored: Tue Jan 26 21:57:21 2016 +0800
Committer: sunyerui <su...@gmail.com>
Committed: Fri Jan 29 11:56:13 2016 +0800
----------------------------------------------------------------------
.../metadata/filter/CompareTupleFilter.java | 4 ++-
.../kylin/query/relnode/OLAPFilterRel.java | 3 +++
.../resources/query/sql_dynamic/query03.dat | 2 ++
.../resources/query/sql_dynamic/query03.sql | 26 ++++++++++++++++++++
4 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/0c13797e/metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
----------------------------------------------------------------------
diff --git a/metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java b/metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
index 73fd0fb..b9db9c4 100644
--- a/metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
+++ b/metadata/src/main/java/org/apache/kylin/metadata/filter/CompareTupleFilter.java
@@ -81,7 +81,9 @@ public class CompareTupleFilter extends TupleFilter {
}
} else if (child instanceof ConstantTupleFilter) {
this.conditionValues.addAll(child.getValues());
- this.firstCondValue = this.conditionValues.iterator().next();
+ if (!this.conditionValues.isEmpty()) {
+ this.firstCondValue = this.conditionValues.iterator().next();
+ }
} else if (child instanceof DynamicTupleFilter) {
DynamicTupleFilter dynamicFilter = (DynamicTupleFilter) child;
this.dynamicVariables.put(dynamicFilter.getVariableName(), null);
http://git-wip-us.apache.org/repos/asf/kylin/blob/0c13797e/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java b/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
index 667acf8..a2ab413 100644
--- a/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
+++ b/query/src/main/java/org/apache/kylin/query/relnode/OLAPFilterRel.java
@@ -137,6 +137,7 @@ public class OLAPFilterRel extends Filter implements OLAPRel {
List<? extends TupleFilter> children = filter.getChildren();
TblColRef inColumn = null;
List<String> inValues = new LinkedList<String>();
+ Map<String, String> dynamicVariable = new HashMap<>();
for (TupleFilter child : children) {
if (child.getOperator() == FilterOperatorEnum.EQ) {
CompareTupleFilter compFilter = (CompareTupleFilter) child;
@@ -149,6 +150,7 @@ public class OLAPFilterRel extends Filter implements OLAPRel {
return null;
}
inValues.addAll(compFilter.getValues());
+ dynamicVariable.putAll(compFilter.getVariables());
} else {
return null;
}
@@ -159,6 +161,7 @@ public class OLAPFilterRel extends Filter implements OLAPRel {
CompareTupleFilter inFilter = new CompareTupleFilter(FilterOperatorEnum.IN);
inFilter.addChild(new ColumnTupleFilter(inColumn));
inFilter.addChild(new ConstantTupleFilter(inValues));
+ inFilter.getVariables().putAll(dynamicVariable);
return inFilter;
}
http://git-wip-us.apache.org/repos/asf/kylin/blob/0c13797e/query/src/test/resources/query/sql_dynamic/query03.dat
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql_dynamic/query03.dat b/query/src/test/resources/query/sql_dynamic/query03.dat
new file mode 100644
index 0000000..fc78596
--- /dev/null
+++ b/query/src/test/resources/query/sql_dynamic/query03.dat
@@ -0,0 +1,2 @@
+FP-GTC
+Others
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/kylin/blob/0c13797e/query/src/test/resources/query/sql_dynamic/query03.sql
----------------------------------------------------------------------
diff --git a/query/src/test/resources/query/sql_dynamic/query03.sql b/query/src/test/resources/query/sql_dynamic/query03.sql
new file mode 100644
index 0000000..31d5d0b
--- /dev/null
+++ b/query/src/test/resources/query/sql_dynamic/query03.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 test_cal_dt.week_beg_dt,sum(test_kylin_fact.price) as GMV
+ , count(1) as TRANS_CNT, count(distinct leaf_categ_id) as LEAF_CATEG_CNT
+ from test_kylin_fact
+ inner JOIN edw.test_cal_dt as test_cal_dt
+ ON test_kylin_fact.cal_dt = test_cal_dt.cal_dt
+ where test_kylin_fact.lstg_format_name in (?, ?)
+ and test_cal_dt.week_beg_dt between DATE '2013-05-01' and DATE '2013-08-01'
+ group by test_cal_dt.week_beg_dt
\ No newline at end of file