[FLINK-39952][Table SQL/Planner] Fix CallContextMock.isArgumentNull() to correctly handle optional arguments#28475
[FLINK-39952][Table SQL/Planner] Fix CallContextMock.isArgumentNull() to correctly handle optional arguments#28475KenanAdel wants to merge 4 commits into
Conversation
… to correctly handle optional arguments Prevent IndexOutOfBoundsException in CallContextMock when checking for optional arguments that are not provided in the test case. Updated the method to safely return true when the requested position is out of bounds or the underlying list is null, ensuring compliance with the CallContext interface contract.
|
@flinkbot run azure |
spuru9
left a comment
There was a problem hiding this comment.
Can you make the PR Description as per the template provided in the repo.
There was a problem hiding this comment.
isArgumentLiteral() and getArgumentValue() still do a raw .get(pos). Not part of the ticket, but might as well guard it the same way while you're here
There was a problem hiding this comment.
@spuru9 Done. I've updated the PR description using the repository template and added consistent guard conditions to both isArgumentLiteral() and getArgumentValue(). Thanks for the review!
…BoundsException - Update isArgumentLiteral() and getArgumentValue() to safely check for nullability and bounds, matching the logic in isArgumentNull(). - Address PR review comments for codebase consistency.
|
This is also a PR that I highly suspect that's not follow the AI contribution guidelines, and we can't merge it as is. Please follow the contribution guidelines as a whole before opening PRs @KenanAdel |
|
Thanks for the feedback I've reviewed the AI contribution guidelines and updated the PR to comply with them, including the required disclosure and PR template updates. I have verified the implementation and understand the design and code logic The PR is ready for review. @MartijnVisser |
What is the purpose of the change
This pull request fixes CallContextMock to better match the CallContext contract when optional arguments are not provided in test scenarios.
Previously, some methods could access argument metadata and values using direct list lookups, which could lead to IndexOutOfBoundsException when a test declared optional arguments but did not provide corresponding entries. This change makes the mock handle missing optional arguments consistently and safely.
Brief change log
isArgumentNull()to correctly handle missing optional arguments.CallContextMock(includingisArgumentLiteral()andgetArgumentValue()).IndexOutOfBoundsExceptionfor optional arguments that are not provided.Verifying this change
This change is already covered by existing tests.
The affected behavior is exercised through the existing type inference test infrastructure that uses
CallContextMock, including tests based onInputTypeStrategiesTestBase.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude- Opus 4.7