Use TIMESTAMP_TRUNC instead of DATETIME_TRUNC for BigQuery #1765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A user flagged that the
DATETIME_TRUNC
operation was causing a query to not use their BQ date partition properly, resulting in more GB of data processed than expected.After doing some research, it looks like the
DATETIME_TRUNC
also converts a timestamp object to a datetime object, which removes any timezone info. We don't intend to ever change the timezone of the underlying column, so this is not what we want.The downside of this change is that, for any BQ users who are using timezone-aware data that's not UTC, they might see a change in the output. This is because
DATETIME_TRUNC
converts to UTC by default before truncating. Regardless, most users using BigQuery should be using UTC as best practice.This PR updates the BQ SQL renderer to use
TIMESTAMP_TRUNC
instead ofDATETIME_TRUNC
.