ibis.timestamp(...)
becomes DATETIME(...)
in BigQuery, but I'd want TIMESTAMP(...)
#9722
-
I'm trying to recreate this query in Ibis: SELECT
*
FROM
`bigquery-public-data.pypi.file_downloads`
WHERE
project = 'kedro'
AND TIMESTAMP("${runtime_params:start_date, ${globals:start_date}}") <= timestamp
AND timestamp < TIMESTAMP("${runtime_params:end_date, ${globals:end_date}}")
LIMIT 5 So I did this: ibis.to_sql(
pypi_kedro_raw_lazy
.filter([
pypi_kedro_raw_lazy.project == "kedro",
ibis.timestamp("2024-07-01") <= pypi_kedro_raw_lazy.timestamp,
pypi_kedro_raw_lazy.timestamp < ibis.timestamp("2024-07-02"),
])
.head(5)
) which returns: SELECT
*
FROM `bigquery-public-data`.`pypi`.`file_downloads` AS `t0`
WHERE
`t0`.`project` = 'kedro'
AND DATETIME('2024-07-01T00:00:00') <= `t0`.`timestamp`
AND `t0`.`timestamp` < DATETIME('2024-07-02T00:00:00')
LIMIT 5 But this query is invalid:
It turns out in this case it works without converting to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @astrojuanlu -- get ready for a feeling of deep dread. In BigQuery, Time was a mistake. |
Beta Was this translation helpful? Give feedback.
Hi @astrojuanlu -- get ready for a feeling of deep dread.
In BigQuery,
DATETIME
s have no time zone,TIMESTAMP
s have a time zone.If you use
ibis.timestamp
and don't specify a time zone, when it compiles to BigQuery, will give you aDATETIME
.So, if you want
TIMESTAMP
, make sure you specify a time zone.Time was a mistake.