xiangfu0 commented on code in PR #19101:
URL: https://github.com/apache/pinot/pull/19101#discussion_r3781402954
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/MultistageGroupByExecutor.java:
##########
@@ -83,6 +83,13 @@ public MultistageGroupByExecutor(int[] groupKeyIds,
AggregationFunction[] aggFun
_aggType = aggType;
_leafReturnFinalResult = leafReturnFinalResult;
_resultSchema = resultSchema;
+ for (int i = 0; i < groupKeyIds.length; i++) {
+ ColumnDataType dataType = resultSchema.getColumnDataType(i);
+ if (!dataType.supportsEquality() || !dataType.supportsHashing()) {
+ throw new IllegalArgumentException(
+ "Raw VARIANT values do not support GROUP BY; extract a typed path
with variantGet first");
+ }
+ }
Review Comment:
Addressed on current head ae60e3de73. The executor now receives the actual
logical input schema and validates
inputSchema.getColumnDataType(groupKeyIds[i]); grouping-set plans use
RepeatOperator’s expanded schema. AggregateOperatorTest and the upstream
GroupingSetsQueriesTest reproduction cover the expanded/non-prefix key shape
and pass.
##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/SortOperator.java:
##########
@@ -73,6 +74,11 @@ public SortOperator(OpChainExecutionContext context,
MultiStageOperator input, S
// - There is no collation
// - Input is already sorted
List<RelFieldCollation> collations = node.getCollations();
+ for (RelFieldCollation collation : collations) {
+ Preconditions.checkArgument(
+
_dataSchema.getColumnDataType(collation.getFieldIndex()).supportsOrdering(),
+ "ORDER BY does not support raw VARIANT values; extract a typed path
with variantGet first");
Review Comment:
Follow-up on current head ae60e3de73: added explicit non-VARIANT opaque-type
diagnostics for SortOperator, SortedMailboxReceiveOperator,
OrderByComparatorFactory, the planner capability visitor, and set operators.
These assert the actual OBJECT/MAP type while preserving VARIANT-specific
variantGet guidance.
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/validation/TypeCapabilityValidationVisitor.java:
##########
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.query.planner.validation;
+
+import java.util.List;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.common.utils.VariantUtils;
+import org.apache.pinot.query.planner.logical.RexExpression;
+import org.apache.pinot.query.planner.plannode.AggregateNode;
+import org.apache.pinot.query.planner.plannode.JoinNode;
+import org.apache.pinot.query.planner.plannode.PlanNode;
+import org.apache.pinot.query.planner.plannode.PlanNodeVisitor;
+import org.apache.pinot.query.planner.plannode.SetOpNode;
+import org.apache.pinot.query.planner.plannode.SortNode;
+import org.apache.pinot.query.planner.plannode.WindowNode;
+import org.apache.pinot.spi.exception.QueryErrorCode;
+import org.apache.pinot.spi.exception.QueryException;
+
+
+/// Rejects operations that would otherwise assign physical byte ordering,
equality, or hashing semantics to a raw
+/// VARIANT value. The visitor has no mutable state and is thread-safe, so
callers may share {@link #INSTANCE}.
+public final class VariantTypeValidationVisitor extends
PlanNodeVisitor.DepthFirstVisitor<Void, Void> {
+ public static final VariantTypeValidationVisitor INSTANCE = new
VariantTypeValidationVisitor();
+
+ private VariantTypeValidationVisitor() {
+ }
+
+ @Override
+ protected boolean traverseStageBoundary() {
+ return false;
+ }
+
+ @Override
+ public Void visitAggregate(AggregateNode node, Void context) {
+ List<PlanNode> inputs = node.getInputs();
+ if (inputs.size() == 1) {
+ validateAggregateInputs(node, inputs.get(0).getDataSchema());
+ }
+ return super.visitAggregate(node, context);
+ }
+
+ /// Validates aggregate operands against their logical input schema.
+ ///
+ /// <p>This method is also invoked by the runtime as a defensive check for
plans that did not pass through the
+ /// current broker planner.
+ public static void validateAggregateInputs(AggregateNode node, DataSchema
inputSchema) {
Review Comment:
Follow-up on current head ae60e3de73: planner group-key validation remains
in TypeCapabilityValidationVisitor (renamed to reflect its generic role), and
runtime validation now uses the exact group-key IDs against the actual expanded
input schema. The grouping-set regression is covered in both
AggregateOperatorTest and the integration suite.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]