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

Timestamp with no time zone id is returning a different value #133

Closed
marcosapmf opened this issue Mar 7, 2023 · 4 comments
Closed

Timestamp with no time zone id is returning a different value #133

marcosapmf opened this issue Mar 7, 2023 · 4 comments

Comments

@marcosapmf
Copy link

Hi!
I'm trying to analyze a simple timestamp value (i.e SELECT TIMESTAMP '2019-02-11 20:26:53.218';) with no time zone id by using the function AnalyzeNextStatement. After the analysis, the output has changed the timestamp value to 2019-02-12 04:26:53.218+00. Shouldn't it be 2019-02-11 20:26:53.218+00 instead?

Is there any way to parameterize the time zone id without passing it within the timestamp?

Thanks in advance!

@nielm
Copy link

nielm commented Mar 8, 2023

2019-02-12 04:26:53.218+00 (ie UTC) is the same as 2019-02-11 20:26:53.218+08:00 (ie US - Pacific time)

This would make sense if the local time zone is US-Pacific on the machine you run this on, as it would assume a timestamp without timezone is expressed in 'local time'... (and IMHO is a reason why timestamps should always have a timezone to avoid ambiguity).

@marcosapmf
Copy link
Author

Hi @nielm, thanks for answering!
That was one of the first things I thought. However I'm running this on my local machine which is in Brazil time (GMT-3), so if it's using the local time zone the result should have been 2019-02-11 23:26:53.218+00, which is 2019-02-11 20:26:53.218+03:00, right?

@nielm
Copy link

nielm commented Mar 9, 2023

Looking at the code, it initializes a default time zone to America/Los_Angeles (US-Pacific) (which is very normal for a Google product!)

ZETASQL_CHECK(absl::LoadTimeZone("America/Los_Angeles", &timezone));

It is possible to set the default timezone on the analyzer using the AnalyzerOptions

void set_default_time_zone(absl::TimeZone timezone) {

public void setDefaultTimezone(String timezone) {

@marcosapmf
Copy link
Author

I see. I'll try to use it. Thanks a lot @nielm !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants