This is an automated email from the ASF dual-hosted git repository.
eldenmoon pushed a commit to branch variant-sparse
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/variant-sparse by this push:
new c582982c438 [fix](expression) fix Dynamically compute function
signature (#48894)
c582982c438 is described below
commit c582982c438208efa4575586ae22d114a8ea060f
Author: Sun Chenyang <[email protected]>
AuthorDate: Mon Mar 17 14:54:44 2025 +0800
[fix](expression) fix Dynamically compute function signature (#48894)
---
.../functions/ComputeSignatureHelper.java | 26 ++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureHelper.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureHelper.java
index 662185bc8eb..4140c47463b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureHelper.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureHelper.java
@@ -429,12 +429,23 @@ public class ComputeSignatureHelper {
return signature;
}
- /** dynamicComputeVariantArgs */
+ /**
+ * Dynamically compute function signature for variant type arguments.
+ * This method handles cases where the function signature contains variant
types
+ * and needs to be adjusted based on the actual argument types.
+ *
+ * @param signature Original function signature
+ * @param arguments List of actual arguments passed to the function
+ * @return Updated function signature with resolved variant types
+ */
public static FunctionSignature dynamicComputeVariantArgs(
FunctionSignature signature, List<Expression> arguments) {
+
List<DataType> newArgTypes =
Lists.newArrayListWithCapacity(arguments.size());
boolean findVariantType = false;
+
for (int i = 0; i < arguments.size(); i++) {
+ // Get signature type for current argument position
DataType sigType;
if (i >= signature.argumentsTypes.size()) {
sigType = signature.getVarArgType().orElseThrow(
@@ -442,15 +453,26 @@ public class ComputeSignatureHelper {
} else {
sigType = signature.argumentsTypes.get(i);
}
+
+ // Get actual type of the argument expression
DataType expressionType = arguments.get(i).getDataType();
+
+ // If both signature type and expression type are variant,
+ // use expression type and update return type
if (sigType instanceof VariantType && expressionType instanceof
VariantType) {
+ // return type is variant, update return type to expression
type
+ if (signature.returnType instanceof VariantType) {
+ signature = signature.withReturnType(expressionType);
+ }
newArgTypes.add(expressionType);
- signature = signature.withReturnType(expressionType);
findVariantType = true;
} else {
+ // Otherwise keep original signature type
newArgTypes.add(sigType);
}
}
+
+ // Update signature with new argument types if any variant type was
found
if (findVariantType) {
signature = signature.withArgumentTypes(signature.hasVarArgs,
newArgTypes);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]