Open jpambrun opened 2 months ago
cc: @martint
My thought is that we should hard-code the locale in the implementation of those functions and provide alternative versions that take a locale as an argument.
Views should store the locale. The behavior of a view should not change based on the current session, unless it explicitly uses functions such as current_user
.
We shouldn’t change the existing behavior of the functions, as that may break users. Locale is a supported part of the session for functions to use.
The problems I see in the current implementation are:
(2) can be solved by adding a variant of the functions that takes a locale as an argument. For (1) and (3) I think we should change the behavior of the functions, maybe with a deprecation period and a flag to restore the legacy behavior in the meantime. I expect the vast majority of use cases would benefit more from portability and predictability of queries than varying the behavior based on how the client is configured. That seems like a very niche application.
We are an international team and we were almost going insane not understanding why some query fails intermitently. It turns out parse_datetime behave differently base on the connected client locale. In our case, this function was invoked from a view which made it hard to pin down. This is also invoked on data from a database table, not from the client, making it even more confusing. I am running 426 on AWS EMR.