Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 0f06c1b

Browse files
fix tests
1 parent 1fa903d commit 0f06c1b

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

bigframes/core/compile/ibis_compiler/scalar_op_registry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,9 @@ def isin_op_impl(x: ibis_types.Value, op: ops.IsInOp):
982982

983983
@scalar_op_compiler.register_unary_op(ops.ToDatetimeOp, pass_op=True)
984984
def to_datetime_op_impl(x: ibis_types.Value, op: ops.ToDatetimeOp):
985-
if x.type() in (ibis_dtypes.str, ibis_dtypes.Timestamp("UTC")): # type: ignore
985+
if x.type() == ibis_dtypes.Timestamp(None): # type: ignore
986+
return x # already a timestamp, no-op
987+
elif x.type() in (ibis_dtypes.str, ibis_dtypes.Timestamp("UTC")): # type: ignore
986988
return x.try_cast(ibis_dtypes.Timestamp(None)) # type: ignore
987989
else:
988990
# Numerical inputs.

tests/system/small/operations/test_datetimes.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,20 @@ def test_dt_tz_localize(scalars_dfs, col_name, tz):
342342
assert_series_equal(bf_result.to_pandas(), pd_result, check_index_type=False)
343343

344344

345-
@pytest.mark.parametrize(
346-
("col_name", "tz"),
347-
[
348-
("timestamp_col", "UTC"),
349-
("datetime_col", "US/Eastern"),
350-
],
351-
)
352-
def test_dt_tz_localize_invalid_inputs(scalars_dfs, col_name, tz):
345+
def test_dt_tz_localize_already_localized(scalars_dfs):
346+
pytest.importorskip("pandas", minversion="2.0.0")
347+
scalars_df, _ = scalars_dfs
348+
349+
with pytest.raises(TypeError):
350+
scalars_df["timestamp_col"].dt.tz_localize("UTC")
351+
352+
353+
def test_dt_tz_localize_invalid_timezone(scalars_dfs):
353354
pytest.importorskip("pandas", minversion="2.0.0")
354355
scalars_df, _ = scalars_dfs
355356

356357
with pytest.raises(ValueError):
357-
scalars_df[col_name].dt.tz_localize(tz)
358+
scalars_df["datetime_col"].dt.tz_localize("US/Eastern")
358359

359360

360361
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)