Skip to content

[hotfix][runtime] Respect UDF precedence during type validation - #4505

Merged
lvyanquan merged 2 commits into
apache:masterfrom
haruki-830:hotfix/udf-validation-precedence
Aug 20, 2026
Merged

[hotfix][runtime] Respect UDF precedence during type validation#4505
lvyanquan merged 2 commits into
apache:masterfrom
haruki-830:hotfix/udf-validation-precedence

Conversation

@haruki-830

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

This is a follow-up to #4492 (FLINK-40240). It aligns Calcite type validation with Janino code generation by giving same-named UDFs precedence over built-in functions.

Verifying this change

  • Added a regression test for UDF return-type inference.

Documentation

This PR does not introduce a new feature.

@haruki-830
haruki-830 marked this pull request as ready for review August 12, 2026 07:56
@leonardBang
leonardBang requested a review from yuxiqian August 14, 2026 09:45
@haruki-830
haruki-830 force-pushed the hotfix/udf-validation-precedence branch from bce9c49 to d107204 Compare August 19, 2026 05:38
SqlNode visited = super.visit(call);
if (visited instanceof SqlBasicCall) {
SqlBasicCall basicCall = (SqlBasicCall) visited;
udfFunctions.stream()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveUserDefinedFunctions matches every SqlBasicCall solely by operator name, including structural operators. Since UDF names are not restricted, registering a UDF named as causes id AS alias to have its AS operator replaced by the UDF, so Calcite validates it as a function call rather than an alias expression.
Please restrict rebinding to actual function-call syntax and leave structural/special operators such as AS intact.

      if (basicCall.getOperator().getSyntax().family
              != SqlSyntax.FUNCTION) {
          return visited;
      }

@lvyanquan lvyanquan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@lvyanquan
lvyanquan merged commit 4f239e7 into apache:master Aug 20, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants