wolfkill opened a new pull request, #4483:
URL: https://github.com/apache/flink-cdc/pull/4483
## What is the purpose of this pull request?
This PR fixes nullable transform `LIKE` / `NOT LIKE` predicates that are
translated to the two-argument regex helpers.
The three-argument SQL `LIKE` helper already returns SQL UNKNOWN (`null`)
when any operand is null. The regex-style two-argument helper instead called
`Pattern.matcher(...)` directly and threw an NPE when the input string was
null. This caused nullable transform predicates such as `name like 'A.*'` to
fail during evaluation instead of producing UNKNOWN.
## Brief change log
- Return `Boolean` from the two-argument regex `like` / `notLike` helpers.
- Return `null` when the input string or regex pattern is null.
- Use `LogicalFunctions.not(...)` for nullable `notLike` semantics.
- Add function-level and Janino-translated predicate regression coverage.
---
## Verifying this change
This change added tests and can be verified as follows:
- Added unit coverage in `StringFunctionsTest` for nullable two-argument
regex `LIKE` / `NOT LIKE` operands.
- Added regression coverage in `JaninoCompilerTest` for translated nullable
`LIKE` / `NOT LIKE` predicates.
- Verified RED before the fix:
- `mvn -U -pl flink-cdc-runtime -am
-Dtest=JaninoCompilerTest#testTranslatedLikePredicateReturnsUnknownForNullOperand
-DfailIfNoTests=false -Dspotless.check.skip=true -Dcheckstyle.skip=true test`
- Failed with `NullPointerException` from
`StringFunctions.like(StringFunctions.java:70)`.
- Verified after the fix with Java 17:
- `mvn -pl flink-cdc-runtime -am
-Dtest=JaninoCompilerTest#testTranslatedLikePredicateReturnsUnknownForNullOperand
-DfailIfNoTests=false -Dspotless.check.skip=true -Dcheckstyle.skip=true test`
- `mvn -pl flink-cdc-runtime -am
-Dtest=StringFunctionsTest,JaninoCompilerTest -DfailIfNoTests=false
-Dspotless.check.skip=true -Dcheckstyle.skip=true test`
- `mvn -pl flink-cdc-runtime -am -DfailIfNoTests=false
-Dspotless.check.skip=true -Dcheckstyle.skip=true test`
- `mvn -pl flink-cdc-runtime -am -DskipTests test`
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: OpenAI Codex
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]