Skip to content

Commit

Permalink
[test](Nereids): add test for scalar agg (apache#28712)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwener authored and HappenLee committed Jan 12, 2024
1 parent e559ca4 commit 45f322e
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.apache.doris.nereids.trees.expressions.Slot;
import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator;
import org.apache.doris.nereids.trees.expressions.functions.agg.Max;
import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
import org.apache.doris.nereids.trees.expressions.functions.scalar.If;
import org.apache.doris.nereids.trees.expressions.literal.Literal;
import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
Expand Down Expand Up @@ -91,6 +93,28 @@ public void pushDownPredicateOneFilterTest() {
);
}

@Test
void scalarAgg() {
LogicalPlan plan = new LogicalPlanBuilder(scan)
.agg(ImmutableList.of(), ImmutableList.of((new Sum(scan.getOutput().get(0))).alias("sum")))
.filter(new If(Literal.of(false), Literal.of(false), Literal.of(false)))
.project(ImmutableList.of(0))
.build();

PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
.applyTopDown(new PushDownFilterThroughAggregation())
.printlnTree()
.matches(
logicalProject(
logicalFilter(
logicalAggregate(
logicalOlapScan()
)
)
)
);
}

/*-
* origin plan:
* project
Expand Down Expand Up @@ -174,7 +198,8 @@ public void pushDownPredicateGroupWithRepeatTest() {
logicalAggregate(
logicalFilter(
logicalRepeat()
).when(filter -> filter.getConjuncts().equals(ImmutableSet.of(filterPredicateId)))
).when(filter -> filter.getConjuncts()
.equals(ImmutableSet.of(filterPredicateId)))
)
)
);
Expand All @@ -195,9 +220,9 @@ public void pushDownPredicateGroupWithRepeatTest() {
.matches(
logicalProject(
logicalFilter(
logicalAggregate(
logicalRepeat()
)
logicalAggregate(
logicalRepeat()
)
).when(filter -> filter.getConjuncts().equals(ImmutableSet.of(filterPredicateId)))
)
);
Expand Down

0 comments on commit 45f322e

Please sign in to comment.