Commit a910b03
authored
fix(unparser): Fix BigQuery timestamp literal format in SQL unparsing (#21103)
## Which issue does this PR close?
The default `Dialect::timestamp_with_tz_to_string` uses `dt.to_string()`
which produces timestamps with a space before the TimeZone offset. This
causes filter pushdown to fail when unparsing timestamp predicates for
BigQuery.
>2016-08-06 20:05:00 +00:00 <- invalid for BigQuery:
invalid timestamp: '2016-08-06 20:05:00 +00:00'; while executing the
filter on column 'startTime' (query) (sqlstate: [0, 0, 0, 0, 0],
vendor_code: -2147483648)
BigQuery rejects this format. Per the [BigQuery timestamp
docs](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#timestamp_type),
the offset must be attached directly to the time:
>2016-08-06 20:05:00+00:00 <- valid
## What changes are included in this PR?
Following similar to [DuckDB pattern/fix
](#17653) override
`timestamp_with_tz_to_string` for `BigQueryDialect` to produce valid
timestamp format
**Before (default `dt.to_string()`):**
```sql
CAST('2016-08-06 20:05:00 +00:00' AS TIMESTAMP) -- BigQuery error
```
After (%:z format):
```sql
CAST('2016-08-06 20:05:00+00:00' AS TIMESTAMP) -- valid BigQuery timestamp
```
## Are these changes tested?
Added unit test and manual e2e test with Google BigQuery instance.
## Are there any user-facing changes?
No1 parent 9f893a4 commit a910b03
2 files changed
+46
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
638 | 650 | | |
639 | 651 | | |
640 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1860 | 1860 | | |
1861 | 1861 | | |
1862 | 1862 | | |
1863 | | - | |
1864 | | - | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
1865 | 1866 | | |
1866 | 1867 | | |
1867 | 1868 | | |
| |||
3349 | 3350 | | |
3350 | 3351 | | |
3351 | 3352 | | |
| 3353 | + | |
3352 | 3354 | | |
3353 | 3355 | | |
3354 | 3356 | | |
| |||
3409 | 3411 | | |
3410 | 3412 | | |
3411 | 3413 | | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
| 3421 | + | |
| 3422 | + | |
| 3423 | + | |
| 3424 | + | |
| 3425 | + | |
| 3426 | + | |
| 3427 | + | |
| 3428 | + | |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
3412 | 3444 | | |
3413 | 3445 | | |
3414 | 3446 | | |
| |||
0 commit comments