googleapis/python-bigquery-dataframes

add `bigframes.bigquery.timestamp_add` and other BigQuery timestamp SQL functions

tswast opened this issue · 0 comments

Is your feature request related to a problem? Please describe.

It's not currently possible to directly add datetime.timedelta objects to timestamp Series because we don't currently have a data type to represent these in BigQuery DataFrames (bigframes) yet.

Describe the solution you'd like

I would like to workaround these limitations by using the SQL methods directly. Please expose methods such as https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#timestamp_add to the bigframes.bigquery namespace.

Describe alternatives you've considered

  1. We've had discussions about how to represent pandas timedeltas in bigframes by using INT64 columns in BigQuery with local metadata to say these are actually timedelta and should be treated as microseconds.
  2. The BigQuery INTERVAL type closely maps to https://arrow.apache.org/docs/python/generated/pyarrow.month_day_nano_interval.html and that's what we get from the BQ Storage Read API. It would be helpful to make this type act more like DateOffset objects in pandas https://pandas.pydata.org/pandas-docs/version/1.1/user_guide/timeseries.html#dateoffset-objects and in bigframes itself.

Additional context

See: https://stackoverflow.com/q/78480391/101923