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 3db8160 [Bug] Fix Tuple is null predicate may cause be cores (#6466)
3db8160 is described below
commit 3db8160400678758ab86eb41b3f464865684cb25
Author: xy720 <[email protected]>
AuthorDate: Mon Sep 27 10:31:48 2021 +0800
[Bug] Fix Tuple is null predicate may cause be cores (#6466)
---
.../doris/analysis/TupleIsNullPredicate.java | 8 +++++
.../doris/analysis/TupleIsNullPredicateTest.java | 37 ++++++++++++++++++++++
.../java/org/apache/doris/planner/PlannerTest.java | 34 ++++++++++++++++++++
3 files changed, 79 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
index c4cb13f..c2b23b5 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TupleIsNullPredicate.java
@@ -57,6 +57,14 @@ public class TupleIsNullPredicate extends Predicate {
protected boolean isConstantImpl() { return false; }
@Override
+ public boolean isBoundByTupleIds(List<TupleId> tids) {
+ for (TupleId tid: tids) {
+ if (tupleIds.contains(tid)) return true;
+ }
+ return false;
+ }
+
+ @Override
public Expr clone() {
return new TupleIsNullPredicate(this);
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/analysis/TupleIsNullPredicateTest.java
b/fe/fe-core/src/test/java/org/apache/doris/analysis/TupleIsNullPredicateTest.java
new file mode 100644
index 0000000..113bbb1
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/analysis/TupleIsNullPredicateTest.java
@@ -0,0 +1,37 @@
+// 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.
+
+package org.apache.doris.analysis;
+
+import com.google.common.collect.Lists;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+public class TupleIsNullPredicateTest {
+
+ @Test
+ public void testIsBoundToTuples() {
+ List<TupleId> tupleIds = Lists.newArrayList();
+ tupleIds.add(new TupleId(20));
+ tupleIds.add(new TupleId(21));
+ TupleIsNullPredicate tupleIsNullPredicate = new
TupleIsNullPredicate(tupleIds);
+
Assert.assertFalse(tupleIsNullPredicate.isBoundByTupleIds(Lists.newArrayList(new
TupleId(1))));
+ }
+}
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
b/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
index 26980ee..084a536 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
@@ -20,6 +20,7 @@ package org.apache.doris.planner;
import org.apache.doris.analysis.CreateDbStmt;
import org.apache.doris.analysis.CreateTableStmt;
import org.apache.doris.analysis.ExplainOptions;
+import org.apache.doris.analysis.Expr;
import org.apache.doris.catalog.Catalog;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.StmtExecutor;
@@ -62,6 +63,11 @@ public class PlannerTest {
+ "AGGREGATE KEY(k1) partition by range(k1) () distributed by
hash(k1) buckets 3 properties('replication_num' = '1');";
createTableStmt = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(createTblStmtStr, ctx);
Catalog.getCurrentCatalog().createTable(createTableStmt);
+
+ createTblStmtStr = "create table db1.tbl3 (k1 date, k2 varchar(128)
NULL, k3 varchar(5000) NULL) "
+ + "DUPLICATE KEY(k1, k2, k3) distributed by hash(k1) buckets 1
properties ('replication_num' = '1');";
+ createTableStmt = (CreateTableStmt)
UtFrameUtils.parseAndAnalyzeStmt(createTblStmtStr, ctx);
+ Catalog.getCurrentCatalog().createTable(createTableStmt);
}
@Test
@@ -360,4 +366,32 @@ public class PlannerTest {
Assert.assertNotNull(stmtExecutor.planner());
}
+ @Test
+ public void testAnalyticSortNodeLeftJoin() throws Exception {
+ String sql = "SELECT a.k1, a.k3, SUM(COUNT(t.k2)) OVER (PARTITION BY
a.k3 ORDER BY a.k1) AS c\n" +
+ "FROM ( SELECT k1, k3 FROM db1.tbl3) a\n" +
+ "LEFT JOIN (SELECT 1 AS line, k1, k2, k3 FROM db1.tbl3) t\n" +
+ "ON t.k1 = a.k1 AND t.k3 = a.k3\n" +
+ "GROUP BY a.k1, a.k3";
+ StmtExecutor stmtExecutor = new StmtExecutor(ctx, sql);
+ stmtExecutor.execute();
+ Assert.assertNotNull(stmtExecutor.planner());
+ Planner planner = stmtExecutor.planner();
+ List<PlanFragment> fragments = planner.getFragments();
+ Assert.assertTrue(fragments.size() > 0);
+ PlanNode node = fragments.get(0).getPlanRoot().getChild(0);
+ Assert.assertTrue(node.getChildren().size() > 0);
+ Assert.assertTrue(node instanceof SortNode);
+ SortNode sortNode = (SortNode) node;
+ List<Expr> tupleExprs = sortNode.resolvedTupleExprs;
+ List<Expr> sortTupleExprs =
sortNode.getSortInfo().getSortTupleSlotExprs();
+ for (Expr expr : tupleExprs) {
+ expr.isBoundByTupleIds(sortNode.getChild(0).tupleIds);
+ }
+ for (Expr expr : sortTupleExprs) {
+ expr.isBoundByTupleIds(sortNode.getChild(0).tupleIds);
+ }
+ }
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]