[fix](planner)should always use plan node's getTblRefIds method to get unassigned conjuncts for this node (#25130)
This commit is contained in:
@ -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<TupleId> tupleIds).
|
||||
*/
|
||||
public List<Expr> 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<Expr> unassigned = getUnassignedConjuncts(
|
||||
node instanceof AggregationNode ? node.getTupleIds() : node.getTblRefIds());
|
||||
if (!node.getChildren().isEmpty() && !(node instanceof AggregationNode)) {
|
||||
List<Expr> unassigned = getUnassignedConjuncts(node.getTblRefIds());
|
||||
if (!node.getChildren().isEmpty()
|
||||
&& !(node instanceof AggregationNode || node instanceof AnalyticEvalNode)) {
|
||||
unassigned = unassigned.stream()
|
||||
.filter(e -> !e.isConstant()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -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"));
|
||||
}
|
||||
|
||||
|
||||
@ -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` """
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user