This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 20f2023 Revert "[Bug] fix OrCompoundPredicate predicate fold bug
#3596" (#3609)
20f2023 is described below
commit 20f20239f2f561867a1e41d6845673ea0b84c229
Author: Mingyu Chen <[email protected]>
AuthorDate: Mon May 18 13:03:24 2020 +0800
Revert "[Bug] fix OrCompoundPredicate predicate fold bug #3596" (#3609)
This revert is used to correct the mess of the commit
timeline caused by the wrong merge method.
---
.../java/org/apache/doris/analysis/SelectStmt.java | 33 +++++-----------------
.../org/apache/doris/planner/QueryPlanTest.java | 15 ----------
2 files changed, 7 insertions(+), 41 deletions(-)
diff --git a/fe/src/main/java/org/apache/doris/analysis/SelectStmt.java
b/fe/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 122c5e5..f705651 100644
--- a/fe/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -618,36 +618,17 @@ public class SelectStmt extends QueryStmt {
temp.add(makeCompound(cloneExprs, CompoundPredicate.Operator.AND));
}
- Expr result;
- boolean isReturnCommonFactorExpr = false;
for (List<Expr> exprList : clearExprs) {
exprList.removeAll(cloneExprs);
- if (exprList.size() == 0) {
- // For example, the sql is "where (a = 1) or (a = 1 and B = 2)"
- // if "(a = 1)" is extracted as a common factor expression,
then the first expression "(a = 1)" has no expression
- // other than a common factor expression, and the second
expression "(a = 1 and B = 2)" has an expression of "(B = 2)"
- //
- // In this case, the common factor expression ("a = 1") can be
directly used to replace the whole CompoundOrPredicate.
- // In Fact, the common factor expression is actually the
parent set of expression "(a = 1)" and expression "(a = 1 and B = 2)"
- //
- // exprList.size() == 0 means one child of CompoundOrPredicate
has no expression other than a common factor expression.
- isReturnCommonFactorExpr = true;
- break;
- }
temp.add(makeCompound(exprList, CompoundPredicate.Operator.AND));
}
- if (isReturnCommonFactorExpr) {
- result = temp.get(0);
- } else {
- // rebuild CompoundPredicate if found duplicate predicate will
build (predicate) and (.. or ..) predicate in
- // step 1: will build (.. or ..)
- result = CollectionUtils.isNotEmpty(cloneExprs) ? new
CompoundPredicate(CompoundPredicate.Operator.AND,
- temp.get(0), makeCompound(temp.subList(1, temp.size()),
CompoundPredicate.Operator.OR))
- : makeCompound(temp, CompoundPredicate.Operator.OR);
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("rewrite ors: " + result.toSql());
- }
+
+ // rebuild CompoundPredicate if found duplicate predicate will build
(predcate) and (.. or ..) predicate in
+ // step 1: will build (.. or ..)
+ Expr result = CollectionUtils.isNotEmpty(cloneExprs) ? new
CompoundPredicate(CompoundPredicate.Operator.AND,
+ temp.get(0), makeCompound(temp.subList(1, temp.size()),
CompoundPredicate.Operator.OR))
+ : makeCompound(temp, CompoundPredicate.Operator.OR);
+ LOG.debug("rewrite ors: " + result.toSql());
return result;
}
diff --git a/fe/src/test/java/org/apache/doris/planner/QueryPlanTest.java
b/fe/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index 371c38d..0398e8a 100644
--- a/fe/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -835,19 +835,4 @@ public class QueryPlanTest {
FeConstants.runningUnitTest = false;
Assert.assertTrue(explainString.contains("partitions=1/1"));
}
-
- @Test
- public void testOrCompoundPredicateFold() throws Exception {
- String queryStr = "explain select * from baseall where (k1 > 1) or
(k1 > 1 and k2 < 1)";
- String explainString =
UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, queryStr);
- Assert.assertTrue(explainString.contains("PREDICATES: (`k1` > 1)\n"));
-
- queryStr = "explain select * from baseall where (k1 > 1 and k2 < 1)
or (k1 > 1)";
- explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext,
queryStr);
- Assert.assertTrue(explainString.contains("PREDICATES: `k1` > 1\n"));
-
- queryStr = "explain select * from baseall where (k1 > 1) or (k1 > 1)";
- explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext,
queryStr);
- Assert.assertTrue(explainString.contains("PREDICATES: (`k1` > 1)\n"));
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]