Skip to content

[Transform-V2] SQL lower and upper depend on the worker default locale #11949

Closed

Description

@tagadearpit

Description

The SQL transform functions lower() and upper() call Java String.toLowerCase() and String.toUpperCase() without an explicit locale. As a result, their output depends on the default locale of the SeaTunnel worker JVM.

For example, under the Turkish locale, lower("I") returns the dotless character ı and upper("i") returns İ, instead of the locale-independent SQL results i and I. A distributed job can therefore produce different transformed data depending on the host locale.

Steps to reproduce

  1. Check out SeaTunnel dev.
  2. In seatunnel-transforms-v2, invoke the existing StringFunction methods with the JVM default locale set to Turkish:
Locale original = Locale.getDefault();
try {
    Locale.setDefault(Locale.forLanguageTag("tr-TR"));
    System.out.println(StringFunction.lower(Collections.singletonList("I")));
    System.out.println(StringFunction.upper(Collections.singletonList("i")));
} finally {
    Locale.setDefault(original);
}
  1. Run the corresponding test or a small Java harness.

Before the fix, the output is:

lower=ı upper=İ

The same harness passes with the proposed fix and produces:

lower=i upper=I

Expected behavior

SQL case conversion should be deterministic and independent of the worker machine’s default locale. lower("I") should return i and upper("i") should return I regardless of the JVM locale.

Environment

  • SeaTunnel branch: dev
  • Module: seatunnel-transforms-v2
  • JVM: Java 8+
  • Reproduction does not require an external connector, database, or cluster.

I have prepared a focused fix on the fork branch tagadearpit:fix/sql-string-case-locale, replacing the implicit default locale with Locale.ROOT and adding a regression test. The focused StringFunctionTest passes with 34 tests, and the transforms module verification lifecycle passes.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions