goccy / bigquery-emulator

BigQuery emulator server implemented in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

prismec opened this issue · 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

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?
goccy/go-zetasql#27