Repository navigation
Description
Search before asking
- I searched the open and closed issues and pull requests and found no report of this. Queries included
FORMATDATETIME locale,FROM_UNIXTIME locale,DateTimeFormatter locale,ofPattern Locale,Locale.getDefault,locale dependent,month name language,Turkish locale,i18n date formatandnon-deterministic date format, on both the issue search and the separate pull request search. The locale reports that exist ([Transform-V2] SQL lower and upper depend on the worker default locale #11949, [Bug][Transform-V2] Case conversion in calcite, nlpmodel and validator depends on the worker default locale #12617, [Bug][Connector-V2] DuckDB type conversion depends on Turkish locale #12581, [Bug] [Transform-V2] Zeta SQL keyword lookup depends on the worker default locale #12496) are all about case conversion of identifiers, a different mechanism. [Bug][Connector-V2][File] Parquet INT96 timestamps are written 543 years in the future under a Thai-locale JVM #12825 is the only date-and-locale report and it was a Parquet INT96 calendar-system bug, fixed in [Fix][Connector-V2][File] Pin the INT96 timestamp calendar to Locale.ROOT #12826.
What happened
The Zeta SQL transform builds the formatter for FORMATDATETIME and FROM_UNIXTIME with DateTimeFormatter.ofPattern(format), which captures Locale.getDefault(Locale.Category.FORMAT) at construction. Any pattern letter that renders text rather than digits (MMM, MMMM, EEE, EEEE, a, G, QQQ) therefore produces a different string depending on the default locale of whichever worker JVM runs the transform.
DateTimeFunction.java:616(formatdatetime)DateTimeFunction.java:799(fromUnixTime)
The same job, over the same rows, writes different values to the sink on different workers, and the values are not reproducible across environments.
The clearest sign that this is unintended is inside the same class. DAYNAME and MONTHNAME deliberately pin English: getMonthsAndWeeks at DateTimeFunction.java:327-336 uses DateFormatSymbols.getInstance(Locale.ENGLISH). So one weekday value, in one row, in one transform, comes out of DAYNAME in English and out of FORMATDATETIME(dt, 'EEEE') in the worker's language.
I measured this by compiling seatunnel-transforms-v2 from dev and calling the real DateTimeFunction methods, not a reimplementation. Input 2026-10-23T14:05:09:
| default locale | DAYNAME(dt) |
MONTHNAME(dt) |
FORMATDATETIME(dt,'EEEE') |
FORMATDATETIME(dt,'dd MMM yyyy') |
FROM_UNIXTIME(ts,'MMM dd','UTC') |
|---|---|---|---|---|---|
en-US |
Friday | October | Friday | 23 Oct 2026 | Oct 23 |
tr-TR |
Friday | October | Cuma | 23 Eki 2026 | Eki 23 |
ja-JP |
Friday | October | 金曜日 | 23 10月 2026 | 10月 23 |
de-DE |
Friday | October | Freitag | 23 Okt. 2026 | Okt. 23 |
ar-EG |
Friday | October | الجمعة | 23 أكتوبر 2026 | أكتوبر 23 |
What is not affected, checked rather than assumed. Numeric-only patterns are stable: yyyy-MM-dd HH:mm:ss through the same function gives one distinct result across all five locales. All 13 patterns of ZetaDateTimeFormat are numeric-only and produced zero variation across seven locales including th-TH-u-ca-buddhist and ar-EG-u-nu-arab, so that enum is not part of this report. Every existing use of these two functions in the tests, the e2e configs and the docs is numeric-only, which is why no test catches this today.
SeaTunnel Version
dev at 14a27ac26a0a71b56722f86cdf8ec2779094ceaf
SeaTunnel Config
env {
job.mode = "BATCH"
}
source {
FakeSource {
plugin_output = "fake"
schema = {
fields {
id = "int"
dt = "timestamp"
}
}
rows = [
{fields = [1, "2026-10-23T14:05:09"], kind = INSERT}
]
}
}
transform {
Sql {
plugin_input = "fake"
plugin_output = "out"
query = "select id, DAYNAME(dt) as a, FORMATDATETIME(dt, 'EEEE') as b, FORMATDATETIME(dt, 'dd MMM yyyy') as c from fake"
}
}
sink {
Console {
plugin_input = "out"
}
}Running Command
# the pattern text is the only thing that changes between these two runs
./bin/seatunnel.sh --config ./config/sql_locale.conf -e local
JAVA_TOOL_OPTIONS="-Duser.language=tr -Duser.country=TR" ./bin/seatunnel.sh --config ./config/sql_locale.conf -e localError Exception
No exception is raised. That is what makes this hard to notice: the job succeeds and writes different data.
# default locale en-US
a = Friday, b = Friday, c = 23 Oct 2026
# default locale tr-TR, same job, same row
a = Friday, b = Cuma, c = 23 Eki 2026
# ^^^^^^^^^^ DAYNAME stays English because DateTimeFunction.java:331
# pins Locale.ENGLISH, while FORMATDATETIME follows the JVM
Zeta or Flink or Spark Version
Not engine specific. The defect is in seatunnel-transforms-v2, which every engine shares. I ran the functions directly rather than a cluster, so I am not claiming a cluster reproduction here.
Java or Scala Version
openjdk 17.0.20.1 2026-08-18, build 17.0.20.1+1-1-24.04-Ubuntu
Screenshots
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
SEZ9 commentedon Oct 25, 2026
Thanks for the detailed report and for measuring against the real
DateTimeFunctionmethods rather than a reimplementation. The contrast withDAYNAME/MONTHNAME, which already pinLocale.ENGLISHviaDateFormatSymbols, is a strong sign the locale-dependent output ofFORMATDATETIMEandFROM_UNIXTIMEis unintended.A fix would likely be to pin an explicit locale when building the formatter in both
formatdatetimeandfromUnixTime, plus a unit test that runs under a non-English default locale to guard against regressions.Since you've indicated you're willing to submit a PR, please go ahead. One thing to keep in mind: pinning to English is a behavior change for users on non-English workers who currently get localized month/day names, so it's worth calling out in the PR description. An optional locale argument could be considered in a follow-up, but deterministic output across workers should be the default.
SEPURI-SAI-KRISHNA commentedon Oct 25, 2026
Thanks @SEZ9. The PR is already open as #12976 and it does what you describe.
Both call sites now pass an explicit locale:
On the behaviour change, it is called out in the PR description, and
Locale.ENGLISHwas chosen overLocale.ROOTfor exactly that reason. I measured both against today's output rather than assuming they agree:Locale.ROOTLocale.ENGLISHEEEEMMMMLocale.ROOTsilently abbreviates 2 of the 7 text patterns, so it would change output for English workers too.Locale.ENGLISHchanges 0 of 7, which keeps the change confined to the workers that were producing localized text. It also matches what this class already does forDAYNAMEandMONTHNAMEthroughDateFormatSymbols.getInstance(Locale.ENGLISH).So users on a non-English worker who were getting localized month and day names will now get English, which is the deliberate part of the fix, and users on an English worker see byte identical output.
The regression test runs the real
SQLTransformunderENGLISH,tr-TRandja-JPdefaults and restores the previous locale in afinally, followingtestAtTimeZonein the same class. One case assertsFORMATDATETIME(dt,'EEEE')equalsDAYNAME(dt)andFORMATDATETIME(dt,'MMMM')equalsMONTHNAME(dt), which is the inconsistency this fixes, with a numeric-pattern control alongside.Agreed that an optional locale argument is a separate follow-up; this PR keeps the default deterministic and does not add an option.
SEZ9 commentedon Oct 26, 2026
Thanks for the detailed follow-up, and for measuring
Locale.ROOTvsLocale.ENGLISHinstead of assuming they agree. TheEEEE→FriandMMMM→Octabbreviation underLocale.ROOTis exactly the kind of silent change we want to avoid for English workers, soLocale.ENGLISHis the right pick here, and lining it up with whatDAYNAME/MONTHNAMEalready do viaDateFormatSymbols.getInstance(Locale.ENGLISH)makes the behaviour of the class internally consistent. Passing the explicit locale at both theformatdatetimeandfromUnixTimecall sites covers the scope of what I flagged.The test shape also sounds right: running the real
SQLTransformunderENGLISH,tr-TRandja-JP, restoring the default in afinallythe waytestAtTimeZonedoes, and assertingFORMATDATETIME(dt,'EEEE')equalsDAYNAME(dt)andFORMATDATETIME(dt,'MMMM')equalsMONTHNAME(dt)with a numeric control alongside.Two small asks before I sign off on the PR:
MMM,a,G,QQQfrom the original report) to the locale-switching test, or paste the rest of that comparison in the PR so the "0 of 7 changed" claim is verifiable?FORMATDATETIME/FROM_UNIXTIMEso it shows up in release notes.Agreed that an optional locale argument is a separate follow-up; keeping this PR to a deterministic default is the right scope.
SEPURI-SAI-KRISHNA commentedon Oct 26, 2026
Thanks @SEZ9. Both asks, in order.
1. The full comparison, and the test now drives it. You offered two options and the first is the better one, so the locale switching test exercises all ten text bearing patterns instead of three, with
de-DEadded as a fourth default. Measured on2024-06-15, a Saturday in Q2, afternoon:GMMMMMMMLLLLEEEEEEEcccaQQQQQQQAll ten are now asserted under all four defaults, so the claim is checked by CI rather than by a table in a thread.
A correction to my earlier comment. I said
Locale.ROOTchanges 2 of 7. Measured properly it is 4 of 10:MMMM,EEEE,QQQQandLLLLall abbreviate under ROOT.Locale.ENGLISHchanges 0 of 10. The conclusion is unchanged and in fact stronger, but the numbers I gave you were understated and I should have measured before quoting them.2. Already in the PR.
docs/en/transforms/sql-functions.mdand the ZH page both carry the behaviour note, underFORMATDATETIMEand again underFROM_UNIXTIME.One thing you did not ask for, which came out of @DanielLeens's review and is worth knowing before you sign off: the pinned locale also pins
WeekFields, so the localised numeric fieldsY,w,W,eandcchange too. Ade-DEoren-GBworker formatting2021-01-01withYYYYgot2020and now gets2021.en-GBmatters there: an English language default is not interchangeable withLocale.ENGLISHfor these fields. Both upgrade notes and both function pages now document it, and there is a regression covering it.SEZ9 commentedon Oct 27, 2026
@SEPURI-SAI-KRISHNA thanks for measuring rather than quoting — this covers both asks.
1. Comparison and test. The four-default, ten-pattern table is exactly what I wanted, and asserting it in the locale-switching test is the right place for it. The corrected figures (
Locale.ROOTabbreviatingMMMM,EEEE,QQQQandLLLL, 4 of 10, versusLocale.ENGLISHchanging 0 of 10) only strengthen the case forLocale.ENGLISH, and it stays consistent with whatDAYNAME/MONTHNAMEalready do viaDateFormatSymbols.getInstance(Locale.ENGLISH). If the earlier 2-of-7 figure appears anywhere in the PR description or docs, please update it to the measured numbers.2. Docs. Good — the behaviour note under both
FORMATDATETIMEandFROM_UNIXTIMEon the EN and ZH pages is what I was after.Nothing further from me on this item.