Skip to content

Commit 2f0d606

Browse files
committed
fix unit test
1 parent 49f03e6 commit 2f0d606

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

bigframes/dtypes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,16 @@ def ibis_dtype_to_arrow_dtype(ibis_dtype: ibis_dtypes.DataType) -> pa.DataType:
265265
)
266266

267267
if isinstance(ibis_dtype, ibis_dtypes.Timestamp):
268+
# Only UTC timezone or None is supported.
269+
tz = ibis_dtype.timezone
270+
if tz not in (None, "UTC"):
271+
raise NotImplementedError(
272+
f"Only UTC timezone is supported, got {repr(tz)}. {constants.FEEDBACK_LINK}"
273+
)
268274
return pa.timestamp(
269275
# Only microsecond precision is supported in BigQuery.
270276
"us",
271-
# Only UTC timezone or None is supported.
272-
tz=None if ibis_dtype.timezone is None else "UTC",
277+
tz=tz,
273278
)
274279

275280
if isinstance(ibis_dtype, ibis_dtypes.Decimal):

tests/unit/test_dtypes.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def test_ibis_dtype_converts(ibis_dtype, bigframes_dtype):
7373

7474
def test_ibis_timestamp_pst_raises_unexpected_datatype():
7575
"""BigQuery timestamp only supports UTC time"""
76-
with pytest.raises(ValueError, match="Unexpected Ibis data type"):
76+
with pytest.raises(
77+
NotImplementedError,
78+
match="Only UTC timezone is supported, got 'PST'",
79+
):
7780
bigframes.dtypes.ibis_dtype_to_bigframes_dtype(
7881
ibis_dtypes.Timestamp(timezone="PST")
7982
)

0 commit comments

Comments
 (0)