Copilot commented on code in PR #19091: URL: https://github.com/apache/pinot/pull/19091#discussion_r3654462014
########## pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/function/BytesToUuidUdf.java: ########## @@ -0,0 +1,46 @@ +/** + * 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.runtime.function; + +import com.google.auto.service.AutoService; +import java.util.Map; +import java.util.Set; +import org.apache.pinot.common.function.scalar.uuid.UuidConversionFunctions; +import org.apache.pinot.core.udf.Udf; +import org.apache.pinot.core.udf.UdfExample; +import org.apache.pinot.core.udf.UdfSignature; + + +@AutoService(Udf.class) +public class BytesToUuidUdf extends Udf.FromAnnotatedMethod { + public BytesToUuidUdf() + throws NoSuchMethodException { + super(UuidConversionFunctions.class.getMethod("bytesToUuid", byte[].class)); + } + + @Override + public String getDescription() { + return "Converts a 16-byte BYTES value into a canonical lowercase UUID string rendered as Pinot UUID."; + } Review Comment: The description says this UDF converts BYTES into a "UUID string", but the underlying method returns a `UUID` (Pinot logical UUID). This wording is confusing for users reading generated UDF docs/tests. ########## pinot-common/src/main/java/org/apache/pinot/common/function/scalar/uuid/IsUuidScalarFunction.java: ########## @@ -0,0 +1,91 @@ +/** + * 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.common.function.scalar.uuid; + +import java.util.List; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.calcite.sql.type.OperandTypes; +import org.apache.calcite.sql.type.ReturnTypes; +import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.pinot.common.function.FunctionInfo; +import org.apache.pinot.common.function.sql.PinotSqlFunction; +import org.apache.pinot.spi.annotations.ScalarFunction; +import org.apache.pinot.spi.utils.UuidUtils; + + +/** + * Polymorphic scalar function that validates string or bytes values as UUID inputs. + * + * <p>This implementation is stateless and thread-safe. + */ +@ScalarFunction(names = {"IS_UUID"}) +public class IsUuidScalarFunction extends AbstractStringOrBytesUuidFunction { + private static final FunctionInfo STRING_FUNCTION_INFO; + private static final FunctionInfo BYTES_FUNCTION_INFO; + + static { + try { + STRING_FUNCTION_INFO = + new FunctionInfo(IsUuidScalarFunction.class.getMethod("isUuid", String.class), IsUuidScalarFunction.class, + true); Review Comment: `IsUuidScalarFunction` is registered with `nullableParameters=true` (via `new FunctionInfo(..., true)`), so `FunctionInvoker` will invoke the method even when the input is null. This makes `IS_UUID(null)` return `false` (because `UuidUtils.isUuid(null)` returns false) instead of returning `null`, which contradicts the UDF examples in `IsUuidUdf` and prevents the ingestion `InbuiltFunctionEvaluator` from preserving nulls for this function. This issue also appears on line 48 of the same file. -- 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]
