-
Notifications
You must be signed in to change notification settings - Fork 25.2k
SQL: make date format functions more strict #112140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL: make date format functions more strict #112140
Conversation
.build(), | ||
new Builder().pattern("%u").javaFormat(t -> String.format(Locale.ROOT, "%02d", t.get(WeekFields.ISO.weekOfYear()))).build(), | ||
new Builder().pattern("%u") | ||
.javaFormat(t -> String.format(Locale.ENGLISH, "%02d", t.get(WeekFields.of(DayOfWeek.MONDAY, 4).weekOfYear()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly how MySQL spec defines %u
.javaFormat(t -> String.format(Locale.ENGLISH, "%02d", t.get(WeekFields.of(DayOfWeek.SUNDAY, 7).weekOfWeekBasedYear()))) | ||
.build(), | ||
new Builder().pattern("%v") | ||
.javaFormat(t -> String.format(Locale.ENGLISH, "%02d", t.get(WeekFields.of(DayOfWeek.MONDAY, 4).weekOfWeekBasedYear()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly how MySQL spec defines %v
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Wait for #112196 before merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
@elasticmachine update branch |
@luigidellaquila Is it ok to backport this to 8.15 and 7.17? |
@thecoop For 8.15 I don't see any problems. |
I can take care of it tomorrow |
Backport #112140 to 8.15 Co-authored-by: Luigi Dell'Aquila <[email protected]>
Switching to
CLDR
locale provider (see #110222) exposed some problems related to date conversion functions.In particular, these functions are defined to mimic MySQL and PostgreSQL behavior, and tests that compare results with the corresponding queries in MySQL and PostgreSQL show a slightly different behavior with CLDR, eg.
Mon
instead ofMonday
with the ROOT locale;This change makes the calculation more strict by
The problem is not present with COMPAT locale provider, the intention of this change is to fix failures introduced by #110222, but I'm doing this as a separate PR to make sure that the new implementation is also good with COMPAT and we are not introducing regressions (ie. that it works fine with both
COMPAT
andCLDR
)