bigquery-emulator icon indicating copy to clipboard operation
bigquery-emulator copied to clipboard

Queries on TIMESTAMP columns are not handled correctly when no timezone is specified

Open prismec opened this issue 11 months ago • 1 comments

What happened?

Given that table my_table with a TIMESTAMP column t, the query SELECT * FROM my_table WHERE t = "<timestamp value>" returns no results if <timestamp value> does not contain a timezone, e.g. 2023-08-01T01:00:00.000000.

Using a timezone, e.g. 2023-08-01T01:00:00.000000Z works as expected.

What did you expect to happen?

<timestamp value> 2023-08-01T01:00:00.000000 is equal to 2023-08-01T01:00:00.000000Z.

See also canonical format of the TIMESTAMP datatype: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type

[time_zone]: String representing the time zone. When a time zone is not explicitly specified, the default time zone, UTC, is used.

How can we reproduce it (as minimally and precisely as possible)?

  1. INSERT INTO my_table (t) VALUES (2023-08-01T01:00:00.000000Z`)
  2. SELECT * FROM my_table WHERE t= "2023-08-01T01:00:00.000000"

Anything else we need to know?

No response

prismec avatar Mar 07 '24 14:03 prismec

It seems that this will require a change to the Go ZetaSQL bindings. I'm not familiar with that process, @goccy could you take a look? https://github.com/goccy/go-zetasql/issues/27

ohaibbq avatar Apr 14 '24 08:04 ohaibbq