diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java index f0e9666509..37a1fa0c53 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java @@ -41,6 +41,7 @@ import org.apache.doris.common.IdGenerator; import org.apache.doris.common.Pair; import org.apache.doris.common.util.TimeUtils; import org.apache.doris.planner.AggregationNode; +import org.apache.doris.planner.AnalyticEvalNode; import org.apache.doris.planner.PlanNode; import org.apache.doris.planner.RuntimeFilter; import org.apache.doris.qe.ConnectContext; @@ -2457,12 +2458,12 @@ public class Analyzer { * Wrapper around getUnassignedConjuncts(List tupleIds). */ public List getUnassignedConjuncts(PlanNode node) { - // constant conjuncts should be push down to all leaf node except agg node. + // constant conjuncts should be push down to all leaf node except agg and analytic node. // (see getPredicatesBoundedByGroupbysSourceExpr method) // so we need remove constant conjuncts when expr is not a leaf node. - List unassigned = getUnassignedConjuncts( - node instanceof AggregationNode ? node.getTupleIds() : node.getTblRefIds()); - if (!node.getChildren().isEmpty() && !(node instanceof AggregationNode)) { + List unassigned = getUnassignedConjuncts(node.getTblRefIds()); + if (!node.getChildren().isEmpty() + && !(node instanceof AggregationNode || node instanceof AnalyticEvalNode)) { unassigned = unassigned.stream() .filter(e -> !e.isConstant()).collect(Collectors.toList()); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java index 2c0e29b9b6..55304b5a3d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java @@ -1928,7 +1928,7 @@ public class QueryPlanTest extends TestWithFeService { String sql = "select /*+ SET_VAR(enable_nereids_planner=false) */ * from issue7929.t1 left join (select max(j1) over() as x from issue7929.t2) a" + " on t1.k1 = a.x where 1 = 0;"; String explainStr = getSQLPlanOrErrorMsg(sql, true); - Assert.assertTrue(UtFrameUtils.checkPlanResultContainsNode(explainStr, 4, "EMPTYSET")); + Assert.assertTrue(UtFrameUtils.checkPlanResultContainsNode(explainStr, 5, "EMPTYSET")); Assert.assertTrue(explainStr.contains("tuple ids: 5")); } diff --git a/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy b/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy index 1276b58807..29663c702d 100644 --- a/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy +++ b/regression-test/suites/correctness_p0/test_push_conjuncts_inlineview.groovy @@ -151,5 +151,39 @@ explain { } sql """ DROP TABLE IF EXISTS `push_conjunct_table` """ + + sql """ DROP TABLE IF EXISTS `dwd_mf_wms_plate_table` """ + sql """ CREATE TABLE `dwd_mf_wms_plate_table` ( + `id` int(11) NOT NULL COMMENT '主键', + `length` float NOT NULL COMMENT '', + `created_time` datetime NULL COMMENT '创建时间' + ) ENGINE=OLAP + UNIQUE KEY(`id`) + COMMENT '' + DISTRIBUTED BY HASH(`id`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + explain { + sql("""select created_time from( + select + ROW_NUMBER() over(order by id ) as row_num, + id, + length, + created_time + from( + select + id, + `length` , + created_time + from + dwd_mf_wms_plate_table + ) t + group by id,length,created_time + ) res + where res.created_time<'2022-02-18 09:30:13';""") + contains "VSELECT" + } + sql """ DROP TABLE IF EXISTS `dwd_mf_wms_plate_table` """ }