Skip to content
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

[BUG]Should we use Locale.ENGLISH for monthName/dayName function #2844

Open
bugmakerrrrrr opened this issue Jul 19, 2024 · 4 comments
Open
Labels
bug Something isn't working

Comments

@bugmakerrrrrr
Copy link
Contributor

What is the bug?
The monthName/dayName function uses Locale.getDefault to get the display name, which may return different results in different env and cause a test error.

org.opensearch.sql.sql.DateTimeFunctionIT > testMonthName FAILED
    java.lang.AssertionError: 
    Expected: iterable with items [[September]] in any order
         but: not matched: <["九月"]>
        at __randomizedtesting.SeedInfo.seed([3027A175091234F:5336A188EBBE09E2]:0)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
        at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
        at org.opensearch.sql.util.MatcherUtils.verify(MatcherUtils.java:173)
        at org.opensearch.sql.util.MatcherUtils.verifyDataRows(MatcherUtils.java:149)
        at org.opensearch.sql.sql.DateTimeFunctionIT.testMonthName(DateTimeFunctionIT.java:801)

Should we change the locale to Locale.ENGLISH?

BTW, I found that the locale of from_unixtime function is Locale.ENGLISH.

@bugmakerrrrrr
Copy link
Contributor Author

@LantaoJin friendly ping:)

@LantaoJin
Copy link
Member

Thanks for reporting this @bugmakerrrrrr .
MonthName and DayName are MySQL-like functions. I found this https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lc_time_names. So in my opinion, it's not a bug as I said in #2685 (comment). But I am not quite sure that should we continue to follow all MySQL principles. cc @dai-chen @penghuo.

@bugmakerrrrrr
Copy link
Contributor Author

Thanks for reporting this @bugmakerrrrrr . MonthName and DayName are MySQL-like functions. I found this https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lc_time_names. So in my opinion, it's not a bug as I said in #2685 (comment). But I am not quite sure that should we continue to follow all MySQL principles. cc @dai-chen @penghuo.

Thanks for you context. I found that the MySQL document said that the default value is 'en_US' regardless of your system's locale setting, so if we need to follow the MySQL principle, should we change the locale to english?

@LantaoJin
Copy link
Member

so if we need to follow the MySQL principle, should we change the locale to english?

That's what I am not quite sure. OpenSearch SQL doesn't provide a system function/variable to set a lc_time_name, if we change it to Locale.ENGLISH, it will restrict to English.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants