This is an automated email from the ASF dual-hosted git repository.
yashmayya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 9f74fc7d148 Disable Calcite's AggregateUnionAggregate planner rule by
default (#16515)
9f74fc7d148 is described below
commit 9f74fc7d14808e85515ae4ddf906f2d805b3a714
Author: Yash Mayya <[email protected]>
AuthorDate: Thu Aug 7 15:43:45 2025 +0530
Disable Calcite's AggregateUnionAggregate planner rule by default (#16515)
---
.../pinot/query/QueryPlannerRuleOptionsTest.java | 60 ++++++++++++++++++++++
.../src/test/resources/queries/SetOpPlans.json | 15 +++---
.../apache/pinot/spi/utils/CommonConstants.java | 3 +-
3 files changed, 71 insertions(+), 7 deletions(-)
diff --git
a/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryPlannerRuleOptionsTest.java
b/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryPlannerRuleOptionsTest.java
index 5b0c00a0816..0bcf5e11838 100644
---
a/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryPlannerRuleOptionsTest.java
+++
b/pinot-query-planner/src/test/java/org/apache/pinot/query/QueryPlannerRuleOptionsTest.java
@@ -470,4 +470,64 @@ public class QueryPlannerRuleOptionsTest extends
QueryEnvironmentTestBase {
+ " PinotLogicalTableScan(table=[[default, b]])\n");
//@formatter:on
}
+
+ @Test
+ public void testAggregateUnionAggregateDisabledByDefault() {
+ // Verify that the AggregateUnionAggregateRule is disabled by default
+ //@formatter:off
+ String query = "EXPLAIN PLAN FOR "
+ + "SELECT * FROM "
+ + "(SELECT DISTINCT col1 FROM a) "
+ + "UNION "
+ + "(SELECT DISTINCT col1 FROM b)";
+ //@formatter:on
+
+ String explain = _queryEnvironment.explainQuery(query,
RANDOM_REQUEST_ID_GEN.nextLong());
+
+ // The aggregates above the table scans should not be merged into the one
above the UNION ALL
+ assertEquals(explain,
+ "Execution Plan\n"
+ + "PinotLogicalAggregate(group=[{0}], aggType=[FINAL])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " PinotLogicalAggregate(group=[{0}], aggType=[LEAF])\n"
+ + " LogicalUnion(all=[true])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " PinotLogicalAggregate(group=[{0}], aggType=[FINAL])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " PinotLogicalAggregate(group=[{0}],
aggType=[LEAF])\n"
+ + " PinotLogicalTableScan(table=[[default, a]])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " PinotLogicalAggregate(group=[{0}], aggType=[FINAL])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " PinotLogicalAggregate(group=[{0}],
aggType=[LEAF])\n"
+ + " PinotLogicalTableScan(table=[[default, b]])\n");
+ }
+
+ @Test
+ public void testAggregateUnionAggregateEnabled() {
+ // Verify that the AggregateUnionAggregateRule is disabled by default
+ //@formatter:off
+ String query = "EXPLAIN PLAN FOR "
+ + "SELECT * FROM "
+ + "(SELECT DISTINCT col1 FROM a) "
+ + "UNION "
+ + "(SELECT DISTINCT col1 FROM b)";
+ //@formatter:on
+
+ String explain = explainQueryWithRuleEnabled(query,
PlannerRuleNames.AGGREGATE_UNION_AGGREGATE);
+
+ // There shouldn't be aggregates above the table scans since they should
be merged into the one above the UNION ALL
+ assertEquals(explain,
+ "Execution Plan\n"
+ + "PinotLogicalAggregate(group=[{0}], aggType=[FINAL])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " PinotLogicalAggregate(group=[{0}], aggType=[LEAF])\n"
+ + " LogicalUnion(all=[true])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " LogicalProject(col1=[$0])\n"
+ + " PinotLogicalTableScan(table=[[default, a]])\n"
+ + " PinotLogicalExchange(distribution=[hash[0]])\n"
+ + " LogicalProject(col1=[$0])\n"
+ + " PinotLogicalTableScan(table=[[default, b]])\n");
+ }
}
diff --git a/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
b/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
index 91d796cff63..59eff321c57 100644
--- a/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
+++ b/pinot-query-planner/src/test/resources/queries/SetOpPlans.json
@@ -46,13 +46,16 @@
"\n PinotLogicalAggregate(group=[{0, 1}], aggType=[LEAF])",
"\n LogicalUnion(all=[true])",
"\n PinotLogicalExchange(distribution=[hash[0, 1]])",
- "\n LogicalUnion(all=[true])",
+ "\n PinotLogicalAggregate(group=[{0, 1}], aggType=[FINAL])",
"\n PinotLogicalExchange(distribution=[hash[0, 1]])",
- "\n LogicalProject(col1=[$0], col2=[$1])",
- "\n PinotLogicalTableScan(table=[[default, a]])",
- "\n PinotLogicalExchange(distribution=[hash[0, 1]])",
- "\n LogicalProject(col1=[$0], col2=[$1])",
- "\n PinotLogicalTableScan(table=[[default, b]])",
+ "\n PinotLogicalAggregate(group=[{0, 1}],
aggType=[LEAF])",
+ "\n LogicalUnion(all=[true])",
+ "\n PinotLogicalExchange(distribution=[hash[0,
1]])",
+ "\n LogicalProject(col1=[$0], col2=[$1])",
+ "\n PinotLogicalTableScan(table=[[default,
a]])",
+ "\n PinotLogicalExchange(distribution=[hash[0,
1]])",
+ "\n LogicalProject(col1=[$0], col2=[$1])",
+ "\n PinotLogicalTableScan(table=[[default,
b]])",
"\n PinotLogicalExchange(distribution=[hash[0, 1]])",
"\n LogicalProject(col1=[$0], col2=[$1])",
"\n PinotLogicalTableScan(table=[[default, c]])",
diff --git
a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
index 367c9370446..3ab38c56a03 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
@@ -820,7 +820,8 @@ public class CommonConstants {
public static final Set<String> DEFAULT_DISABLED_RULES = Set.of(
PlannerRuleNames.AGGREGATE_JOIN_TRANSPOSE_EXTENDED,
PlannerRuleNames.SORT_JOIN_TRANSPOSE,
- PlannerRuleNames.SORT_JOIN_COPY
+ PlannerRuleNames.SORT_JOIN_COPY,
+ PlannerRuleNames.AGGREGATE_UNION_AGGREGATE
);
public static class FailureDetector {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]