[FLINK-39273][table-common] Fix argument name conflict when UDF method contains lambda expression#27787
Open
dylanhz wants to merge 1 commit intoapache:masterfrom
Open
[FLINK-39273][table-common] Fix argument name conflict when UDF method contains lambda expression#27787dylanhz wants to merge 1 commit intoapache:masterfrom
dylanhz wants to merge 1 commit intoapache:masterfrom
Conversation
…d contains lambda expression
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
Fix a bug where UDF type inference throws "Argument name conflict" when a method (e.g. eval, accumulate) contains a lambda expression that captures its own parameters.
The ASM-based
ParameterExtractorinExtractionUtilsmatched target methods only by bytecode descriptor, ignoring the method name. When a lambda captures parameters of the enclosingevalmethod, the Java compiler generates alambda$eval$Nsynthetic static method with the same descriptor. TheParameterExtractorvisits both the realevaland the synthetic method, causing the lambda's local variable names (starting at slot 0) to overwrite the instance method's parameter entries (where slot 0 isthis) in the sharedTreeMap, producing duplicate names and triggering the validation error.Brief change log
methodNameinParameterExtractor(method.getName()for methods,"<init>"for constructors)name.equals(methodName) && descriptor.equals(methodDescriptor)invisitMethodto avoid visiting lambda synthetic methodsVerifying this change
This change added tests and can be verified as follows:
ExtractionUtilsTestthat directly verifiesextractExecutableNamesreturns correct parameter names for a method containing a lambda that captures its own parametersTypeInferenceExtractorTestthat verifies end-to-end type inference succeeds for aScalarFunctionwith lambda captureDoes this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation