diff --git a/crates/polars-core/src/series/implementations/time.rs b/crates/polars-core/src/series/implementations/time.rs index 15766cb039fe..84c4b528938c 100644 --- a/crates/polars-core/src/series/implementations/time.rs +++ b/crates/polars-core/src/series/implementations/time.rs @@ -156,7 +156,7 @@ impl SeriesTrait for SeriesWrap { } fn split_at(&self, offset: i64) -> (Series, Series) { let (a, b) = self.0.split_at(offset); - (a.into_series(), b.into_series()) + (a.into_time().into_series(), b.into_time().into_series()) } fn _sum_as_f64(&self) -> f64 { diff --git a/py-polars/polars/testing/parametric/strategies/core.py b/py-polars/polars/testing/parametric/strategies/core.py index da412a72399d..c0cc732d71b0 100644 --- a/py-polars/polars/testing/parametric/strategies/core.py +++ b/py-polars/polars/testing/parametric/strategies/core.py @@ -231,10 +231,13 @@ def series( ) ) + print(values) + print(dtype) s = Series(name=name, values=values, dtype=dtype) # Apply masking out of values if do_mask_out: + print("hi") values = draw( st.lists( st.booleans(), @@ -249,6 +252,7 @@ def series( # Apply chunking if allow_chunks and size > 1 and draw(st.booleans()): + print("hi2") split_at = size // 2 s = s[:split_at].append(s[split_at:]) diff --git a/py-polars/tests/unit/operations/test_merge_sorted.py b/py-polars/tests/unit/operations/test_merge_sorted.py index 34b22d83cbdb..eb5b2420ceb9 100644 --- a/py-polars/tests/unit/operations/test_merge_sorted.py +++ b/py-polars/tests/unit/operations/test_merge_sorted.py @@ -1,3 +1,5 @@ +from datetime import time + import pytest from hypothesis import given @@ -58,6 +60,7 @@ def test_merge_sorted_decimal_20990(precision: int) -> None: assert_series_equal(result, expected) +@pytest.mark.may_fail_auto_streaming def test_merge_sorted_categorical() -> None: left = pl.Series("a", ["a", "b"], pl.Categorical()).sort().to_frame() right = pl.Series("a", ["a", "b", "b"], pl.Categorical()).sort().to_frame() @@ -139,6 +142,9 @@ def test_merge_sorted_parametric(lhs: pl.Series, rhs: pl.Series) -> None: excluded_dtypes=[ pl.Struct, # Bug. See https://github.com/pola-rs/polars/issues/20986 pl.Binary, # Bug. See https://github.com/pola-rs/polars/issues/20988 + pl.Categorical( + ordering="lexical" + ), # Bug. See https://github.com/pola-rs/polars/issues/21025 ], allow_null=False, # See: https://github.com/pola-rs/polars/issues/20991 ), @@ -150,3 +156,11 @@ def test_merge_sorted_self_parametric(s: pl.Series) -> None: append_sorted = s.append(s).sort() assert_series_equal(merge_sorted, append_sorted) + + +# This was an encountered bug in the streaming engine, it was actually a bug +# with split_at. +def test_merge_time() -> None: + s = pl.Series("a", [time(0, 0)], pl.Time) + df = pl.DataFrame([s]) + assert df.merge_sorted(df, "a").get_column("a").dtype == pl.Time()