This is an automated email from the ASF dual-hosted git repository.
nextdreamblue pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 57113320bde [fix](planner) remove and retain input slot for aggregate
slot which is not materialized (#33044)
57113320bde is described below
commit 57113320bde8b9581b9ac0783df2d7085a4c97a0
Author: xueweizhang <[email protected]>
AuthorDate: Fri Mar 29 19:39:16 2024 +0800
[fix](planner) remove and retain input slot for aggregate slot which is not
materialized (#33044)
Signed-off-by: nextdreamblue <[email protected]>
---
.../org/apache/doris/planner/AggregationNode.java | 27 +++++++++-----
.../test_inlineview_with_project.out | 3 ++
.../test_inlineview_with_project.groovy | 41 ++++++++++++++++++++++
3 files changed, 62 insertions(+), 9 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java
index b0a4fcf2db3..56683c79196 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java
@@ -363,16 +363,25 @@ public class AggregationNode extends PlanNode {
if (!tupleDesc.getMaterializedSlots().isEmpty()) {
result.add(tupleDesc.getMaterializedSlots().get(0).getId());
}
- }
- // if some input slot for aggregate slot which is not materialized, we
need to remove it from the result
- TupleDescriptor tupleDescriptor = aggInfo.getOutputTupleDesc();
- ArrayList<SlotDescriptor> slots = tupleDescriptor.getSlots();
- for (SlotDescriptor slot : slots) {
- if (!slot.isMaterialized()) {
- List<SlotId> unRequestIds = Lists.newArrayList();
- Expr.getIds(slot.getSourceExprs(), null, unRequestIds);
- unRequestIds.forEach(result::remove);
+ } else {
+ // if some input slot for aggregate slot which is not
materialized, we need to remove it from the result
+ TupleDescriptor tupleDescriptor = aggInfo.getOutputTupleDesc();
+ ArrayList<SlotDescriptor> slots = tupleDescriptor.getSlots();
+ Set<SlotId> allUnRequestIds = Sets.newHashSet();
+ Set<SlotId> allRequestIds = Sets.newHashSet();
+ for (SlotDescriptor slot : slots) {
+ if (!slot.isMaterialized()) {
+ List<SlotId> unRequestIds = Lists.newArrayList();
+ Expr.getIds(slot.getSourceExprs(), null, unRequestIds);
+ allUnRequestIds.addAll(unRequestIds);
+ } else {
+ List<SlotId> requestIds = Lists.newArrayList();
+ Expr.getIds(slot.getSourceExprs(), null, requestIds);
+ allRequestIds.addAll(requestIds);
+ }
}
+ allRequestIds.forEach(allUnRequestIds::remove);
+ allUnRequestIds.forEach(result::remove);
}
return result;
}
diff --git
a/regression-test/data/correctness_p0/test_inlineview_with_project.out
b/regression-test/data/correctness_p0/test_inlineview_with_project.out
index 20135da100a..fad0b3fe446 100644
--- a/regression-test/data/correctness_p0/test_inlineview_with_project.out
+++ b/regression-test/data/correctness_p0/test_inlineview_with_project.out
@@ -23,3 +23,6 @@
2
3
+-- !select5 --
+3
+
diff --git
a/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy
b/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy
index 8a70fb9e751..07d274ed1a1 100644
--- a/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy
+++ b/regression-test/suites/correctness_p0/test_inlineview_with_project.groovy
@@ -562,6 +562,47 @@ suite("test_inlineview_with_project") {
order by 1;
"""
+ qt_select5 """
+ select
+ count(*)
+ from
+ (
+ select
+ random(),
+ group_concat(cast(ga.column3 as varchar)) as column111
+ from
+ (
+ select
+ t1.id as id,
+ upper(t1.caseId) as column1,
+ t1.content as column3
+ from
+ (
+ select
+ id,
+ caseId,
+ content
+ from
+ dr_user_test_t2
+ limit
+ 10
+ ) t1
+ left join (
+ select
+ id,
+ caseId,
+ content
+ from
+ dr_user_test_t2
+ limit
+ 10
+ ) t2 on t1.id = t2.id
+ ) as ga
+ group by
+ lower(ga.column3)
+ ) as a;
+ """
+
sql """DROP TABLE IF EXISTS `dr_user_test_t1`;"""
sql """DROP TABLE IF EXISTS `dr_user_test_t2`;"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]