Repository navigation
[Fix][Transform-V2] Make calcite, nlpmodel and validator case conversion locale independent - #12618
Conversation
…ion locale independent
|
The Run totals: 94 jobs, 79 successful, 11 skipped, 3 failed, 1 cancelled.
The detail on each:
So 481 tests ran across the three integration jobs and exactly 3 failed, each one a distinct pre-existing flake with a fix already in review. Nothing in the transform unit tests failed. I would rather not rerun blindly, since all four causes are upstream and a rerun only re-rolls the dice. Happy to rebase onto |
|
Thanks @DanielLeens. Tracking issue drafted per your scope; I will open it separately so the guard stays out of this PR. On the red Build: I pulled the three failing job logs for run
A few details worth stating rather than asserting "flaky":
On whether this diff could cause any of them: every Happy to rerun the three jobs if you would rather see the aggregate green, though #12116 in particular will keep recurring on the Flink leg until it is fixed. |
|
Cross-link for discoverability, per @SEZ9 on #12617: the lint-rule guard is deliberately not in this PR. It is tracked separately in #12620, which carries the 24-site baseline on |
|
Thanks @SEPURI-SAI-KRISHNA. Agreed on the split: keeping the lint-rule guard out of this PR and tracking it in #12620, sequenced after this PR and the other fix land so the rule is evaluated against the post-fix module rather than the 24-site baseline on On the red What I would still like before merging:
Once the rebase is pushed I will do the review pass on the diff itself. |
|
Both asks are done, @SEZ9. 1. Refreshed onto current Nothing conflicted. Of the 13 2. The eleven are the complete set. Added to the PR description, and the scan on the new head is: 83 For the #12620 starting point you asked for: the same scan over all 228 On the rerun. Noting it since it had already run before your comment, and it turned out to be informative rather than blind. Attempt 2 of So the second run is the artifact you originally wanted: two of the three tracked flakes cleared, and the third reproduced with its own tracked signature. |
|
Heads up on the red Build before you start the review pass: it is one unrelated job, not the diff. The failing leg is That is the test named in open issue #11847. It is not a job timeout either: This PR changes 11 files, 8 under I am not asking for a rerun, since you said one was not needed. Flagging it only so the red mark does not read as a signal coming from the diff. |
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @SEPURI-SAI-KRISHNA, thank you for this thorough follow-up to #12495, and for being upfront about which sites are real defects and which are consistency changes. I reviewed head 4bbe8b329 (already merged with current dev at the time) by reading the call sites and their callers. This is a static review; I did not run the PR.
What problem does this PR solve
- Pain point: eleven
toUpperCase()/toLowerCase()calls inseatunnel-transforms-v2(calcite,nlpmodel,validator) use the JVM default locale. On a worker running undertr-TR(oraz),iandIdo not round-trip, so tokens that are later compared withequals,List.containsor aswitchstop matching. - Approach: every site now passes
Locale.ROOT, plus four regression tests that switch the default locale totr-TRin atry/finally. - One sentence: a mechanical, locale-independent case conversion for the remaining sites of the defect class fixed for
sql/in #12495.
1. Code change review
Core logic (before / after)
before: method.toUpperCase() -> the I of PROJECTION becomes a dotted capital I (U+0130) under tr-TR -> no case label matches -> throws
after : method.toUpperCase(Locale.ROOT) -> "RANDOM_PROJECTION" on every worker
What I verified in the source
VectorReduceFunction.eval(switch (method.toUpperCase(...)), line 61) is a real exact-matchswitch, so the TurkishRANDOM_PROJECTIONmangling genuinely breaks it. Reachable from SQL viaVECTOR_REDUCE(...).ModalityType.fromFileSuffixis called fromSrcField.determineModalityType(SrcField.java:62) for URL payloads without an explicit modality, and then compares againstfileExtensions.contains(...)(plainequals). Real defect for.GIF,.TIFF,.TIF,.AVI,.ICO,.DIB,.SGIstyle suffixes.DoubaoModel(line 389) builds thedata:<group>/<format>;base64,...MIME prefix fromModalityGroup.name().toLowerCase(...). Real defect for every IMAGE payload sent as binary.- The remaining sites (
BuiltinFunctions,AbstractModel.convertData,DataValidatorTransformConfigx2,ModalityType.ofName,PayloadFormat.ofName) are safe today and are correctly described as hardening. - Completeness: I grepped the PR head for bare
toUpperCase()/toLowerCase()undersrc/main. No match remains incalcite,nlpmodelorvalidator; the 13 remaining calls are all undersql/(#12495 scope). That agrees with the numbers in the description.
Compatibility: fully compatible. Locale.ROOT behaves exactly like the default locale on any non-Turkish/Azeri/Lithuanian JVM, so no existing job changes behaviour. On tr-TR workers the behaviour changes only from "broken" to "working". No option, default, SPI signature or serialized format changes.
Performance / side effects: none; same JDK call with an explicit locale.
Error handling / logging: unchanged.
Issues found (all Low, none blocking)
-
Low - the description counts five "reachable" sites, but two are not reachable in this repo today.
Location: PR description table;ModelInvocationCacheKey.java:145,ModalityType.java:103.
Problem: (a)ModalityType.supportsExtensionhas no caller insrc/main(only the new test calls it). (b) The cache key is built inModelInvocationRuntime.buildCacheKey, butAbstractModelconstructs the runtime with the single-argument constructor, which installsModelInvocationCache.NOOP(ModelInvocationRuntime.java:35-37), and there is no non-testModelInvocationCacheimplementation. Within one JVM every adapter also returns one constant provider string, so even a real cache would see one spelling per adapter.
Risk: none for the code change, which is still correct. The cache-key change does matter for an out-of-treeModelInvocationCacheshared between workers with different default locales, which is a reasonable thing to protect against.
Suggested fix: reword the table to say three production-reachable defects (VectorReduceFunction,ModalityType.fromFileSuffix,DoubaoModel), two latent ones (supportsExtensionpublic API, cache key with a pluggable cache) and six hardening sites. The tests can stay as they are. -
Low -
engine.close()is not in thefinallyblock.
Location:CalciteSQLEngineTest.java, newtestVectorReduceMethodIsLocaleIndependent.
Problem: if the assertion fails, the engine is not closed.
Suggested fix: moveengine.close()into thefinally(or use try-with-resources ifCalciteSQLEngineisAutoCloseable). Trivial.
2. Code quality
- Standards: change is minimal and uniform, imports are added in the right group, no new dependency. No new public method, so no extra Javadoc is required.
- Tests (stability rating: Stable): four tests are added to existing classes, which follows the project rule not to create new test classes casually. Each one sets
Locale.setDefault(tr-TR)and restores it in afinally.- Failing power: without the fix each test fails (
Unknown reduction method,data:prefix with a dotless i,.GIFfalling back toTEXT, differing cache keys), and the author's mutation run reports exactly these four failures. Locale.setDefaultis JVM-global, but the module's surefire run is sequential, the restore is infinally, andStringFunctionTest,NumericFunctionTest,FieldRenameTransformTestandTableRenameTransformTestalready use the same pattern.- No sleeps, ports or network.
- The cache-key test builds two keys with different capitalisation inside one JVM, which demonstrates the normalisation property rather than a production failure (see issue 1); it is still a valid guard.
- Failing power: without the fix each test fails (
- Docs: no user-visible option or behaviour change on default locales, so no
docs/en/docs/zhupdate is needed.
3. Architecture
- This is the precise fix for the whole class of problem (explicit locale at each call site) and it deliberately leaves the lint-rule guard to #12620, which is the right separation.
- Maintainability: once #12495 lands the module has zero bare locale-sensitive case conversions, which makes the later guard cheap.
- Historical compatibility: safe, as above.
4. Issue summary
| # | Severity | Location | Blocking | Summary |
|---|---|---|---|---|
| 1 | Low | PR description, ModelInvocationCacheKey.java:145, ModalityType.java:103 |
No | Two of the "reachable" sites are latent (NOOP cache, no caller of supportsExtension); reword |
| 2 | Low | CalciteSQLEngineTest.java (new test) |
No | Close the engine in finally |
5. Merge recommendation
Ready to merge. There are no blocking items.
- Merge state is
BLOCKEDonly for the missing approving review; the branch is 18 commits behinddevwithout conflicts (transform files changed ondevsince are outside the three packages touched here). - CI diagnosis (fork run
37567347336, head4bbe8b329): 82 jobs passed, 11 skipped, 1 failed. The failing job isall-connectors-it-7 (8, ubuntu-latest), with a single errorPostgresCDCIT.testPostgresCdcSnapshotOnlyAndCommittedOffsetStartupModes(ConditionTimeout, expected 1 but was 0 after 3 minutes). It is in a CDC connector module that this diff does not touch, so it is unrelated. The transform unit and integration jobs passed. A targeted re-run of just that job should clear the badge.
Thanks again for the careful work and the clear PR description.
…n the locale test
|
Thanks @DanielLeens, both taken. The first is a better test than mine. Issue 1, reachability. You are right, and I verified rather than taking it on trust:
The description now reads three production-reachable, two latent, six hardening, with callers named, and the summary table at the top is rewritten to match. That table is why this needed saying twice: my earlier correction fixed the lower section and left the summary claiming five, so the description contradicted itself again. Your test, whether a production caller exists at all, is strictly stronger than mine, which only asked what the converted token is compared with. Credited in the description. Both latent changes stay with their tests. The cache key is the one I would least like to drop: it matters only for an out-of-tree Issue 2, the unclosed engine. Fixed. Flagging rather than leaving you to notice: that makes mine the only try-with-resources in a file with 316 bare I checked my other three tests for the same mistake. They construct only Verified after the change: On CI, agreed: |
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @SEPURI-SAI-KRISHNA, thank you for taking both points from my last review so seriously, and for the very clear write-up in the description. I re-reviewed the PR at the new head d99a521 (11 files, 8 under src/main, 3 under src/test). This is static analysis only; I did not run the PR locally.
What problem does this PR solve
- Pain point: eleven
toUpperCase()/toLowerCase()calls inseatunnel-transforms-v2(calcite,nlpmodel,validator) follow the JVM default locale. Undertr-TR(oraz)iandIdo not round-trip, so tokens later matched withequals,containsor aswitchstop matching. - Approach: every site now passes
Locale.ROOT, plus four regression tests that switch the default locale totr-TRinside atry/finally. - In one sentence: a mechanical, locale-independent case conversion for the remaining sites of the defect class fixed for
sql/in #12495.
1. Code change review
What changed since my last review. The only new commit, d99a521, touches CalciteSQLEngineTest and moves the engine into try-with-resources, which closes my issue 2 (the engine was not closed when an assertion failed). The description now reads three production-reachable defects, two latent, six hardening, with the callers named, which closes my issue 1. CalciteSQLEngine is AutoCloseable, so try-with-resources is fine; keeping it is better than a trailing close(), and I would not convert it back for uniformity.
What I re-verified on the new head
- The diff is exactly the eleven call sites, each now
Locale.ROOTwithjava.util.Localeimported; nothing else insrc/mainchanged. git grep -E "toUpperCase\(\)|toLowerCase\(\)"overcalcite,nlpmodelandvalidatorreturns no match on the PR head, and also none on the currentdevhead0278a6a(the newerGetJsonObjectFunctionfrom #12666 has no bare conversions). The 13 remaining bare calls inseatunnel-transforms-v2/src/mainare all undersql/, which is #12495's scope, so the two PRs together do take the module to zero.- Reachability, from my first pass and unchanged:
VectorReduceFunction.eval(exact-matchswitch),ModalityType.fromFileSuffix(viaSrcField) andDoubaoModel(MIME prefix) are real defects on a Turkish or Azeri default locale. The other sites are latent or hardening and are labelled that way.
Compatibility: fully compatible. Locale.ROOT behaves like the default locale on every non-Turkish/Azeri/Lithuanian JVM, so no existing job changes. On tr-TR workers the behaviour changes only from broken to working. No option, default, SPI or serialized format changes.
Performance and side effects: none (same JDK call with an explicit locale).
Error handling and logging: unchanged.
Issues: none.
2. Code quality
- Standards: minimal, uniform change, imports in the right group, no new dependency.
- Tests: four tests added to three existing classes. Stability rating: Stable.
Locale.setDefaultis JVM-global, but each test restores it infinally, the module's other locale tests use the same pattern, and there are no sleeps, ports or network. Failing power: reverting the conversions makesVECTOR_REDUCEthrowUnknown reduction method, the base64 prefix carries a dotless i,.GIFfalls back toTEXT, and the two cache keys differ. The cache-key test demonstrates the normalisation property inside one JVM rather than a production failure, which the description says openly. - Docs: no user-visible option or default-locale behaviour change, so no
docs/en/docs/zhupdate is needed.
3. Architecture
A precise fix for the whole class of problem, with the lint-rule guard deliberately left to #12620. Maintainability is good: once this and #12495 land, the module has no bare locale-sensitive conversions. Historical compatibility is safe.
4. Issue summary
No open issues.
5. Merge recommendation
Conclusion: Ready to merge
- Blockers: none. The two Low items from my previous round are closed.
- Non-blocking: none.
- CI diagnosis: the fork run for this head (
37876760814) is fully green: 83 jobs passed, 11 skipped by design, 0 failed, and the apache-sideBuildcheck isSUCCESS. The earlier redall-connectors-it-7(PostgresCDCIT, #11847) did not recur. The branch is 43 commits behinddevand diverged, with no conflict; the only remaining gate is the required approving review from a committer. - Other reviewers: nobody else has submitted a review yet (@SEZ9 has commented and planned a review pass once the branch was refreshed). Note that I am a read-only reviewer, so my earlier
APPROVEDentry (at4bbe8b3, before the test-only commit) does not satisfy the merge rule; a maintainer with write access still needs to give the final approval.
Thanks again for the careful work and the honest description.
Purpose of this pull request
Closes #12617.
Eleven call sites in
seatunnel-transforms-v2convert case without aLocale, so they follow the worker's default locale. Undertr-TRthe letteridoes not round trip:"if".toUpperCase()is"İF"and"GIF".toLowerCase()is"gıf".Same defect class as #12496, fixed for the
sqlsubtree by #12495. This covers the remaining sites, incalcite,nlpmodelandvalidator, which @DanielLeens asked for as a separate PR in his #12495 review. Every site becomestoUpperCase(Locale.ROOT)ortoLowerCase(Locale.ROOT).The eleven sites split three ways, and the section "Reachable defects vs hardening" below sets
out how that split was arrived at, including a correction. Three are reachable defects with a
production caller, two are latent, and six are hardening. Each of the first five has a test
that fails without the fix; the two latent ones fail it because the test calls the API directly,
which is also why they were mis-filed as reachable in an earlier version of this description.
Reachable, with a production caller:
tr-TRcalcite/udf/VectorReduceFunction.java:60VECTOR_REDUCE(vec, 2, 'random_projection')throwsUnknown reduction method. The upper-casing exists precisely so a lower-case method resolves.nlpmodel/embedding/multimodal/ModalityType.java:78SrcField.java:62. A URL ending.GIF,.TIF,.AVI,.ICO,.DIBor.SGIis not detected and falls back toTEXT, so an image is embedded as text.nlpmodel/embedding/remote/doubao/DoubaoModel.java:388data:ımage/png;base64,....ModalityGroup.IMAGEis a shipped constant, so no unusual input is needed.Latent: the change is correct, but nothing in this repo reaches it:
ModalityType.java:102supportsExtension("TIF")and("AVI")returnfalseundertr-TR, but the method has no caller in anysrc/main; it is a public API only the new test exercises.nlpmodel/ModelInvocationCacheKey.java:144tr-TRthe key carriesprovider=openaı,modality=ımageandformat=bınary, so two equivalent configurations produce two keys. It only matters for an out-of-treeModelInvocationCache:AbstractModel:46installsModelInvocationCache.NOOP, whosegetreturns empty andputdoes nothing.Six sites are hardening, the same pattern but with no path to a wrong result even on an
affected locale. I am changing them for uniformity rather than because they are broken, and would
rather say so than present eleven fixes as eleven bugs:
calcite/udf/BuiltinFunctions.java:54. None of the 12 shipped UDF names are altered by a TurkishtoUpperCase(), because they are already upper case. Only a third-partyCalciteUdfwhosefunctionName()carries a lower-caseiwould register under a mangled key.ModalityType.java:60andnlpmodel/embedding/multimodal/PayloadFormat.java:40. Both feedequalsIgnoreCase, which still matches a dotlessi, so the conversion is redundant rather than wrong.validator/DataValidatorTransformConfig.java:168and:336, andnlpmodel/llm/remote/AbstractModel.java:123. Their tokens areNOT_NULL,RANGE,LENGTH,REGEX,UDF,true,1,yesandfalse, none of which carry ani. Each is oneUNIQUEorIN_LISTcase label away from breaking silently.Happy to drop the hardening group if a reviewer would rather keep the diff to the three reachable sites, or to delete the two redundant
toLowerCase()calls that feedequalsIgnoreCaseinstead of qualifying them. I kept one kind of change throughout so the diff stays mechanical.The lint rule @DanielLeens also suggested is deliberately not here. SeaTunnel has no Checkstyle or forbidden-apis today, so a guard means either a new build plugin or a
tools/checker wired intobackend.yml. That is a CI decision which should not gate a bug fix, and I will raise it separately.Does this PR introduce any user-facing change?
No new option, default, signature or format. Behaviour is unchanged on any default locale whose case rules match ASCII, which is why the 1224 pre-existing tests pass untouched. On a worker whose default locale is Turkish or Azeri, the three reachable sites above stop misbehaving, and the two latent ones stop being able to.
How was this patch tested?
Four tests added to three existing classes, following the pattern already used in #12495: save
Locale.getDefault(), settr-TR, restore in afinally.CalciteSQLEngineTest.testVectorReduceMethodIsLocaleIndependentDoubaoMultimodalModelTest.testBinaryBase64MimeTypeIsLocaleIndependentDoubaoMultimodalModelTest.testFileSuffixModalityDetectionIsLocaleIndependent, which also coverssupportsExtensionModelInvocationCacheKeyTest.keyIsStableAcrossSpellingsUnderAnyDefaultLocaleFull module:
Tests run: 1228, Failures: 0, Errors: 0, Skipped: 0.Mutation check, re-run against the current 1228-test module rather than carried over: reverting all eleven sites to the bare calls gives
Tests run: 1228, Failures: 3, Errors: 1and fails exactly these four, nothing else:That no pre-existing test fails on the revert is the point: this class of bug is invisible to the current suite.
spotless:checkpasses. No E2E test covers these paths, and none is added, since the defect is a JVM default-locale property that a container test would not vary.Reachable defects vs hardening
Correcting this section a second time, and crediting @DanielLeens for the test that got it right. The summary above now matches it.
It first contradicted the table higher up. I then rewrote it around what the converted token is
compared with:
equalsIgnoreCasefoldsi,Iandıtogether and is safe, whileList.contains,String.equalsand aswitchare not. That classification gave five reachablesites and it is still the right rule, but it is not sufficient. The stricter question is whether a
production caller exists at all, and on that test two of my five are not reachable in this
repo. Both verified rather than taken on trust:
ModalityType.supportsExtension(:102) has no caller in anysrc/mainrepo-wide. A grepreturns only its own declaration; the two assertions in the new test are its only callers.
ModelInvocationCacheKey(:144) is reached fromModelInvocationRuntime.buildCacheKey(
:127), butAbstractModel(:46) builds the runtime with the single-argument constructor,which installs
ModelInvocationCache.NOOP. The only implementation of that interface undersrc/mainisNoopModelInvocationCache, whosegetreturns empty and whoseputdoesnothing, so a mangled key has no observable effect in-tree.
So the honest split is three production-reachable defects, two latent, and six hardening
changes. The mechanism below is measured under
tr_TR:Reachable today, with a production caller:
VectorReduceFunction:60:switch (method.toUpperCase(...))againstcase "RANDOM_PROJECTION", reached from SQL viaVECTOR_REDUCE(...). An exact match, so the mangled form falls through.ModalityType:78(fromFileSuffix), reached fromSrcField.java:62for URL payloads with no explicit modality. It resolves throughfileExtensions.contains(...), which isString.equalsper element, sogifandgıfdo not match.DoubaoModel:388, which builds thedata:<group>/<format>;base64,...prefix, so an IMAGE payload goes out asdata:ımage/png.ModalityGroup.IMAGEis a shipped constant, so no unusual input is needed.Latent: correct to fix, no in-tree path:
ModalityType:102(supportsExtension), a public API with no caller yet.ModelInvocationCacheKey:144, which matters only for an out-of-treeModelInvocationCacheshared between workers whose default locales differ. That is worth protecting against, which is why the change and its test stay.Hardening only:
ModalityType:60(ofName) andPayloadFormat:40, both feedingequalsIgnoreCase(callers atSrcFieldSpec.java:76,:80and:87), so the conversion is redundant rather than wrong.BuiltinFunctions:54: all twelve shipped Calcite UDF names are already upper case and none is altered by a TurkishtoUpperCase.AbstractModel:123,DataValidatorTransformConfig:168and:336: their tokens areNOT_NULL,RANGE,LENGTH,REGEX,UDF,true,1,yesandfalse, none carrying ani. Each is oneUNIQUEorIN_LISTcase label away from breaking silently.The four tests cover all three reachable sites and both latent ones:
CalciteSQLEngineTest.testVectorReduceMethodIsLocaleIndependent,DoubaoMultimodalModelTest.testFileSuffixModalityDetectionIsLocaleIndependent(which also assertssupportsExtension("TIF")and("AVI")directly),DoubaoMultimodalModelTest.testBinaryBase64MimeTypeIsLocaleIndependent, andModelInvocationCacheKeyTest.keyIsStableAcrossSpellingsUnderAnyDefaultLocale.The hardening sites are included so the module does not keep a mixed convention that the next
reader has to re-derive.
Completeness of the eleven sites
Per @SEZ9's request, the scan that establishes these eleven are the whole set in the three modules, run on the merged head:
So after this change there is no
toUpperCaseortoLowerCasecall without an explicitLocaleleft incalcite,nlpmodelorvalidator. All eleven now readLocale.ROOT:src/mainfiles scannedcalciteudf/BuiltinFunctions:55,udf/VectorReduceFunction:61nlpmodelModelInvocationCacheKey:145,embedding/multimodal/ModalityType:61,79,103,embedding/multimodal/PayloadFormat:42,embedding/remote/doubao/DoubaoModel:389,llm/remote/AbstractModel:124validatorDataValidatorTransformConfig:169,337For the starting point #12620 asked for, the same scan across all 228
src/mainfiles ofseatunnel-transforms-v2returns 13 remaining bare calls, every one undersql/:Those are #12495's scope, not this PR's. 13 plus the 11 here is 24, which matches the baseline enumerated on #12620, so the two PRs together take the module to zero.
Line numbers above are as of the merged head. Five of the
sql/sites moved relative to the #12620 table (ZetaSQLFunction459/687/707 to 464/696/716,ZetaSQLType570 to 572,VectorFunction270 to 272) because #12403 and #12335 landed in that package in the meantime. The call sites themselves are unchanged.