Skip to content

[Fix][Transform-V2] Make calcite, nlpmodel and validator case conversion locale independent - #12618

Merged
nzw921rx merged 3 commits into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-transform-locale-remaining
Oct 12, 2026
Merged

nzw921rx merged 3 commits into
apache:devfrom
SEPURI-SAI-KRISHNA:fix-transform-locale-remaining

Conversation

@SEPURI-SAI-KRISHNA

@SEPURI-SAI-KRISHNA SEPURI-SAI-KRISHNA commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Purpose of this pull request

Closes #12617.

Eleven call sites in seatunnel-transforms-v2 convert case without a Locale, so they follow the worker's default locale. Under tr-TR the letter i does not round trip: "if".toUpperCase() is "İF" and "GIF".toLowerCase() is "gıf".

Same defect class as #12496, fixed for the sql subtree by #12495. This covers the remaining sites, in calcite, nlpmodel and validator, which @DanielLeens asked for as a separate PR in his #12495 review. Every site becomes toUpperCase(Locale.ROOT) or toLowerCase(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:

Site Effect under tr-TR
calcite/udf/VectorReduceFunction.java:60 VECTOR_REDUCE(vec, 2, 'random_projection') throws Unknown reduction method. The upper-casing exists precisely so a lower-case method resolves.
nlpmodel/embedding/multimodal/ModalityType.java:78 Reached from SrcField.java:62. A URL ending .GIF, .TIF, .AVI, .ICO, .DIB or .SGI is not detected and falls back to TEXT, so an image is embedded as text.
nlpmodel/embedding/remote/doubao/DoubaoModel.java:388 The base64 payload goes out as data:ımage/png;base64,.... ModalityGroup.IMAGE is a shipped constant, so no unusual input is needed.

Latent: the change is correct, but nothing in this repo reaches it:

Site Why it is latent
ModalityType.java:102 supportsExtension("TIF") and ("AVI") return false under tr-TR, but the method has no caller in any src/main; it is a public API only the new test exercises.
nlpmodel/ModelInvocationCacheKey.java:144 Under tr-TR the key carries provider=openaı, modality=ımage and format=bınary, so two equivalent configurations produce two keys. It only matters for an out-of-tree ModelInvocationCache: AbstractModel:46 installs ModelInvocationCache.NOOP, whose get returns empty and put does 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 Turkish toUpperCase(), because they are already upper case. Only a third-party CalciteUdf whose functionName() carries a lower-case i would register under a mangled key.
  • ModalityType.java:60 and nlpmodel/embedding/multimodal/PayloadFormat.java:40. Both feed equalsIgnoreCase, which still matches a dotless i, so the conversion is redundant rather than wrong.
  • validator/DataValidatorTransformConfig.java:168 and :336, and nlpmodel/llm/remote/AbstractModel.java:123. Their tokens are NOT_NULL, RANGE, LENGTH, REGEX, UDF, true, 1, yes and false, none of which carry an i. Each is one UNIQUE or IN_LIST case 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 feed equalsIgnoreCase instead 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 into backend.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(), set tr-TR, restore in a finally.

  • CalciteSQLEngineTest.testVectorReduceMethodIsLocaleIndependent
  • DoubaoMultimodalModelTest.testBinaryBase64MimeTypeIsLocaleIndependent
  • DoubaoMultimodalModelTest.testFileSuffixModalityDetectionIsLocaleIndependent, which also covers supportsExtension
  • ModelInvocationCacheKeyTest.keyIsStableAcrossSpellingsUnderAnyDefaultLocale

Full 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: 1 and fails exactly these four, nothing else:

DoubaoMultimodalModelTest.testBinaryBase64MimeTypeIsLocaleIndependent
  MIME type must not depend on the default locale, but was: data:ımage/png;base64,bW
DoubaoMultimodalModelTest.testFileSuffixModalityDetectionIsLocaleIndependent
  expected: <ModalityType.GIF(name=gif, ...)> but was: <ModalityType.TEXT(name=text, ...)>
ModelInvocationCacheKeyTest.keyIsStableAcrossSpellingsUnderAnyDefaultLocale
  expected: <...provider=openaı|...|modality=ımage|format=bınary|...>
       but was: <...provider=openai|...|modality=image|format=binary|...>
CalciteSQLEngineTest.testVectorReduceMethodIsLocaleIndependent » Transform

