Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Oct 10, 2024
1 parent a5316bb commit 80baf78
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import org.junit.jupiter.api.Test;

public class PushDownCountIntoUnionAllTest extends TestWithFeService implements MemoPatternMatchSupported {
public class PushCountIntoUnionAllTest extends TestWithFeService implements MemoPatternMatchSupported {
@Override
protected void runBeforeAll() throws Exception {
createDatabase("test");
Expand All @@ -42,7 +42,7 @@ protected void runBeforeAll() throws Exception {

@Test
void testPushCountStar() {
String sql = "select count(1) from (select id,a from t1 union all select id,a from t1 where id>10) t;";
String sql = "select id,count(1) from (select id,a from t1 union all select id,a from t1 where id>10) t group by id;";
PlanChecker.from(connectContext)
.analyze(sql)
.rewrite()
Expand All @@ -52,7 +52,7 @@ void testPushCountStar() {
logicalAggregate().when(agg -> ExpressionUtils.containsType(agg.getOutputExpressions(), Count.class)))
).when(agg -> ExpressionUtils.containsType(agg.getOutputExpressions(), Sum0.class))
);
String sql2 = "select count(*) from (select id,a from t1 union all select id,a from t1 where id>10) t;";
String sql2 = "select id,count(*) from (select id,a from t1 union all select id,a from t1 where id>10) t group by id;";
PlanChecker.from(connectContext)
.analyze(sql2)
.rewrite()
Expand All @@ -63,6 +63,19 @@ void testPushCountStar() {
).when(agg -> ExpressionUtils.containsType(agg.getOutputExpressions(), Sum0.class))
);
}
// TODO: not push because after column prune, agg-union transform to agg-project(1)-union, not match rule pattern.
@Test
void testPushCountStarNotPush() {
String sql = "select count(1) from (select id,a from t1 union all select id,a from t1 where id>10) t;";
PlanChecker.from(connectContext)
.analyze(sql)
.rewrite()
.nonMatch(
logicalAggregate(
logicalUnion(logicalAggregate(), logicalAggregate())
).when(agg -> ExpressionUtils.containsType(agg.getOutputExpressions(), Sum0.class))
);
}

@Test
void testPushCountColumn() {
Expand Down

0 comments on commit 80baf78

Please sign in to comment.