This is an automated email from the ASF dual-hosted git repository.
xiangfu0 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 cf1ce2d299f Remove leftovers of the two-plan design from the MV
aggregate comments and tests (#20334)
cf1ce2d299f is described below
commit cf1ce2d299f757236770a33d5a9c61b7e2858027
Author: Yash Mayya <[email protected]>
AuthorDate: Tue Nov 24 13:11:32 2026 +0530
Remove leftovers of the two-plan design from the MV aggregate comments and
tests (#20334)
---
pinot-common/src/main/proto/plan.proto | 5 +++--
.../tests/MultiStageEngineIntegrationTest.java | 16 ++++++++--------
.../validation/ArrayToMvValidationVisitor.java | 19 ++++++-------------
.../validation/ArrayToMvValidationVisitorTest.java | 4 ++--
.../runtime/operator/MvAggregateOperatorTest.java | 2 +-
.../src/test/resources/queries/MvAggregate.json | 6 +++---
6 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/pinot-common/src/main/proto/plan.proto
b/pinot-common/src/main/proto/plan.proto
index f03b2fcd175..521d7d0a08c 100644
--- a/pinot-common/src/main/proto/plan.proto
+++ b/pinot-common/src/main/proto/plan.proto
@@ -45,8 +45,9 @@ message PlanNode {
EnrichedJoinNode enrichedJoinNode = 17 [deprecated = true];
UnnestNode unnestNode = 18;
// Rolling upgrade: a server that predates this field reads it as
NODE_NOT_SET and throws
- // "Unsupported PlanNode type". A broker emits it only for a query that
fails to plan without it, so
- // every query that an old server runs today keeps its plan.
+ // "Unsupported PlanNode type". A broker emits it only for GROUP BY
ARRAY_TO_MV(expr) when the aggregate cannot
+ // run in the leaf stage, for example above a join. An aggregate that
reads a table scan keeps the
+ // AggregateNode, which an old server runs.
MvAggregateNode mvAggregateNode = 19;
}
}
diff --git
a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java
b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java
index 8527bd46df0..ce43a86438e 100644
---
a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java
+++
b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/MultiStageEngineIntegrationTest.java
@@ -1236,9 +1236,9 @@ public class MultiStageEngineIntegrationTest extends
BaseClusterIntegrationTestS
assertEquals(results.get(10).asText(), "hello!");
}
- /// The hint that a leaf-only `GROUP BY ARRAY_TO_MV(col)` uses to plan the
MV aggregate: the plan without it fails,
- /// so the planner plans the MV aggregate, which ignores the hint and runs
inside the leaf stage. Without a hint, the
- /// query keeps the plain leaf aggregate.
+ /// The hint that a leaf-only `GROUP BY ARRAY_TO_MV(col)` uses to plan the
MV aggregate: with it, the plain aggregate
+ /// runs above the leaf stage, so the planner plans the MV aggregate, which
ignores the hint and runs inside the leaf
+ /// stage. Without a hint, the query keeps the plain leaf aggregate.
@DataProvider(name = "mvAggregateHint")
public Object[][] mvAggregateHint() {
return new Object[][]{{""}, {"/*+
aggOptions(is_skip_leaf_stage_group_by='true') */ "}};
@@ -1441,7 +1441,7 @@ public class MultiStageEngineIntegrationTest extends
BaseClusterIntegrationTestS
throws Exception {
String join = "FROM mytable a JOIN mytable b ON a.FlightNum = b.FlightNum
AND a.DaysSinceEpoch = b.DaysSinceEpoch ";
String query = "SELECT ARRAY_TO_MV(a.RandomAirports), COUNT(*) " + join +
"GROUP BY ARRAY_TO_MV(a.RandomAirports)";
- // The planner plans the MV aggregate because the query fails without it.
+ // The aggregate cannot run in the leaf stage, so the planner plans the MV
aggregate.
Assertions.assertThat(explainPlan("EXPLAIN PLAN FOR " +
query)).contains("PinotLogicalMvAggregate");
JsonNode mvAggregate = postQuery(query);
assertNoError(mvAggregate);
@@ -1480,8 +1480,8 @@ public class MultiStageEngineIntegrationTest extends
BaseClusterIntegrationTestS
return new Object[][]{{""}, {"/*+ joinOptions(join_strategy='lookup')
*/"}};
}
- /// With the hint `is_skip_leaf_stage_group_by`, the plan without the MV
aggregate fails, so the planner plans the MV
- /// aggregate, which ignores the hint. The result equals the plain aggregate
of the query without the hint.
+ /// With the hint `is_skip_leaf_stage_group_by`, the plain aggregate runs
above the leaf stage, so the planner plans
+ /// the MV aggregate, which ignores the hint. The result equals the plain
aggregate of the query without the hint.
@Test
public void testMvAggregateSkipLeafHint()
throws Exception {
@@ -1531,8 +1531,8 @@ public class MultiStageEngineIntegrationTest extends
BaseClusterIntegrationTestS
assertEquals(sortedRows(multiStage.get("resultTable").get("rows")),
expectedRows);
}
- /// On a scan, the hint makes the plan without the MV aggregate fail, so the
planner plans the MV aggregate (see
- /// [#mvAggregateHint]). Above a join, the plan without the MV aggregate
fails anyway.
+ /// On a scan, the hint makes the planner plan the MV aggregate (see
[#mvAggregateHint]). Above a join, the planner
+ /// plans the MV aggregate with or without the hint.
@DataProvider(name = "mvAggregateFromClauses")
public Object[][] mvAggregateFromClauses() {
return new Object[][]{
diff --git
a/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitor.java
b/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitor.java
index 2d50fc2d6a7..4f99a855829 100644
---
a/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitor.java
+++
b/pinot-query-planner/src/main/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitor.java
@@ -47,10 +47,11 @@ import org.apache.pinot.spi.exception.QueryException;
/// Validates the uses of `ARRAY_TO_MV` that remain in a plan after the
planner rules.
///
-/// `GROUP BY ARRAY_TO_MV(expr)` is planned as an MV aggregate, which removes
the call from the plan. Any other use is
-/// either a supported leaf-stage use, where the leaf translation drops the
call and the single-stage engine sees the
-/// multi-value column, or an error. The check is structural: any remaining
call in a node that runs in an intermediate
-/// stage is an error, so that no `f(ARRAY_TO_MV(col))` shape reaches an
intermediate-stage operator undetected.
+/// `GROUP BY ARRAY_TO_MV(expr)` above the leaf stage is planned as an MV
aggregate, which removes the call from the
+/// plan. Any other use is either a supported leaf-stage use, where the leaf
translation drops the call and the
+/// single-stage engine sees the multi-value column, or an error. The check is
structural: any remaining call in a node
+/// that runs in an intermediate stage is an error, so that no
`f(ARRAY_TO_MV(col))` shape reaches an intermediate-stage
+/// operator undetected.
///
/// | Node | Leaf stage | Intermediate stage |
/// |---|---|---|
@@ -384,15 +385,7 @@ public class ArrayToMvValidationVisitor implements
PlanNodeVisitor<Void, Boolean
}
private static QueryException error(String context) {
- return new ArrayToMvValidationException(context + ". " + SUPPORTED_USES);
- }
-
- /// The [QueryErrorCode#QUERY_PLANNING] error of a plan that uses
`ARRAY_TO_MV` where the plan cannot run it. The
- /// MV aggregate fallback plans such a query again with the MV aggregate.
- public static class ArrayToMvValidationException extends QueryException {
- ArrayToMvValidationException(String message) {
- super(QueryErrorCode.QUERY_PLANNING, message);
- }
+ return new QueryException(QueryErrorCode.QUERY_PLANNING, context + ". " +
SUPPORTED_USES);
}
private boolean containsArrayToMv(RexExpression expression) {
diff --git
a/pinot-query-planner/src/test/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitorTest.java
b/pinot-query-planner/src/test/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitorTest.java
index 777ef958551..8b8cfab1bbc 100644
---
a/pinot-query-planner/src/test/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitorTest.java
+++
b/pinot-query-planner/src/test/java/org/apache/pinot/query/planner/validation/ArrayToMvValidationVisitorTest.java
@@ -143,9 +143,9 @@ public class ArrayToMvValidationVisitorTest {
false, null, 0);
validate(node, false);
validateWithoutMvAggregate(node, false);
- for (boolean useMvAggregate : new boolean[]{true, false}) {
+ for (boolean planHasMvAggregate : new boolean[]{true, false}) {
QueryException e = expectThrows(QueryException.class,
- () -> ArrayToMvValidationVisitor.validate(node, false,
useMvAggregate));
+ () -> ArrayToMvValidationVisitor.validate(node, false,
planHasMvAggregate));
assertTrue(e.getMessage().contains("in the intermediate stage"),
e.getMessage());
assertTrue(e.getMessage().contains("Use ARRAY_TO_MV() to group by
multi-value column"), e.getMessage());
assertTrue(e.getMessage().endsWith(ArrayToMvValidationVisitor.SUPPORTED_USES),
e.getMessage());
diff --git
a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/MvAggregateOperatorTest.java
b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/MvAggregateOperatorTest.java
index a0dd5c97783..a88b914d07f 100644
---
a/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/MvAggregateOperatorTest.java
+++
b/pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/MvAggregateOperatorTest.java
@@ -430,7 +430,7 @@ public class MvAggregateOperatorTest {
assertEquals(statMap.getLong(AggregateOperator.StatKey.NUM_GROUPS), 2);
}
- /// The stats are reported under the MV aggregate type, with the aggregate
stat keys.
+ /// The stats are reported with the type and the stat keys of the plain
aggregate.
@Test
public void testStatsType() {
DataSchema inSchema = new DataSchema(new String[]{"mv"}, new
ColumnDataType[]{STRING_ARRAY});
diff --git a/pinot-query-runtime/src/test/resources/queries/MvAggregate.json
b/pinot-query-runtime/src/test/resources/queries/MvAggregate.json
index c59af13cedb..bb8ebf477da 100644
--- a/pinot-query-runtime/src/test/resources/queries/MvAggregate.json
+++ b/pinot-query-runtime/src/test/resources/queries/MvAggregate.json
@@ -1,6 +1,6 @@
{
"mv_aggregate": {
- "comment": "GROUP BY ARRAY_TO_MV(col) plans as an MV aggregate when the
query fails without it. Above a join it runs as MvAggregateOperator. An
aggregate that runs whole in the leaf stage keeps the plain aggregate. The
cases on a scan that test the MV aggregate use the hint
is_skip_leaf_stage_group_by: with it, the plan without the MV aggregate fails,
and the MV aggregate, which ignores the hint, runs inside the leaf stage. The
expected rows follow single-stage engine semantics: one [...]
+ "comment": "GROUP BY ARRAY_TO_MV(col) plans as an MV aggregate when the
aggregate cannot run in the leaf stage. Above a join it runs as
MvAggregateOperator. An aggregate that reads a table scan keeps the plain
aggregate, which the leaf stage runs in the single-stage engine. The cases on a
scan that test the MV aggregate use the hint is_skip_leaf_stage_group_by: with
it, the plain aggregate runs above the leaf stage, so the planner plans the MV
aggregate, which ignores the hint and ru [...]
"tables": {
"tbl": {
"schema": [
@@ -223,7 +223,7 @@
"ignoreV2Optimizer": true
},
{
- "description": "The planner plans the MV aggregate above a self-join
because the query fails without it",
+ "description": "The planner plans the MV aggregate above a self-join,
where the aggregate cannot run in the leaf stage",
"sql": "SELECT ARRAY_TO_MV(t1.strMv), COUNT(*) FROM {tbl} t1 JOIN
{tbl} t2 ON t1.k = t2.k GROUP BY ARRAY_TO_MV(t1.strMv)",
"outputs": [["a", 3], ["b", 2], ["c", 1], [null, 1]],
"ignoreV2Optimizer": true
@@ -299,7 +299,7 @@
]
},
"mv_aggregate_null_handling": {
- "comment": "With column-based null handling the MV column is nullable. A
null row forms one null group, as in the single-stage engine. CROSS JOIN UNNEST
differs here: it drops the null row. In a query that plans without the MV
aggregate, ARRAY_TO_MV has the NOT NULL type that it had before the MV
aggregate, so Calcite removes COALESCE and folds IS NULL checks around it, as
before. In the plan with the MV aggregate, ARRAY_TO_MV is nullable when its
array is nullable, so the planner ke [...]
+ "comment": "With column-based null handling the MV column is nullable. A
null row forms one null group, as in the single-stage engine. CROSS JOIN UNNEST
differs here: it drops the null row. ARRAY_TO_MV is nullable when its array is
nullable, so Calcite keeps COALESCE and IS NULL checks around it. The leaf
stage cannot run COALESCE on a multi-value column. Above the leaf stage,
COALESCE around an ARRAY_TO_MV group key nests ARRAY_TO_MV in another
expression, which is not supported.",
"extraProps": {
"enableColumnBasedNullHandling": true
},
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]