That no pre-existing test fails on the revert is the point: this class of bug is invisible to the current suite.

spotless:check passes. 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
: equalsIgnoreCase folds i, I and ı together and is safe, while
List.contains, String.equals and a switch are not. That classification gave five reachable
sites 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 any src/main repo-wide. A grep
    returns only its own declaration; the two assertions in the new test are its only callers.
  • ModelInvocationCacheKey (:144) is reached from ModelInvocationRuntime.buildCacheKey
    (:127), but AbstractModel (:46) builds the runtime with the single-argument constructor,
    which installs ModelInvocationCache.NOOP. The only implementation of that interface under
    src/main is NoopModelInvocationCache, whose get returns empty and whose put does
    nothing, 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:

"image".equalsIgnoreCase("ımage")             = true    absorbs the dotless i
List.of("gif").contains(".GIF".toLowerCase())      = false   does not
"random_projection".toUpperCase()                  = RANDOM_PROJECTİON
"IMAGE".toLowerCase() + "/png"                     = ımage/png

Reachable today, with a production caller:

  • VectorReduceFunction:60: switch (method.toUpperCase(...)) against case "RANDOM_PROJECTION", reached from SQL via VECTOR_REDUCE(...). An exact match, so the mangled form falls through.
  • ModalityType:78 (fromFileSuffix), reached from SrcField.java:62 for URL payloads with no explicit modality. It resolves through fileExtensions.contains(...), which is String.equals per element, so gif and gıf do not match.
  • DoubaoModel:388, which builds the data:<group>/<format>;base64,... prefix, so an IMAGE payload goes out as data:ımage/png. ModalityGroup.IMAGE is 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-tree ModelInvocationCache shared 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) and PayloadFormat:40, both feeding equalsIgnoreCase (callers at SrcFieldSpec.java:76, :80 and :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 Turkish toUpperCase.
  • AbstractModel:123, DataValidatorTransformConfig:168 and :336: their tokens are NOT_NULL, RANGE, LENGTH, REGEX, UDF, true, 1, yes and false, none carrying an i. Each is one UNIQUE or IN_LIST case label away from breaking silently.

The four tests cover all three reachable sites and both latent ones:
CalciteSQLEngineTest.testVectorReduceMethodIsLocaleIndependent,
DoubaoMultimodalModelTest.testFileSuffixModalityDetectionIsLocaleIndependent (which also asserts
supportsExtension("TIF") and ("AVI") directly),
DoubaoMultimodalModelTest.testBinaryBase64MimeTypeIsLocaleIndependent, and
ModelInvocationCacheKeyTest.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:

$ git grep -nE "toUpperCase\(\)|toLowerCase\(\)" -- \
    seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/{calcite,nlpmodel,validator}
(no matches)

So after this change there is no toUpperCase or toLowerCase call without an explicit Locale left in calcite, nlpmodel or validator. All eleven now read Locale.ROOT:

module sites src/main files scanned
calcite udf/BuiltinFunctions:55, udf/VectorReduceFunction:61 27
nlpmodel ModelInvocationCacheKey:145, embedding/multimodal/ModalityType:61,79,103, embedding/multimodal/PayloadFormat:42, embedding/remote/doubao/DoubaoModel:389, llm/remote/AbstractModel:124 41
validator DataValidatorTransformConfig:169,337 15

For the starting point #12620 asked for, the same scan across all 228 src/main files of seatunnel-transforms-v2 returns 13 remaining bare calls, every one under sql/:

sql/SQLTransform.java:84
sql/zeta/ZetaSQLFunction.java:464, :696, :716
sql/zeta/ZetaSQLType.java:323, :572
sql/zeta/functions/CastFunction.java:93
sql/zeta/functions/DateTimeFunction.java:70, :185, :264, :384
sql/zeta/functions/SystemFunction.java:275
sql/zeta/functions/VectorFunction.java:272

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 (ZetaSQLFunction 459/687/707 to 464/696/716, ZetaSQLType 570 to 572, VectorFunction 270 to 272) because #12403 and #12335 landed in that package in the meantime. The call sites themselves are unchanged.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

The Build check is red. I went through every failing job on run 37140738764 (head 48599a8f6), and none of the three failures is in code this PR touches. The diff is confined to calcite, nlpmodel and validator plus their unit tests.

Run totals: 94 jobs, 79 successful, 11 skipped, 3 failed, 1 cancelled.

job result already tracked as
transform-v2-it-part-1 219 tests, 1 failure #12116, fix #12216
engine-v2-it (11) 197 tests, 1 failure #12313 and #12316
paimon-connector-it (8) 65 tests, 1 failure #11679, fix #11727
Build website cancelled at the 90 minute timeout #12613, fix #12614

The detail on each:

transform-v2-it-part-1. TestFilterRowKindIT.testFilterRowKindMultiTable{TestContainer}[2], expected: <0> but was: <1>. Container 2 is Flink, and the job config filter_row_kind_exclude_insert_multi_table.conf uses an Assert sink with MIN_ROW and MAX_ROW rules across three tables. That is exactly the shape #12116 describes, where AssertSinkWriter evaluates JVM-wide static counters per subtask close().

engine-v2-it (11). BackpressureSlowSinkIT.testCheckpointsKeepCompletingUnderSustainedBackpressure. The test was added on 2026-09-10 in #12107 and #12313 is open specifically to make its barrier injection deterministic, with #12316 as the underlying fix.

paimon-connector-it (8). PaimonWithS3IT.privilegeEnabledPaimonSourceUnAuthorized failed with "Job did not return within 5 minutes". A job cancelled by a downstream privilege check hanging the client is #11679, and the 5 minute bound that turns the hang into a fast failure came from #11718.

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 dev once any of them land if you would prefer a green badge before review.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

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 37140738764 (head 48599a8f6) and every failure is an already-tracked issue, none of them reachable from this diff.

job failing test tracked as
transform-v2-it-part-1 (11) TestFilterRowKindIT.testFilterRowKindMultiTable #12116
engine-v2-it (11) BackpressureSlowSinkIT.testCheckpointsKeepCompletingUnderSustainedBackpressure #12313 / #12316
paimon-connector-it (8) PaimonWithS3IT.privilegeEnabledPaimonSourceUnAuthorized #11679

A few details worth stating rather than asserting "flaky":

On whether this diff could cause any of them: every src/main change in this PR is X.toUpperCase() to X.toUpperCase(Locale.ROOT) or the toLowerCase equivalent, plus the java.util.Locale import. 11 call sites, no other statement changed. On a runner whose default locale is not Turkish, Azerbaijani or Lithuanian, those calls return identical values, so the change is a no-op at runtime on CI and cannot affect a row count, a checkpoint or an S3 privilege check.

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.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

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 dev af80a6704 and holds implementation until this PR and #12495 have both landed, so the rule is evaluated against the post-fix module rather than failing on sites these two already fix.

@SEZ9

SEZ9 commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

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 dev af80a6704, makes sense to me. Nothing further needed on that here; we can continue the guard discussion on #12620.

On the red Build for run 37140738764 (head 48599a8f6): your breakdown is convincing. The three failing integration tests (TestFilterRowKindIT, BackpressureSlowSinkIT, PaimonWithS3IT) each map to an already-tracked issue, and I agree that swapping toUpperCase() / toLowerCase for the Locale.ROOT overloads cannot change a row count, a checkpoint, or an S3 privilege check on a non-Turkish/Azerbaijani/Lithuanian runner. No need for a blind rerun.

What I would still like before merging:

  1. A rebase onto current dev to pick up whatever has landed since 48599a8f6. If the Flink leg of transform-v2-it-part-1 fails again with the same expected: <0> but was: <1> signature in TestFilterRowKindIT, I am fine treating that as the known issue and not blocking on it.
  2. A quick confirmation that the 11 src/main call sites are the complete set in calcite, nlpmodel and validator, i.e. no toUpperCase() / toLowerCase call without a Locale remains in those three modules after this change. A one-line grep result in the PR description is enough, and it gives [Improve][Transform-V2] Define the locale-independence contract for case conversion in seatunnel-transforms-v2 #12620 its starting point.

Once the rebase is pushed I will do the review pass on the diff itself.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

Both asks are done, @SEZ9.

1. Refreshed onto current dev. New head 4bbe8b329, now zero commits behind. I did this by merging upstream/dev rather than a true rebase, so the existing review anchors on the PR are preserved; say the word if you would rather have linear history and I will rebase and force push instead.

Nothing conflicted. Of the 13 seatunnel-transforms-v2 files touched on dev since the old base 309b15eff, every one is under metadata/ or sql/zeta/, and this PR touches only calcite, nlpmodel and validator, so there is no intersection at all. seatunnel-transforms-v2 is green on the merged head: Tests run: 1228, Failures: 0, Errors: 0, and spotless:check passes.

2. The eleven are the complete set. Added to the PR description, and the scan on the new head is:

$ git grep -nE "toUpperCase\(\)|toLowerCase\(\)" -- \
    seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/{calcite,nlpmodel,validator}
(no matches)

83 src/main files across the three modules (27 calcite, 41 nlpmodel, 15 validator), and every one of the eleven now reads Locale.ROOT.

For the #12620 starting point you asked for: the same scan over all 228 src/main files of the module returns 13 remaining bare calls on this branch, every one under sql/, which is #12495's scope. 13 plus 11 is 24, matching the baseline enumerated on #12620, so the two PRs together take the module to zero.

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 37140738764 on the same head 48599a8f6: transform-v2-it-part-1 (11) and paimon-connector-it (8) both went green, so TestFilterRowKindIT (#12116) and PaimonWithS3IT (#11679) did not recur. The only remaining failure was engine-v2-it (11), on BackpressureSlowSinkIT.testCheckpointsKeepCompletingUnderSustainedBackpressure, 197 tests with 1 failure and no runner shutdown signal in the log, so a genuine recurrence of #12313 / #12316 rather than infrastructure. Build website was cancelled at the 90 minute limit again, which #12614 addresses.

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.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

Heads up on the red Build before you start the review pass: it is one unrelated job, not the diff.

The failing leg is all-connectors-it-7 (8, ubuntu-latest). Its only error is:

PostgresCDCIT.testPostgresCdcSnapshotOnlyAndCommittedOffsetStartupModes:625 » ConditionTimeout
org.awaitility.core.ConditionTimeoutException: expected: <1> but was: <0> within 3 minutes

That is the test named in open issue #11847. It is not a job timeout either: all-connectors-it-7 is configured timeout-minutes: 150 and the leg ran 80 minutes, so it failed on the assertion rather than being cut off.

This PR changes 11 files, 8 under src/main and 3 under src/test, all in seatunnel-transforms-v2, and none in any connector or CDC module. PostgresCDCIT cannot reach the change. Every other job in the run passed.

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 DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in seatunnel-transforms-v2 (calcite, nlpmodel, validator) use the JVM default locale. On a worker running under tr-TR (or az), i and I do not round-trip, so tokens that are later compared with equals, List.contains or a switch stop matching.
  • Approach: every site now passes Locale.ROOT, plus four regression tests that switch the default locale to tr-TR in a try/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-match switch, so the Turkish RANDOM_PROJECTION mangling genuinely breaks it. Reachable from SQL via VECTOR_REDUCE(...).
  • ModalityType.fromFileSuffix is called from SrcField.determineModalityType (SrcField.java:62) for URL payloads without an explicit modality, and then compares against fileExtensions.contains(...) (plain equals). Real defect for .GIF, .TIFF, .TIF, .AVI, .ICO, .DIB, .SGI style suffixes.
  • DoubaoModel (line 389) builds the data:<group>/<format>;base64,... MIME prefix from ModalityGroup.name().toLowerCase(...). Real defect for every IMAGE payload sent as binary.
  • The remaining sites (BuiltinFunctions, AbstractModel.convertData, DataValidatorTransformConfig x2, ModalityType.ofName, PayloadFormat.ofName) are safe today and are correctly described as hardening.
  • Completeness: I grepped the PR head for bare toUpperCase() / toLowerCase() under src/main. No match remains in calcite, nlpmodel or validator; the 13 remaining calls are all under sql/ (#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)

  1. 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.supportsExtension has no caller in src/main (only the new test calls it). (b) The cache key is built in ModelInvocationRuntime.buildCacheKey, but AbstractModel constructs the runtime with the single-argument constructor, which installs ModelInvocationCache.NOOP (ModelInvocationRuntime.java:35-37), and there is no non-test ModelInvocationCache implementation. 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-tree ModelInvocationCache shared 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 (supportsExtension public API, cache key with a pluggable cache) and six hardening sites. The tests can stay as they are.

  2. Low - engine.close() is not in the finally block.
    Location: CalciteSQLEngineTest.java, new testVectorReduceMethodIsLocaleIndependent.
    Problem: if the assertion fails, the engine is not closed.
    Suggested fix: move engine.close() into the finally (or use try-with-resources if CalciteSQLEngine is AutoCloseable). 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 a finally.
    • Failing power: without the fix each test fails (Unknown reduction method, data: prefix with a dotless i, .GIF falling back to TEXT, differing cache keys), and the author's mutation run reports exactly these four failures.
    • Locale.setDefault is JVM-global, but the module's surefire run is sequential, the restore is in finally, and StringFunctionTest, NumericFunctionTest, FieldRenameTransformTest and TableRenameTransformTest already 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.
  • Docs: no user-visible option or behaviour change on default locales, so no docs/en / docs/zh update 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 BLOCKED only for the missing approving review; the branch is 18 commits behind dev without conflicts (transform files changed on dev since are outside the three packages touched here).
  • CI diagnosis (fork run 37567347336, head 4bbe8b329): 82 jobs passed, 11 skipped, 1 failed. The failing job is all-connectors-it-7 (8, ubuntu-latest), with a single error PostgresCDCIT.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.

@SEPURI-SAI-KRISHNA

Copy link
Copy Markdown
Collaborator Author

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:

  • ModalityType.supportsExtension has no caller in any src/main repo-wide. A grep returns only its own declaration; the two assertions in my test are its only callers.
  • ModelInvocationCacheKey is reached from ModelInvocationRuntime.buildCacheKey:127, but AbstractModel:46 uses the single-argument new ModelInvocationRuntime(options), which installs ModelInvocationCache.NOOP. The only implementation under src/main is NoopModelInvocationCache, whose get returns empty and put does nothing, so a mangled key has no observable effect in-tree.

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 ModelInvocationCache shared across workers with differing default locales, which is worth protecting against.

Issue 2, the unclosed engine. Fixed. CalciteSQLEngine is AutoCloseable, so the test now wraps it in try-with-resources inside the locale block instead of calling close() as the last statement of the try.

Flagging rather than leaving you to notice: that makes mine the only try-with-resources in a file with 316 bare engine.close() calls. Happy to use a plain finally if you would rather the file stayed uniform. Your call.

I checked my other three tests for the same mistake. They construct only HashMap, VectorFieldSpec, SrcField and MultimodalFieldValue, none closeable, so it was isolated to the calcite one.

Verified after the change: CalciteSQLEngineTest 325 tests 0F 0E; full module 1228 tests 0F 0E; reverting all eleven sites still fails exactly those four tests and nothing else, re-run against the current module rather than carried over; spotless clean.

On CI, agreed: all-connectors-it-7 (8) is PostgresCDCIT, the known #11847 flake in a CDC module this diff does not touch.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in seatunnel-transforms-v2 (calcite, nlpmodel, validator) follow the JVM default locale. Under tr-TR (or az) i and I do not round-trip, so tokens later matched with equals, contains or a switch stop matching.
  • Approach: every site now passes Locale.ROOT, plus four regression tests that switch the default locale to tr-TR inside a try/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.ROOT with java.util.Locale imported; nothing else in src/main changed.
  • git grep -E "toUpperCase\(\)|toLowerCase\(\)" over calcite, nlpmodel and validator returns no match on the PR head, and also none on the current dev head 0278a6a (the newer GetJsonObjectFunction from #12666 has no bare conversions). The 13 remaining bare calls in seatunnel-transforms-v2/src/main are all under sql/, 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-match switch), ModalityType.fromFileSuffix (via SrcField) and DoubaoModel (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.setDefault is JVM-global, but each test restores it in finally, the module's other locale tests use the same pattern, and there are no sleeps, ports or network. Failing power: reverting the conversions makes VECTOR_REDUCE throw Unknown reduction method, the base64 prefix carries a dotless i, .GIF falls back to TEXT, 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/zh update 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-side Build check is SUCCESS. The earlier red all-connectors-it-7 (PostgresCDCIT, #11847) did not recur. The branch is 43 commits behind dev and 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 APPROVED entry (at 4bbe8b3, 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.

@nzw921rx nzw921rx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Transform-V2] Case conversion in calcite, nlpmodel and validator depends on the worker default locale

4 participants