Skip to content

Commit 1cf6432

Browse files
fix: Fix internal type errors with temporal accessors
1 parent 6b8154c commit 1cf6432

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

tests/system/small/operations/test_dates.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,14 @@ def test_date_series_diff_agg(scalars_dfs):
7171
pandas.testing.assert_series_equal(
7272
actual_result, expected_result, check_index_type=False
7373
)
74+
75+
76+
def test_date_can_cast_after_accessor(scalars_dfs):
77+
bf_df, pd_df = scalars_dfs
78+
79+
actual_result = bf_df.date_col.dt.isocalendar().week.astype("Int64").to_pandas()
80+
expected_result = pd_df.date_col.dt.isocalendar().week.astype("Int64")
81+
82+
pandas.testing.assert_series_equal(
83+
actual_result, expected_result, check_dtype=False, check_index_type=False
84+
)

tests/system/small/operations/test_datetimes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,3 +603,14 @@ def test_to_datetime(scalars_dfs, col):
603603
testing.assert_series_equal(
604604
actual_result, expected_result, check_dtype=False, check_index_type=False
605605
)
606+
607+
608+
def test_timedelta_can_cast_after_dt_accessor(timedelta_series):
609+
bf_s, pd_s = timedelta_series
610+
611+
actual_result = bf_s.dt.isocalendar().week.astype("Int64").to_pandas()
612+
expected_result = pd_s.dt.isocalendar().week.astype("Int64")
613+
614+
assert_series_equal(
615+
actual_result, expected_result, check_dtype=False, check_index_type=False
616+
)

third_party/bigframes_vendored/ibis/expr/operations/strings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@ class ExtractFragment(ExtractURLField):
364364
class StringLength(StringUnary):
365365
"""Compute the length of a string."""
366366

367-
dtype = dt.int32
367+
dtype = dt.int64
368368

369369

370370
@public
371371
class StringAscii(StringUnary):
372372
"""Compute the ASCII code of the first character of a string."""
373373

374-
dtype = dt.int32
374+
dtype = dt.int64
375375

376376

377377
@public

third_party/bigframes_vendored/ibis/expr/operations/temporal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class ExtractTemporalField(Unary):
105105
"""Extract a field from a temporal value."""
106106

107107
arg: Value[dt.Temporal]
108-
dtype = dt.int32
108+
dtype = dt.int64
109109

110110

111111
@public

0 commit comments

Comments
 (0)