xiangfu0 commented on code in PR #19101:
URL: https://github.com/apache/pinot/pull/19101#discussion_r3742924231


##########
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:
   Fixed in xiangfu0/pinot#236. The ORDER BY / sort / window / set-op / 
aggregate rejections now name the actual unsupported type (e.g. "ORDER BY does 
not support OBJECT values") and keep the raw-VARIANT wording plus `variantGet` 
guidance only for VARIANT. Applied to `SortOperator`, 
`SortedMailboxReceiveOperator`, `OrderByComparatorFactory`, and 
`VariantTypeValidationVisitor`.



##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java:
##########
@@ -1448,6 +1456,10 @@ static void validatePartialUpsertStrategies(TableConfig 
tableConfig, Schema sche
 
         FieldSpec fieldSpec = schema.getFieldSpecFor(column);
         Preconditions.checkState(fieldSpec != null, "Merger cannot be applied 
to non-existing column: %s", column);
+        if (fieldSpec.getDataType() == DataType.VARIANT) {
+          Preconditions.checkState(columnStrategy == 
UpsertConfig.Strategy.OVERWRITE,
+              "VARIANT column supports only OVERWRITE partial-upsert strategy: 
%s", column);

Review Comment:
   Fixed in xiangfu0/pinot#236. `validatePartialUpsertStrategies` now validates 
the *effective* strategy for every VARIANT column up front: it uses the 
explicit entry if listed, otherwise `defaultPartialUpsertStrategy`, and 
requires OVERWRITE. It also rejects a custom `partialUpsertMergerClass` on 
VARIANT columns (which cannot be validated against the OVERWRITE-only 
contract). Added 3 tests covering unlisted-column default, valid default, and 
custom-merger rejection.



##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/validation/VariantTypeValidationVisitor.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:
   Fixed in xiangfu0/pinot#236. `validateAggregateInputs(AggregateNode, ...)` 
now also validates `AggregateNode.getGroupKeys()` (equality+hashing), so the 
planner gate rejects `GROUP BY raw_variant` consistently with 
sort/join/set-op/window (runtime already rejected it). Added 
`testRejectsRawVariantGroupByKey`.



-- 
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]

Reply via email to