Skip to content

Commit c5537f9

Browse files
authored
feat(bigquery): add timestamp diff support (#11944)
## Description of changes Add timestamp diff support to bigquery. ## Issues closed Resolves #11945
1 parent e5c660c commit c5537f9

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

ibis/backends/sql/compilers/bigquery/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ class BigQueryCompiler(SQLGlotCompiler):
136136
ops.Median,
137137
ops.RegexSplit,
138138
ops.RowID,
139-
ops.TimestampDiff,
140139
ops.Kurtosis,
141140
)
142141

@@ -390,6 +389,9 @@ def visit_TimestampDelta(self, op, *, left, right, part):
390389
"timestamp difference with mixed timezone/timezoneless values is not implemented"
391390
)
392391

392+
def visit_TimestampDiff(self, op, *, left, right):
393+
return sge.TimestampDiff(this=left, expression=right, unit=self.v.SECOND)
394+
393395
def visit_GroupConcat(self, op, *, arg, sep, where, order_by):
394396
if where is not None:
395397
arg = self.if_(where, arg, NULL)

ibis/backends/tests/test_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ def test_interactive(alltypes, monkeypatch):
11181118
expr = alltypes.mutate(
11191119
str_col=_.string_col.replace("1", "").nullif("2"),
11201120
date_col=_.timestamp_col.date(),
1121-
delta_col=lambda t: ibis.now() - t.timestamp_col,
1121+
delta_col=lambda t: ibis.now() - t.timestamp_col.cast("timestamp('UTC')"),
11221122
)
11231123

11241124
repr(expr)

ibis/backends/tests/test_temporal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ def convert_to_offset(x):
835835
id="timestamp-subtract-timestamp",
836836
marks=[
837837
pytest.mark.notimpl(
838-
["bigquery", "snowflake", "sqlite", "exasol", "mssql"],
838+
["snowflake", "sqlite", "exasol", "mssql"],
839839
raises=com.OperationNotDefinedError,
840840
),
841841
pytest.mark.notimpl(

0 commit comments

Comments
 (0)