From a630f127ced5aa7141f19ee43a8eed89ca3d458c Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Thu, 27 Jul 2023 13:20:50 +0800 Subject: [PATCH] [fix](planner) fix bug of push down conjuncts through agg (#22202) should use both contains and comeFrom method to check if the conjunct can be pushed down throgh agg node --- .../main/java/org/apache/doris/analysis/DateLiteral.java | 7 +++++++ .../java/org/apache/doris/planner/SingleNodePlanner.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java index 1eda2f2c9f..770f2f9d37 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DateLiteral.java @@ -261,6 +261,7 @@ public class DateLiteral extends LiteralExpr { } else { throw new AnalysisException("Error date literal type : " + type); } + analysisDone(); } public DateLiteral(long year, long month, long day) { @@ -271,6 +272,7 @@ public class DateLiteral extends LiteralExpr { this.month = month; this.day = day; this.type = ScalarType.getDefaultDateType(Type.DATE); + analysisDone(); } public DateLiteral(long year, long month, long day, Type type) { @@ -280,6 +282,7 @@ public class DateLiteral extends LiteralExpr { Preconditions.checkArgument(type.getPrimitiveType().equals(Type.DATE.getPrimitiveType()) || type.getPrimitiveType().equals(Type.DATEV2.getPrimitiveType())); this.type = type; + analysisDone(); } public DateLiteral(long year, long month, long day, long hour, long minute, long second) { @@ -290,6 +293,7 @@ public class DateLiteral extends LiteralExpr { this.month = month; this.day = day; this.type = ScalarType.getDefaultDateType(Type.DATETIME); + analysisDone(); } public DateLiteral(long year, long month, long day, long hour, long minute, long second, long microsecond, @@ -303,6 +307,7 @@ public class DateLiteral extends LiteralExpr { this.microsecond = microsecond; Preconditions.checkArgument(type.isDatetimeV2()); this.type = type; + analysisDone(); } public DateLiteral(long year, long month, long day, long hour, long minute, long second, Type type) { @@ -315,6 +320,7 @@ public class DateLiteral extends LiteralExpr { Preconditions.checkArgument(type.getPrimitiveType().equals(Type.DATETIME.getPrimitiveType()) || type.getPrimitiveType().equals(Type.DATETIMEV2.getPrimitiveType())); this.type = type; + analysisDone(); } public DateLiteral(LocalDateTime dateTime, Type type) { @@ -328,6 +334,7 @@ public class DateLiteral extends LiteralExpr { this.second = dateTime.getSecond(); this.microsecond = dateTime.get(ChronoField.MICRO_OF_SECOND); } + analysisDone(); } public DateLiteral(DateLiteral other) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java index b01c6cc77a..61cb2d8cc7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SingleNodePlanner.java @@ -2794,7 +2794,7 @@ public class SingleNodePlanner { GroupByClause groupByClause = stmt.getGroupByClause(); List exprs = groupByClause.getGroupingExprs(); final Expr srcExpr = sourceExpr; - if (!exprs.stream().anyMatch(expr -> expr.comeFrom(srcExpr))) { + if (!exprs.contains(srcExpr) && !exprs.stream().anyMatch(expr -> expr.comeFrom(srcExpr))) { // the sourceExpr doesn't come from any of the group by exprs isAllSlotReferToGroupBys = false; break;