Skip to content

Commit 1b645af

Browse files
jackwenerstephen
authored and
stephen
committed
[test](Nereids): add test for scalar agg (apache#28712)
1 parent f3f8c13 commit 1b645af

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PushDownFilterThroughAggregationTest.java

+29-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.apache.doris.nereids.trees.expressions.Slot;
2828
import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator;
2929
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
30+
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
31+
import org.apache.doris.nereids.trees.expressions.functions.scalar.If;
3032
import org.apache.doris.nereids.trees.expressions.literal.Literal;
3133
import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
3234
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
@@ -91,6 +93,28 @@ public void pushDownPredicateOneFilterTest() {
9193
);
9294
}
9395

96+
@Test
97+
void scalarAgg() {
98+
LogicalPlan plan = new LogicalPlanBuilder(scan)
99+
.agg(ImmutableList.of(), ImmutableList.of((new Sum(scan.getOutput().get(0))).alias("sum")))
100+
.filter(new If(Literal.of(false), Literal.of(false), Literal.of(false)))
101+
.project(ImmutableList.of(0))
102+
.build();
103+
104+
PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
105+
.applyTopDown(new PushDownFilterThroughAggregation())
106+
.printlnTree()
107+
.matches(
108+
logicalProject(
109+
logicalFilter(
110+
logicalAggregate(
111+
logicalOlapScan()
112+
)
113+
)
114+
)
115+
);
116+
}
117+
94118
/*-
95119
* origin plan:
96120
* project
@@ -174,7 +198,8 @@ public void pushDownPredicateGroupWithRepeatTest() {
174198
logicalAggregate(
175199
logicalFilter(
176200
logicalRepeat()
177-
).when(filter -> filter.getConjuncts().equals(ImmutableSet.of(filterPredicateId)))
201+
).when(filter -> filter.getConjuncts()
202+
.equals(ImmutableSet.of(filterPredicateId)))
178203
)
179204
)
180205
);
@@ -195,9 +220,9 @@ public void pushDownPredicateGroupWithRepeatTest() {
195220
.matches(
196221
logicalProject(
197222
logicalFilter(
198-
logicalAggregate(
199-
logicalRepeat()
200-
)
223+
logicalAggregate(
224+
logicalRepeat()
225+
)
201226
).when(filter -> filter.getConjuncts().equals(ImmutableSet.of(filterPredicateId)))
202227
)
203228
);

0 commit comments

Comments
 (0)