Skip to content

[FLINK-41448][table-planner] Name UDF metric groups after the normalized function name - #29910

Open
weiqingy wants to merge 1 commit into
apache:masterfrom
weiqingy:FLINK-41448-udf-metric-name-case
Open

weiqingy wants to merge 1 commit into
apache:masterfrom
weiqingy:FLINK-41448-udf-metric-name-case

Conversation

@weiqingy

Copy link
Copy Markdown
Contributor

What is the purpose of the change

Function names are case-insensitive in SQL, but the UDF metric group (udf.<udf_name>) was named after the spelling used at the call site. Calling one function as myUdf(x) and MYUDF(x) in a query produced two groups, udf.myUdf and udf.MYUDF, each with part of the samples, and a dashboard built for one spelling missed the calls made with another. This pull request names the group after the normalized (lower-case) function name, so every spelling reports under one group. UDF metrics are new in 2.4.0, so changing the name now does not affect existing dashboards.

Brief change log

  • Added BridgingFunctionGenUtil#udfMetricNameOf, which returns FunctionIdentifier#normalizeName of the function name for a function resolved by name, and the unchanged generated name for an inline function.
  • Both places that produce a UDF metric name use it: BridgingSqlFunctionCallGen (sync scalar and table functions, async scalar functions) and the async table function correlate entry in BridgingFunctionGenUtil.
  • An inline Table API function (for example call(new MyUdf(), $("x"))) is not looked up by name, so it cannot be split by spelling. It keeps its class-based name, since lower-casing it would only make the class harder to recognize.
  • Only the metric name changes. Operator names, EXPLAIN output and plan digests are unaffected.
  • The metrics docs (English and Chinese) state that the group name is the lower-case function name and describe the inline case.

Verifying this change

This change added tests and can be verified as follows:

  • UdfMetricsITCase#testFunctionNameSpellingsShareOneLowerCaseGroup: mixedCaseUdf(id), MIXEDCASEUDF(id) registers exactly one group, udf.mixedcaseudf, which receives the samples of both calls.
  • UdfMetricsITCase#testAsyncTableGroupNameIsLowerCase: an async table function called as ASYNCTABLEUDF(id) reports under udf.asynctableudf. This covers the second place that produces a metric name.
  • UdfMetricsITCase#testInlineFunctionKeepsClassBasedGroupName: an inline Table API call keeps its class-based group name.
  • Each new test fails when its part of the change is reverted. UdfMetricsITCase, AsyncCalcITCase and AsyncCorrelateITCase pass.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? docs

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code 2.1.322 (Claude Opus 5.5)

…zed function name

Function names are case-insensitive in SQL, but the UDF metric group was
named after BridgingSqlFunction#getName. For a temporary system function
that is the spelling used at the call site, so calling one function as
myUdf(x) and MYUDF(x) produced two groups, each with part of the samples.

Use FunctionIdentifier#normalizeName for functions that are resolved by
name, at both places that produce a UDF metric name, so every spelling
reports under one lower-case group. An inline function is not resolved by
name and keeps its generated, class-based name. Only the metric name
changes; operator names and plans are unaffected.
@flinkbot

flinkbot commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

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