Repository navigation
[Fix][Transform-V2] Make rename transform case conversion locale independent - #11994
Conversation
…pendent TableRenameTransform.convertCase and FieldRenameTransform.convertCase called String.toUpperCase()/toLowerCase() without an explicit locale, so convert_case=UPPER/LOWER produced different output under e.g. the Turkish locale (dotless i). Use Locale.ROOT for deterministic SQL-style case conversion, matching the fix for the SQL lower/upper functions.
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
FieldRenameTransform and TableRenameTransform both implement a convert_case option (UPPER/LOWER) that renames fields/tables using String.toUpperCase() / String.toLowerCase() with no explicit Locale. Those no-arg overloads silently use Locale.getDefault(), which is the classic "Turkish locale bug": on a JVM whose default locale is tr, az, or lt, "i".toUpperCase() produces "İ" (U+0130, dotted capital I) instead of "I", and "I".toLowerCase() produces a dotless "ı" instead of "i". This PR pins both call sites to Locale.ROOT so the rename output is deterministic and independent of the JVM/host locale, and adds a regression test that flips Locale.setDefault() to tr-TR to prove it.
1. Code Change Review
1.1 Core Logic Analysis
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/FieldRenameTransform.java:167-172— insideconvertName(String):case UPPER: name = name.toUpperCase(Locale.ROOT); // was: name.toUpperCase() break; case LOWER: name = name.toLowerCase(Locale.ROOT); // was: name.toLowerCase() break;
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/TableRenameTransform.java:152-155— insideconvertCase(String):case UPPER: return name.toUpperCase(Locale.ROOT); // was: return name.toUpperCase(); case LOWER: return name.toLowerCase(Locale.ROOT); // was: return name.toLowerCase();
Normal-path confirmation: this is not a boundary/recovery path. TableRenameTransform.convertCase() is invoked from transformTableIdentifier() (called for every schema resolution) and from convertName(), which is on the hot per-row/per-schema-change path (transformRow/mapSchemaChangeEvent both route through it whenever convert_case is configured). FieldRenameTransform.convertName() is likewise invoked from transformTableSchema() and mapSchemaChangeEvent(). Any job that sets convert_case: UPPER|LOWER on either transform hits this code on every run, so the fix is on the primary execution path, not an edge case.
Key Findings
- Both of the only two case-conversion call sites for this feature are fixed consistently with
Locale.ROOT(verified viagrep -rn "convertCase\|ConvertCase"across therenamepackage — no other call site exists). Locale.ROOTis the correct choice here (notLocale.ENGLISH, which is a real-but-slightly-different locale that could itself pick up future JDK per-locale ICU changes;Locale.ROOTis the base locale explicitly designed for locale-insensitive operations).- I checked the rest of
seatunnel-transforms-v2for the same anti-pattern (toUpperCase()/toLowerCase()withoutLocale). There are other call sites (e.g.zeta/functions/*,SQLTransform.java:83,ZetaSQLFunction.java), but those all operate on fixed ASCII keyword/function-name tokens ("UPPER","ENGINE", SQL type names, etc.) defined by the engine itself, not on arbitrary user data — they are not exposed to the same Turkish-ifailure mode in any realistic case and are out of scope for this fix. No hidden second instance of this exact bug was missed within the rename transforms.
1.2 Compatibility Impact
Classification: Fully compatible for the overwhelming majority of deployments; Partially incompatible only for a narrow locale-specific edge case.
- For any JVM running under
en,C/POSIX, or most other locales,toUpperCase()andtoUpperCase(Locale.ROOT)produce byte-identical output for ASCII input, so there is no observable behavior change for essentially all existing configs and pipelines. - The only environments where output changes are those whose JVM default locale is Turkish (
tr), Azerbaijani (az), or Lithuanian (lt) and whose table/field names contain the letteri/I/İ/ı. For those deployments, this PR changes the previously-buggy (locale-corrupted) output to the correct, expected output. That is a behavior change from the user's point of view even though it is a bug fix, and it could affect a running job's downstream sink table/column naming if it is resumed from an old checkpoint/savepoint or if a Sink DDL was already created under the old, mis-cased name. This is a genuinely narrow blast radius, but per the project's compatibility rule it is worth an explicit mention in the PR description (a one-line note that Turkish/Azerbaijani/Lithuanian-locale users may see a different table/column name after upgrading) rather than being silently folded into a routine bugfix changelog entry. I do not consider this blocking, since the old behavior was an unambiguous bug (silent locale-dependent corruption of the user's own metadata), not a decision anyone deliberately relied on.
1.3 Performance / Side-Effect Analysis
None. Locale.ROOT is a static singleton; passing it explicitly to toUpperCase/toLowerCase has no measurable CPU/memory/GC cost difference versus the no-arg overload (the no-arg overload just forwards to Locale.getDefault(Locale.Category.FORMAT) internally). No new allocations, no new synchronization, no new I/O.
1.4 Error Handling and Logging
No new issues introduced. Exception handling for the default branch (UnsupportedOperationException) is unchanged in both files.
2. Code Quality Assessment
2.1 Coding Standards
The change is a minimal, surgical two-token edit inside an existing switch block in each file — it does not introduce a new method or a nontrivial field, so the project's "new core methods/fields must be commented" rule does not strictly apply. That said, a short inline comment such as // Locale.ROOT avoids the Turkish-i / Azerbaijani-i case-conversion bug at each site would help a future maintainer understand why Locale.ROOT was deliberately chosen instead of just reverting the diff during some future refactor. This is a Low-severity, non-blocking nit.
2.2 Test Coverage and Test Stability
Stability rating: Stable. The new test (TableRenameTransformTest.testConvertCaseIsLocaleIndependent, seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/TableRenameTransformTest.java:151-169) is fully deterministic: it explicitly sets Locale.setDefault(Locale.forLanguageTag("tr-TR")), asserts both UPPER ("i" → "I", not "İ") and LOWER ("I" → "i", not "ı") conversions, and restores the original default locale in a finally block so it cannot leak global JVM state into other tests running in the same fork/JVM (an important discipline point since Locale.setDefault is process-global). No hard sleeps, no timing assumptions, no shared/static mutable state left dangling. This is exactly the right way to write this kind of test.
Issue N=1 — Coverage gap: FieldRenameTransform has no equivalent regression test.
- Location:
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/FieldRenameTransformTest.java(no locale test added), compare toTableRenameTransformTest.java:151-169(has one). - Problem description: The PR fixes the identical bug in two files (
FieldRenameTransform.javaandTableRenameTransform.java), but the new locale-independence regression test was only added forTableRenameTransform.FieldRenameTransform.convertName(String)is@VisibleForTesting public, so an analogous test (setLocale.forLanguageTag("tr-TR"), assertconvertName("i")=="I"underUPPER, etc.) would be trivial to add and mirrors the existing test structure inFieldRenameTransformTest.javaat lines 106/140 whereConvertCase.LOWER/UPPERare already exercised (just not under a non-default locale). - Potential risk: without this test, a future refactor of
FieldRenameTransformcould silently reintroducetoUpperCase()/toLowerCase()withoutLocale.ROOTand nothing in CI would catch it, even though the exact same regression was caught forTableRenameTransform. - Best improvement: add a mirrored
testConvertCaseIsLocaleIndependenttest toFieldRenameTransformTest.java. - Severity: Medium
- Raised by another reviewer: No
2.3 Documentation Updates
No doc changes are needed. convert_case: UPPER|LOWER is already documented in docs/en/transforms/field-rename.md and docs/en/transforms/table-rename.md with no locale-specific wording, and this fix does not change the documented option's semantics — it only makes the already-documented behavior deterministic across environments, which is what a user reading the docs would already reasonably expect.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. This is exactly the right, minimal, idiomatic Java fix for this well-known JDK locale pitfall — no workaround, no new abstraction, no unnecessary scope creep into unrelated toUpperCase()/toLowerCase() call sites elsewhere in the module (which is correct, since those other sites operate on internal ASCII tokens, not user data, and are out of scope for this PR).
3.2 Maintainability
Good. Two isolated one-line changes plus a targeted regression test keep the diff easy to review and low-risk to merge.
3.3 Extensibility
Not applicable — no new extension points introduced.
3.4 Historical-Version Compatibility
No config option, API, serialization format, or checkpoint/savepoint schema is touched. The only historical-compatibility nuance is the narrow Turkish/Azerbaijani/Lithuanian-locale output-change scenario discussed in 1.2, which is a correctness improvement rather than a contract change.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Missing mirrored locale-independence regression test for FieldRenameTransform |
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/FieldRenameTransformTest.java |
Medium |
| 2 | No inline comment explaining why Locale.ROOT was chosen (helps prevent future accidental revert) |
FieldRenameTransform.java:167-172, TableRenameTransform.java:152-155 |
Low |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
-
Blockers — must be fixed
- (Medium) Issue 1: add the equivalent
Locale-independence regression test toFieldRenameTransformTest.javaso both fixed files carry a regression guard, not just one.
- (Medium) Issue 1: add the equivalent
-
Recommended fixes — non-blocking
- (Low) Issue 2: a one-line comment at each
Locale.ROOTcall site explaining the Turkish-locale rationale, so a future contributor doesn't "clean up" the seemingly-redundantLocale.ROOTargument. - Consider adding a one-sentence note in the PR description about the narrow output-change scenario for Turkish/Azerbaijani/Lithuanian-locale deployments (see 1.2) — informational for release notes, not a code change.
- (Low) Issue 2: a one-line comment at each
Overall assessment: this is a small, correct, well-targeted fix for a real and well-documented JDK locale pitfall, backed by a genuinely deterministic (non-flaky) regression test that correctly restores global JVM state afterward. The only gap is that the regression test was written for TableRenameTransform but not mirrored onto FieldRenameTransform, which shares the exact same bug pattern and fix. That's a quick, low-effort addition and I'd be happy to approve immediately once it's in. Nice catch and a clean fix, corgy-w — thank you for pinning this down to Locale.ROOT specifically rather than just swapping in the host's current locale.
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
FieldRenameTransformandTableRenameTransformboth implement aconvert_caseoption (UPPER/LOWER) that previously called the no-argString.toUpperCase()/String.toLowerCase(), which silently useLocale.getDefault(). On a JVM whose default locale is Turkish/Azerbaijani/Lithuanian,"i".toUpperCase()produces"İ"instead of"I", and"I".toLowerCase()produces"ı"instead of"i"— a classic, well-documented JDK locale pitfall.- This PR pins both call sites to
Locale.ROOTso the rename output is deterministic and independent of the JVM/host locale, and adds a regression test that flipsLocale.setDefault()totr-TRto prove it forTableRenameTransform. - One-sentence summary: correct, minimal fix for the Turkish-locale case-conversion bug, but the single Medium-severity gap flagged in my last review (no equivalent regression test for
FieldRenameTransform, which has the exact same bug/fix) is still open — the only commit added since then is an emptychore: trigger CIcommit with zero code diff.
1. Code Change Review
1.1 Core Logic Analysis
Re-verified against the current head 43b9264742... in a clean checkout — the diff versus my last review is byte-identical for the fix itself:
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/FieldRenameTransform.java:167,170— insideconvertName(String):case UPPER: name = name.toUpperCase(Locale.ROOT); // was: name.toUpperCase() break; case LOWER: name = name.toLowerCase(Locale.ROOT); // was: name.toLowerCase() break;
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/TableRenameTransform.java:153,155— insideconvertCase(String):case UPPER: return name.toUpperCase(Locale.ROOT); // was: return name.toUpperCase(); case LOWER: return name.toLowerCase(Locale.ROOT); // was: return name.toLowerCase();
What changed since my last review: git diff 57a4c8af 43b92647 (the fix commit vs. the new head) is empty — the only new commit is chore: trigger CI, an empty commit with no file changes at all (I confirmed this with git show --stat and a zero-line git diff). So there is nothing new to re-review in the production code; this round is purely "same code, CI was re-triggered."
Normal-path confirmation (unchanged from before): TableRenameTransform.convertCase() is invoked from transformTableIdentifier() (every schema resolution) and from convertName(), on the hot per-row/per-schema-change path (transformRow/mapSchemaChangeEvent). FieldRenameTransform.convertName() is likewise invoked from transformTableSchema() and mapSchemaChangeEvent(). Any job with convert_case: UPPER|LOWER configured hits this on every run — this is the primary execution path, not an edge case.
Key Findings
- Both of the only two case-conversion call sites in the
renamepackage are fixed consistently withLocale.ROOT(re-verified withgrep -rn "convertCase\|ConvertCase"across the package — no other call site exists). Locale.ROOTis the correct choice (locale-insensitive by design, safer thanLocale.ENGLISH, which is a real locale that could still shift with future JDK/ICU data updates).- Cross-PR consistency check (per this round's assignment): I compared this against the two sibling fixes for the same bug class landing in this same review cycle — PR #11950 (
StringFunction.lower/upperin the SQL transform'sLocale.ROOTfix,seatunnel-transforms-v2/.../zeta/functions/StringFunction.java:261,269) and PR #11894 (JobStatus.fromString,seatunnel-engine/.../JobStatus.java). All three use the identical remediation (Locale.ROOT, notLocale.ENGLISHor a hardcodedLocale.US) and the identical regression-test pattern (Locale.setDefault(Locale.forLanguageTag("tr-TR"))inside atry/finallythat restores the original default). This PR's approach is fully consistent with its siblings — good sign that this is being fixed as a recognized class of bug, not three independent, divergent workarounds.
1.2 Compatibility Impact
Classification: Fully compatible for the overwhelming majority of deployments; Partially incompatible only for a narrow locale-specific edge case. (Unchanged from last review — no new compatibility surface was introduced since the code is unchanged.) For en, C/POSIX, or most other JVM default locales, toUpperCase() and toUpperCase(Locale.ROOT) are byte-identical for ASCII input — no observable change for the vast majority of existing pipelines. The only environments where output changes are Turkish/Azerbaijani/Lithuanian-locale JVMs with table/field names containing i/I. That is a genuine (if narrow) user-visible output change from the previous (buggy) behavior; still not blocking since the old behavior was silent metadata corruption, not an intentional contract.
1.3 Performance / Side-Effect Analysis
None. Locale.ROOT is a static singleton; no measurable CPU/memory/GC difference versus the no-arg overload, no new allocations, no new synchronization or I/O.
1.4 Error Handling and Logging
No new issues. The default branch (UnsupportedOperationException) is unchanged in both files.
Issue 1 — Coverage gap: FieldRenameTransform still has no equivalent regression test (carried over, unresolved).
- Location:
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/FieldRenameTransformTest.java(re-verified at current head:grep -n "Locale"returns zero matches), compare toTableRenameTransformTest.java:153-171, which hastestConvertCaseIsLocaleIndependent. - Problem description: the PR fixes the identical bug in two files, but the locale-independence regression test exists only for
TableRenameTransform.FieldRenameTransform.convertName(String)is@VisibleForTesting public, so mirroring the existing test structure (FieldRenameTransformTest.javaalready exercisesConvertCase.LOWER/UPPERaround lines 106/140, just not under a non-default locale) would be a trivial addition. - Potential risk: without this test, a future refactor of
FieldRenameTransformcould silently reintroduce the no-argtoUpperCase()/toLowerCase()and nothing in CI would catch it, even though the sibling class (TableRenameTransform) is now protected. - Best improvement: add a mirrored
testConvertCaseIsLocaleIndependent-style test toFieldRenameTransformTest.javausing the sametr-TR/ try-finally pattern already proven inTableRenameTransformTest.javaand in the sibling PRs #11950 / #11894. - Severity: Medium
- Raised by another reviewer: No (this is a carryover from my prior review on this same PR — not a new finding this round, but it was not addressed by the new commit, so it remains open).
2. Code Quality Assessment
2.1 Coding Standards
Unchanged from last review: the fix is a minimal two-token edit inside an existing switch in each file, not a new method/field, so the "new methods/fields need comments" rule doesn't strictly apply. A short inline comment (// Locale.ROOT avoids the Turkish-i case-conversion bug) at each site remains a nice-to-have, not a blocker (Issue 2 below, unchanged severity).
2.2 Test Coverage and Test Stability
Stability rating: Stable for the test that does exist. TableRenameTransformTest.testConvertCaseIsLocaleIndependent (seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/TableRenameTransformTest.java:152-170) is fully deterministic: explicitly sets Locale.setDefault(Locale.forLanguageTag("tr-TR")), asserts both UPPER ("i" → "I", not "İ") and LOWER ("I" → "i", not "ı"), and restores the original default locale in a finally block, so it cannot leak global JVM state into other tests sharing the same fork/JVM. No hard sleeps, no timing assumptions, no dangling shared/static mutable state. This is exactly the right way to write this kind of test, and it genuinely reproduces the bug under a non-ROOT default locale as the assignment asked me to confirm.
Coverage gap: as in Issue 1, FieldRenameTransform — which carries the identical bug and identical fix — has no such test, so half of this PR's production change is currently unguarded by regression tests.
2.3 Documentation Updates
No doc changes needed; convert_case: UPPER|LOWER is already documented with no locale-specific wording in docs/en/transforms/field-rename.md / docs/en/transforms/table-rename.md, and this fix only makes the already-documented behavior deterministic, which is what a reader would already expect.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix — minimal, idiomatic, no unnecessary scope creep into unrelated toUpperCase()/toLowerCase() call sites elsewhere in the module that operate on internal ASCII tokens rather than user data.
3.2 Maintainability
Good for the parts that are tested; the untested FieldRenameTransform half is one silent-regression risk away from a future accidental revert, which is exactly what Issue 1 exists to prevent.
3.3 Extensibility
Not applicable — no new extension points.
3.4 Historical-Version Compatibility
No config option, API, serialization format, or checkpoint/savepoint schema is touched. The only nuance is the narrow Turkish/Azerbaijani/Lithuanian-locale output-change scenario discussed in 1.2, a correctness improvement rather than a contract change.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Missing mirrored locale-independence regression test for FieldRenameTransform (carried over from prior review, still unaddressed) |
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/FieldRenameTransformTest.java |
Medium |
| 2 | No inline comment explaining why Locale.ROOT was deliberately chosen |
FieldRenameTransform.java:167,170, TableRenameTransform.java:153,155 |
Low |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
-
Blockers — must be fixed
- (Medium) Issue 1: add the equivalent
Locale-independence regression test toFieldRenameTransformTest.java. This was flagged in my previous review round and is still the only thing standing between this PR and merge — the code fix itself is correct and unchanged.
- (Medium) Issue 1: add the equivalent
-
Recommended fixes — non-blocking
- (Low) Issue 2: a one-line comment at each
Locale.ROOTcall site so a future contributor doesn't "clean up" the seemingly-redundant argument.
- (Low) Issue 2: a one-line comment at each
CI status at time of this review: the Build check on the apache side is a pointer to the contributor's fork run; I traced it to corgy-w/seatunnel run 33144894589 for head 43b9264742.... All completed jobs (license header, code style, dead links, unit-test x4 matrix, engine-k8s-it, several all-connectors-it batches, etc.) are green; the run is still in progress with several connector-IT jobs queued/running and the updated-modules-integration-test-* jobs correctly skipped since only seatunnel-transforms-v2 changed. No failures observed as of this check — CI is genuinely PENDING, not blocked, so there is nothing to diagnose or re-sync yet.
Overall assessment: this remains a small, correct, well-targeted fix for a real JDK locale pitfall, and it is pleasing to see it landed consistently with its two sibling fixes (#11950, #11894) — same Locale.ROOT remediation, same tr-TR simulated-locale regression-test pattern. The only outstanding item is still the missing FieldRenameTransformTest coverage from my last round; since the new commit here was a no-op CI retrigger rather than a code update, that gap simply hasn't been touched yet. No new issues found in this pass. Once the mirrored test lands, I'm happy to approve.
Address review feedback: FieldRenameTransform.convertName has the same locale-dependent case conversion bug as TableRenameTransform, but lacked an equivalent regression test. Add testConvertCaseIsLocaleIndependent, matching the TableRenameTransform test, which flips the JVM default locale to tr-TR and asserts Locale.ROOT-based UPPER/LOWER output.
|
Thanks @DanielLeens for the thorough review and for confirming the fix is correct. I've addressed the flagged Medium gap: added the equivalent regression test for |
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
FieldRenameTransform and TableRenameTransform both implement a convert_case option (UPPER/LOWER) that previously called the no-arg String.toUpperCase() / String.toLowerCase(), which silently use Locale.getDefault(). On a JVM whose default locale is Turkish/Azerbaijani/Lithuanian, "i".toUpperCase() produces "İ" instead of "I", and "I".toLowerCase() produces "ı" instead of "i" — a classic, well-documented JDK locale pitfall. This PR pins both call sites to Locale.ROOT so the rename output is deterministic and independent of the JVM/host locale. This is a full re-review against the current head (fd48938ae6c9c9455dc2802cf51d6114dca7f7a0): the single Medium-severity gap carried over from my two previous rounds (no locale regression test for FieldRenameTransform) has now been closed by the newest commit.
1. Code Change Review
1.1 Core Logic Analysis
Fetched the PR branch fresh and re-walked the full dev...head diff (4 files, +40/-4) rather than diffing against my prior notes.
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/FieldRenameTransform.java:168,171— insideconvertName(String):case UPPER: name = name.toUpperCase(Locale.ROOT); // was: name.toUpperCase() break; case LOWER: name = name.toLowerCase(Locale.ROOT); // was: name.toLowerCase() break;
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/TableRenameTransform.java:154,156— insideconvertCase(String):case UPPER: return name.toUpperCase(Locale.ROOT); // was: return name.toUpperCase(); case LOWER: return name.toLowerCase(Locale.ROOT); // was: return name.toLowerCase();
Unchanged since the fix commit 57a4c8af.
What changed since my last review: the new commit fd48938a ("Add FieldRenameTransform locale regression test") adds exactly one thing — FieldRenameTransformTest.testConvertCaseIsLocaleIndependent (seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/FieldRenameTransformTest.java:277-295), mirroring the existing TableRenameTransformTest.testConvertCaseIsLocaleIndependent. No production code changed in this round.
Fresh full-file search for other unguarded case-conversion calls (per this round's assignment, re-verified independently rather than trusting my earlier grep): I checked every file in the rename package — ConvertCase.java (a plain two-value enum, no string logic), FieldRenameConfig.java, TableRenameConfig.java, FieldRenameTransformFactory.java, TableRenameTransformFactory.java, FieldRenameMultiCatalogTransform.java, TableRenameMultiCatalogTransform.java — none of them contain toUpperCase/toLowerCase calls; the two multi-catalog wrapper classes delegate to the already-fixed convertName/convertCase methods rather than duplicating the switch logic. So the two sites fixed here really are the only two call sites in the whole package — confirmed independently, not just re-stated from the last round.
Normal-path confirmation (unchanged): TableRenameTransform.convertCase() is invoked from transformTableIdentifier() (every schema resolution) and from convertName(), on the hot per-row/per-schema-change path (transformRow/mapSchemaChangeEvent). FieldRenameTransform.convertName() is likewise invoked from transformTableSchema() and mapSchemaChangeEvent(). Any job with convert_case: UPPER|LOWER configured hits this on every run — primary execution path, not an edge case.
Cross-PR consistency check: this round I also looked at the sibling PRs for the same bug class flagged in this batch — #11950 and #11951, both titled "Make SQL case conversion locale independent" and both targeting the same underlying issue (#11949) in StringFunction.lower/upper. Worth flagging to a maintainer: #11950 (tagadearpit) and #11951 (zhangshenghang) appear to be two independent, duplicate PRs fixing the identical SQL-transform bug with the identical Locale.ROOT + tr-TR regression-test pattern — only one of them should ultimately be merged. That's outside the scope of this PR's review, but since this PR was explicitly cross-referenced against them: the fix pattern here (Locale.ROOT, not Locale.ENGLISH/Locale.US; Locale.setDefault(Locale.forLanguageTag("tr-TR")) inside try/finally) is fully consistent with both. Good sign this is being treated as a recognized bug class rather than three divergent one-off patches.
1.2 Compatibility Impact
Classification: Fully compatible for the overwhelming majority of deployments; Partially incompatible only for a narrow locale-specific edge case. (Unchanged — no new compatibility surface this round, since only a test was added.) For en, C/POSIX, or most other JVM default locales, toUpperCase() and toUpperCase(Locale.ROOT) are byte-identical for ASCII input — no observable change for the vast majority of existing pipelines. The only environments where output changes are Turkish/Azerbaijani/Lithuanian-locale JVMs with table/field names containing i/I. That is a genuine (if narrow) user-visible output change from the previous (buggy) behavior; not blocking, since the old behavior was silent metadata corruption rather than an intentional contract.
1.3 Performance / Side-Effect Analysis
None. Locale.ROOT is a static singleton; no measurable CPU/memory/GC difference versus the no-arg overload, no new allocations, no new synchronization or I/O.
1.4 Error Handling and Logging
No new issues. The default branch (UnsupportedOperationException) is unchanged in both files.
No formal issues in this section this round (the one prior Medium finding was a test-coverage gap, addressed below).
2. Code Quality Assessment
2.1 Coding Standards
Unchanged: the production fix is a minimal two-token edit inside an existing switch in each file, not a new method/field, so the "new methods/fields need comments" rule doesn't strictly apply. A short inline comment (// Locale.ROOT avoids the Turkish-i case-conversion bug) at each site remains a nice-to-have (Issue 2 below, unchanged Low severity, non-blocking).
2.2 Test Coverage and Test Stability
Stability rating: Stable. I read the new FieldRenameTransformTest.testConvertCaseIsLocaleIndependent line by line — it mirrors TableRenameTransformTest.testConvertCaseIsLocaleIndependent exactly: sets Locale.setDefault(Locale.forLanguageTag("tr-TR")), builds a FieldRenameTransform with ConvertCase.UPPER, asserts convertName("i") equals "I" (would be "İ" under the bug) and convertName("abc") still equals "ABC" (proves ASCII-normal output is unaffected), repeats for ConvertCase.LOWER ("I" -> "i", "ABC" -> "abc"), and restores the original default locale in a finally block so it can't leak global JVM state to other tests in the same fork. This genuinely simulates a Turkish default locale (not just an assertion against Locale.ROOT in isolation), which is exactly what was asked for. Both rename-transform classes are now protected by an equivalent regression test — Issue 1 from my prior two reviews is resolved.
I also independently confirmed this test actually compiles and passes rather than trusting the author's comment: the fork CI run for this exact head (fd48938a, run 33181120882, triggered at the same timestamp as the push) shows both unit-test (8, ubuntu-latest) and unit-test (11, ubuntu-latest) (plus the Windows/JDK matrix) as SUCCESS, which is where this test executes.
No new test-coverage gaps found in this pass.
2.3 Documentation Updates
No doc changes needed; convert_case: UPPER|LOWER is already documented with no locale-specific wording in docs/en/transforms/field-rename.md / docs/en/transforms/table-rename.md, and this fix only makes the already-documented behavior deterministic, which is what a reader would already expect.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix — minimal, idiomatic, no unnecessary scope creep into unrelated toUpperCase()/toLowerCase() call sites elsewhere in the module that operate on internal ASCII tokens rather than user data.
3.2 Maintainability
Good, and now fully symmetric: both fixed classes carry an equivalent regression test, so a future refactor that accidentally reintroduces the no-arg overload in either file will be caught by CI instead of only in one of the two.
3.3 Extensibility
Not applicable — no new extension points.
3.4 Historical-Version Compatibility
No config option, API, serialization format, or checkpoint/savepoint schema is touched. The only nuance is the narrow Turkish/Azerbaijani/Lithuanian-locale output-change scenario discussed in 1.2, a correctness improvement rather than a contract change.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | FieldRenameTransformfd48938a |
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/rename/FieldRenameTransformTest.java:277-295 |
Resolved (was Medium) |
| 2 | No inline comment explaining why Locale.ROOT was deliberately chosen |
FieldRenameTransform.java:168,171, TableRenameTransform.java:154,156 |
Low |
5. Merge Recommendation
Conclusion: Ready to merge
-
Blockers — must be fixed
- None. The only Medium item from my prior two review rounds is closed in this commit, and this fresh full re-review (independent grep across the whole
renamepackage, independent read of the new test, independent CI verification) did not surface anything new.
- None. The only Medium item from my prior two review rounds is closed in this commit, and this fresh full re-review (independent grep across the whole
-
Recommended fixes — non-blocking
- (Low) Issue 2: a one-line comment at each
Locale.ROOTcall site so a future contributor doesn't "clean up" the seemingly-redundant argument. Feel free to land as-is and pick this up in a follow-up, or fold it in now — either is fine with me.
- (Low) Issue 2: a one-line comment at each
CI status at time of this review: the apache-side Build check shows CANCELLED, which mirrors the fork run's overall conclusion (corgy-w/seatunnel run 33181120882, head fd48938a). I checked every job in that run individually rather than trusting the rollup label: 82 succeeded, 10 correctly skipped (updated-modules-integration-test-*, since only seatunnel-transforms-v2 changed), and exactly one job — kudu-connector-it (8, ubuntu-latest) — was cancelled after running ~1.5 hours (20:55:58 to 22:26:13), while the JDK-11 variant of the same job (kudu-connector-it (11, ubuntu-latest)) completed successfully in the same run. This reads as an unrelated infra hang in the Kudu Testcontainer bootstrap (nothing in this PR touches the connector-kudu module or its container setup), not a real signal against this change — the tests that actually exercise this PR's code (unit-test x4 matrix, both transform-v2-it-part-1/transform-v2-it-part-2 jobs, code style, dead links, sanity check) are all green. I'd recommend a maintainer re-run just that one cancelled job (gh run rerun 33181120882 --job <kudu-it-8-job-id>) to get a clean rollup before the final merge click, but I don't consider it a code-side blocker.
Overall assessment: this is a small, correct, well-targeted fix for a real JDK locale pitfall, now landed consistently across both affected classes with matching regression tests, and consistent with the two independent sibling fixes for the SQL-transform side of the same bug class (#11950/#11951 — worth a maintainer glance since those two look like duplicates of each other, unrelated to this PR). Thanks for closing the gap quickly, corgy-w — I'm approving this round.
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
FieldRenameTransform and TableRenameTransform both implement a convert_case option (UPPER/LOWER) that previously called the no-arg String.toUpperCase() / String.toLowerCase(), which silently use Locale.getDefault(). On a JVM whose default locale is Turkish/Azerbaijani/Lithuanian, "i".toUpperCase() produces "İ" instead of "I", and "I".toLowerCase() produces "ı" instead of "i" — the classic JDK "Turkish-i" locale pitfall. This PR pins both call sites to Locale.ROOT so the rename output is deterministic across JVM/host locales, and adds matching regression tests for both classes.
Sorry for missing this in an earlier review: in my very first pass on this PR I dismissed every other toUpperCase()/toLowerCase() call site in zeta/functions/* as "fixed ASCII keyword/function-name tokens, not exposed to the Turkish-i bug." That blanket statement was wrong for StringFunction.lower()/upper() — those two methods are the actual implementation of the SQL LOWER()/UPPER() functions and operate on the caller's own row data (args.get(0)), not an internal token, so they carry the identical bug. I only partially corrected myself in the second round by acknowledging a sibling PR (#11950) fixes exactly that method, without going back to fix the incorrect blanket claim in round one. This re-review re-verifies the boundary properly (see 1.1) rather than repeating the earlier shortcut.
This is a full fresh review of the entire current diff and call chain, not an incremental diff against my last round, per this cycle's assignment.
1. Code Change Review
1.1 Core Logic Analysis
I fetched the PR head fresh (f75654b8606f1b5f0090b0728a9706bddf84f983) into a clean worktree and independently confirmed the file-level diff against the current dev merge-base is unchanged from what I approved last round: 4 files, +46/-4.
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/FieldRenameTransform.java:168,171—convertName(String):case UPPER: name = name.toUpperCase(Locale.ROOT); // was: name.toUpperCase() break; case LOWER: name = name.toLowerCase(Locale.ROOT); // was: name.toLowerCase() break;
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/TableRenameTransform.java:154,156—convertCase(String):case UPPER: return name.toUpperCase(Locale.ROOT); // was: return name.toUpperCase(); case LOWER: return name.toLowerCase(Locale.ROOT); // was: return name.toLowerCase();
What changed since my last (APPROVED) review: the only commit added since fd48938a (the commit I approved) is f75654b8, whose message is chore: trigger CI. I diffed the two commits directly (git diff fd48938a f75654b8 --stat) and it is completely empty — zero files, zero lines. This is a no-op CI-retrigger commit, not new code. So there is nothing new to re-review in the production or test code this round; I'm reconfirming my prior approval against byte-identical content, not approving new work.
Normal-path confirmation (independently re-traced, not just re-stated): TableRenameTransform.convertCase() is called from transformTableIdentifier() (database/schema name conversion on every schema resolution, TableRenameTransform.java:88-91) and from convertName() (table name conversion, called from transformTableSchema() at line 132 and from mapSchemaChangeEvent()/convertName(AlterTableColumnEvent) at line 145). FieldRenameTransform.convertName(String) is called from transformTableSchema() (line 98) and transitively from every AlterTableColumnEvent branch (add/drop/modify/change column, lines 215-255) via the private convertName(Column) helper. Any job with convert_case: UPPER|LOWER configured on either transform hits this on every schema resolution and every schema-change event — this is the primary execution path, not a boundary/recovery path.
Full-package re-scan for other unguarded case-conversion calls in the rename package (re-verified independently): grep -rn "toUpperCase\|toLowerCase" seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/rename/ returns exactly the two fixed sites and nothing else. The multi-catalog wrappers (FieldRenameMultiCatalogTransform, TableRenameMultiCatalogTransform) extend AbstractMultiCatalogMapTransform and delegate to the fixed single-catalog transforms rather than duplicating the switch logic — confirmed via grep -n "convertCase\|convertName\|extends" on both files. The two sites fixed here really are the only two call sites in the whole rename package.
Same-transform-family locale-sensitivity scan (this round's specific assignment): I re-scanned the broader seatunnel-transforms-v2 module for unguarded toUpperCase()/toLowerCase(). Most hits (ZetaSQLFunction.java, ZetaSQLType.java, CastFunction.java, DateTimeFunction.java, NumericFunction.java, SystemFunction.java, SQLTransform.java:83, VectorReduceFunction.java, BuiltinFunctions.java) really are internal keyword/type/function-name dispatch on engine-defined ASCII tokens ("UPPER", "ENGINE", SQL type/function names) — correctly out of scope, as previously assessed.
However, seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/StringFunction.java:263 (lower()) and :271 (upper()) are a real exception to that pattern — this is the actual implementation of the SQL LOWER(column)/UPPER(column) functions, operating on arg = (String) args.get(0), i.e., the user's own row data passed through the SQL transform, exactly analogous to this PR's convertCase/convertName. As of this PR's current head, dev still contains the unguarded arg.toLowerCase()/arg.toUpperCase() at those two lines (verified directly in this worktree after merging in latest dev). This is the identical bug class, in the same module, still unfixed — but it is correctly out of scope for this PR (#11994 only touches the rename package). It is already tracked by two open, unmerged, mutually-duplicate PRs: #11950 and #11951 (both titled "Make SQL case conversion locale independent", both still OPEN/mergedAt: null as of this review). I'm flagging this only as an FYI cross-reference, consistent with what I noted in my prior round — not a blocker on #11994.
Locale.ROOTremains the correct choice here (locale-insensitive by design, safer thanLocale.ENGLISH, which is a real locale that could shift with future JDK/ICU data updates).
1.2 Compatibility Impact
Classification: Fully compatible for the overwhelming majority of deployments; partially incompatible only for a narrow locale-specific edge case. Unchanged from prior rounds — no new compatibility surface, since the code is unchanged. For en, C/POSIX, or most other JVM default locales, toUpperCase() and toUpperCase(Locale.ROOT) are byte-identical for ASCII input, so there is no observable change for the vast majority of existing pipelines. The only environments where output changes are Turkish/Azerbaijani/Lithuanian-locale JVMs with table/field names containing i/I. That is a genuine (if narrow) user-visible output change from the previous (buggy) behavior — not blocking, since the old behavior was silent locale-dependent metadata corruption, not an intentional contract.
1.3 Performance / Side-Effect Analysis
None. Locale.ROOT is a static singleton; no measurable CPU/memory/GC difference versus the no-arg overload, no new allocations, no new synchronization or I/O.
1.4 Error Handling and Logging
No new issues. The default branch (UnsupportedOperationException) is unchanged in both files.
2. Code Quality Assessment
2.1 Coding Standards
Unchanged: the fix is a minimal two-token edit inside an existing switch in each file, not a new method/field, so the "new methods/fields need comments" rule doesn't strictly apply. A short inline comment (// Locale.ROOT avoids the Turkish-i case-conversion bug) at each site remains a nice-to-have, non-blocking (Issue 2 below, still open, still Low).
2.2 Test Coverage and Test Stability
Stability rating: Stable. Both TableRenameTransformTest.testConvertCaseIsLocaleIndependent (TableRenameTransformTest.java:151-169) and FieldRenameTransformTest.testConvertCaseIsLocaleIndependent (FieldRenameTransformTest.java:278-296) are fully deterministic: each explicitly sets Locale.setDefault(Locale.forLanguageTag("tr-TR")), asserts both UPPER ("i" -> "I", not "İ") and LOWER ("I" -> "i", not "ı") conversions, additionally asserts plain-ASCII input ("abc"/"ABC") is unaffected, and restores the original default locale in a finally block so it cannot leak process-global JVM state into other tests sharing the same fork. No hard sleeps, no timing assumptions, no dangling shared/static mutable state. Both fixed classes are now symmetrically covered — the Medium-severity gap I raised in my first two rounds (FieldRenameTransform had no equivalent test) is resolved and remains resolved; no new coverage gap found in this pass.
2.3 Documentation Updates
No doc changes needed. convert_case: UPPER|LOWER is already documented with no locale-specific wording in docs/en/transforms/field-rename.md / docs/en/transforms/table-rename.md, and this fix only makes the already-documented behavior deterministic, which is what a reader would already expect.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise, minimal, idiomatic fix for a well-known JDK locale pitfall, with no scope creep into the unrelated (and correctly out-of-scope) call sites elsewhere in the module.
3.2 Maintainability
Good, and symmetric: both fixed classes carry an equivalent regression test, so a future refactor that accidentally reintroduces the no-arg overload in either file will be caught by CI.
3.3 Extensibility
Not applicable — no new extension points introduced.
3.4 Historical-Version Compatibility
No config option, API, serialization format, or checkpoint/savepoint schema is touched. The only nuance is the narrow Turkish/Azerbaijani/Lithuanian-locale output-change scenario discussed in 1.2, a correctness improvement rather than a contract change.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | No inline comment explaining why Locale.ROOT was deliberately chosen |
FieldRenameTransform.java:168,171, TableRenameTransform.java:154,156 |
Low |
| 2 | (FYI, not a blocker on this PR) StringFunction.lower()/upper() in the SQL transform has the identical unguarded-locale bug and is still unfixed in dev; tracked by two separate open/duplicate PRs (#11950, #11951), out of scope for #11994 |
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/functions/StringFunction.java:263,271 |
Informational |
5. Merge Recommendation
Conclusion: Ready to merge
-
Blockers — must be fixed
- None. This round's fresh, full re-review (independent worktree checkout, independent file-level diff against
dev, independent re-trace of the call chain, independent package-wide and module-wide locale-sensitivity grep) found no new issues and confirms the diff is byte-identical to what I already approved.
- None. This round's fresh, full re-review (independent worktree checkout, independent file-level diff against
-
Recommended fixes — non-blocking
- (Low) Issue 1: a one-line comment at each
Locale.ROOTcall site so a future contributor doesn't "clean up" the seemingly-redundant argument. - (Informational) Issue 2: no action needed on this PR; a maintainer may want to prioritize merging one of
#11950/#11951to close out the siblingStringFunctionbug, since it's the same bug class and still open indev.
- (Low) Issue 1: a one-line comment at each
CI status at time of this re-review: the apache-side Build check shows CANCELLED, dereferenced to the fork's real Actions run at corgy-w/seatunnel run 33389249091 for the current head f75654b8. I checked every job individually: 82 succeeded, 10 correctly skipped (updated-modules-integration-test-*, since only seatunnel-transforms-v2 changed), and exactly one job — kudu-connector-it (11, ubuntu-latest) — was cancelled, while the JDK-8 variant of the same job completed successfully in the same run. This is the same unrelated Kudu-Testcontainer-bootstrap flake pattern I already saw (and flagged as unrelated) on the previous head in my prior round, just hitting the other JDK matrix leg this time. Nothing in this PR touches connector-kudu, so this doesn't change the merge recommendation; a maintainer re-run of just that one job would give a fully clean rollup before the actual merge click.
mergeStateStatus: BLOCKED simply reflects that DanielLeens's approval does not satisfy branch protection (no write access) — reviewDecision is REVIEW_REQUIRED, not CHANGES_REQUESTED; there is no unresolved reviewer objection blocking this.
Thanks again, corgy-w — nothing changed in the code since I approved this last round (the only new commit was an empty CI retrigger), and this fresh, independent pass confirms it's still solid. Apologies again for the imprecise "all zeta/functions/* call sites are safe ASCII tokens" framing in my very first review — the correct, narrower statement is that StringFunction.lower/upper is the one real exception, and it's being tracked separately, not part of this PR.
Purpose of this pull request
TableRenameTransform.convertCase()andFieldRenameTransform.convertCase()callString.toUpperCase()/String.toLowerCase()without an explicit locale, soconvert_case=UPPER/LOWERdepends on the default locale of the worker JVM. Under the Turkish locale,lower("I")returns the dotlessıandupper("i")returnsİ, so a distributed job can produce different output depending on the host.This is the same class of bug as the SQL
lower()/upper()functions (#11949) — but those PRs only fixedStringFunction, leaving the rename transforms affected.The fix passes
Locale.ROOTso case conversion is deterministic and follows SQL semantics.Does this PR introduce any user-facing change?
No behavioral change under non-Turkish-default locales; it only makes the result locale independent.
How was this patch tested?
./mvnw spotless:apply -pl seatunnel-transforms-v2TableRenameTransformTest(2 tests) andFieldRenameTransformTest(3 tests) pass, including the newtestConvertCaseIsLocaleIndependentregression test which runs under thetr-TRlocale.