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


##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/PostgreSqlByteaLiteralRewriter.java:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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.sql.parsers;
+
+import java.util.List;
+import org.apache.calcite.sql.SqlBinaryStringLiteral;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlCharStringLiteral;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.fun.SqlLibraryOperators;
+import org.apache.calcite.sql.util.SqlShuttle;
+
+
+/// Normalizes PostgreSQL hex-format BYTEA literals to Calcite binary literals 
before validation or Pinot query
+/// conversion. This deliberately supports only quoted constants so it cannot 
introduce engine-specific per-row
+/// STRING-to-BYTES cast behavior.
+final class PostgreSqlByteaLiteralRewriter extends SqlShuttle {

Review Comment:
   **[P2] Please split the PostgreSQL `bytea` syntax into a follow-up PR.** 
Core BYTES-array support is independently complete with Calcite `ARRAY[X'...']` 
literals; this final commit adds a distinct parser/cast feature (+227/-27 
across four modules) to an already +998/-104, six-module PR. Keeping it 
separate would make both the wire/runtime change and the PostgreSQL 
compatibility policy independently reviewable.



##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/operands/TransformOperandFactory.java:
##########
@@ -77,8 +79,61 @@ private static TransformOperand 
getTransformOperand(RexExpression.FunctionCall f
         return new FilterOperand.Predicate(operands, dataSchema, v -> v < 0);
       case "LESS_THAN_OR_EQUAL":
         return new FilterOperand.Predicate(operands, dataSchema, v -> v <= 0);
+      case "ARRAY_VALUE_CONSTRUCTOR":
+        return getArrayValueConstructorOperand(functionCall, dataSchema);
       default:
         return new FunctionOperand(functionCall, dataSchema);
     }
   }
+
+  private static TransformOperand 
getArrayValueConstructorOperand(RexExpression.FunctionCall functionCall,
+      DataSchema dataSchema) {
+    if (functionCall.getDataType() == ColumnDataType.BYTES_ARRAY) {
+      List<RexExpression> operands = functionCall.getFunctionOperands();
+      ByteArray[] values = new ByteArray[operands.size()];
+      for (int i = 0; i < operands.size(); i++) {
+        RexExpression operand = operands.get(i);
+        if (!(operand instanceof RexExpression.Literal)) {
+          return new FunctionOperand(functionCall, dataSchema);

Review Comment:
   **[P2] Avoid the generic per-row conversion for dynamic BYTES arrays.** When 
any element is an input ref or non-literal, this falls back to 
`FunctionOperand` for every row. For `ARRAY[bytes_col_1, bytes_col_2]`, the 
path allocates an invocation `Object[]`, a `byte[][]`, a `ByteArray[]`, and one 
new `ByteArray` per element. `ReferenceOperand` already supplies reusable 
`ByteArray` wrappers over the same backing bytes, so only the result 
`ByteArray[]` needs to be allocated per row. Could we add a BYTES-specific 
dynamic operand that evaluates its children internally while retaining the 
cached literal operand?



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