Skip to content

branch-4.1: [fix](udf) Reject variadic user-defined functions #67373 - #67524

Open
github-actions[bot] wants to merge 1 commit into
branch-4.1from
auto-pick-67373-branch-4.1
Open

branch-4.1: [fix](udf) Reject variadic user-defined functions #67373#67524
github-actions[bot] wants to merge 1 commit into
branch-4.1from
auto-pick-67373-branch-4.1

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Cherry-picked from #67373

User-defined functions exposed variadic DDL metadata without reliable
end-to-end support. Reject variadic declarations during `CREATE
FUNCTION` analysis for scalar, aggregate, table, and alias functions
while retaining variadic signature parsing for `DROP`, `SHOW`, and
historical metadata compatibility.

before:
```sql
CREATE FUNCTION py_add(INT, INT, ...)
RETURNS INT
PROPERTIES (
    "type" = "PYTHON_UDF",
    "symbol" = "evaluate",
    "runtime_version" = "3.12.11",
    "volatility" = "immutable"
)
AS $$
def evaluate(a, b, c):
    return a + b + c
$$;

SELECT py_add(1, 2, 3);
-- ERROR 1105 (HY000): errCode = 2, detailMessage = Index 2 out of bounds for length 2
```

In `PythonUdfBuilder.java:82`:

```java
public Pair<PythonUdf, PythonUdf> build(String name, List<?> arguments) {
    // exprs = (1, 2, 3), size = 3
    // argTypes = [INT, INT], size = 2
    List<Expression> exprs = arguments.stream().map(Expression.class::cast).collect(Collectors.toList());
    List<DataType> argTypes = udf.getSignatures().get(0).argumentsTypes;

    List<Expression> processedExprs = Lists.newArrayList();
    for (int i = 0; i < exprs.size(); ++i) {
        // when i = 2, argTypes.get(2), err occur!
        processedExprs.add(TypeCoercionUtils.castIfNotSameType(exprs.get(i), argTypes.get(i)));
    }
    return Pair.ofSame(udf.withFreshVolatileIdentity().withChildren(processedExprs));
}
```

now:
```sql
CREATE FUNCTION py_add(INT, INT, ...)
RETURNS INT
PROPERTIES (
    "type" = "PYTHON_UDF",
    "symbol" = "evaluate",
    "runtime_version" = "3.12.11",
    "volatility" = "immutable"
)
AS $$
def evaluate(a, b, c):
    return a + b + c
$$;
-- ERROR 1105 (HY000): errCode = 2, detailMessage = mismatched input ',' expecting ')'(line 1, pos 31)
```

### Release note

Reject variadic declarations for user-defined functions.

### Check List (For Author)

- Test: Unit Test
  - ./run-fe-ut.sh --run org.apache.doris.catalog.CreateFunctionTest
- Behavior changed: Yes. Variadic user-defined function declarations are
rejected during analysis.
- Does this need documentation:
apache/doris-website#4103
@github-actions
github-actions Bot requested a review from yiguolei as a code owner September 4, 2026 04:19
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 75.00% (12/16) 🎉
Increment coverage report
Complete coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants