Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.logical.LogicalAggregate;
import org.apache.doris.nereids.util.ExpressionUtils;
import org.apache.doris.nereids.util.Utils;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;

import java.util.HashMap;
Expand Down Expand Up @@ -75,7 +75,8 @@ public Rule build() {
if (slotGroupByExprs.isEmpty() && lit != null) {
slotGroupByExprs.add(lit);
}
return aggregate.withGroupByAndOutput(ImmutableList.copyOf(slotGroupByExprs),
return aggregate.withGroupByAndOutput(
ExpressionUtils.replace(Utils.fastToImmutableList(slotGroupByExprs), constantExprsReplaceMap),
ExpressionUtils.replaceNamedExpressions(outputExprs, constantExprsReplaceMap));
}).toRule(RuleType.ELIMINATE_GROUP_BY_CONSTANT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
suite("aggregate_groupby_constant") {
sql "SET enable_nereids_planner=true"
sql "SET enable_fallback_to_original_planner=false"
sql "set disable_nereids_rules='prune_empty_partition'"

sql """ DROP TABLE IF EXISTS table_500_undef_partitions2_keys3_properties4_distributed_by5; """
sql """
Expand Down Expand Up @@ -47,4 +48,29 @@ suite("aggregate_groupby_constant") {
OR table1 . `col_int_undef_signed` <> NULL )
GROUP BY field1,field2
ORDER BY field1,field2 LIMIT 10000;"""

sql """
SELECT
IF(
t.`col_varchar_10__undef_signed` IN ('女'),
(
TIMESTAMPDIFF(
YEAR,
NOW(),
NOW()
)
),
1
) AS x0,
TIMESTAMPDIFF(
YEAR,
NOW(),
NOW()
) AS x1
FROM
table_500_undef_partitions2_keys3_properties4_distributed_by5 AS t
GROUP BY
x0,
x1;
"""
}
Loading