Skip to content

Commit

Permalink
fix: Use physical for row-encoding (#18251)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Aug 18, 2024
1 parent bf82f3d commit 0e9914d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ pub fn _get_rows_encoded_compat_array(by: &Series) -> PolarsResult<ArrayRef> {
ca.physical().chunks[0].clone()
}
},
_ => by.to_arrow(0, CompatLevel::newest()),
// Take physical
_ => by.chunks()[0].clone(),
};
Ok(out)
}
Expand Down
22 changes: 22 additions & 0 deletions py-polars/tests/unit/test_rows.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import date

import pytest

import polars as pl
Expand Down Expand Up @@ -246,3 +248,23 @@ def test_row_constructor_uint64() -> None:
data=[[0], [int(2**63) + 1]], schema={"x": pl.UInt64}, orient="row"
)
assert df.rows() == [(0,), (9223372036854775809,)]


def test_physical_row_encoding() -> None:
dt_str = [
{
"ts": date(2023, 7, 1),
"files": "AGG_202307.xlsx",
"period_bins": [date(2023, 7, 1), date(2024, 1, 1)],
},
]

df = pl.from_dicts(dt_str)
df_groups = df.group_by("period_bins")
assert df_groups.all().to_dicts() == [
{
"period_bins": [date(2023, 7, 1), date(2024, 1, 1)],
"ts": [date(2023, 7, 1)],
"files": ["AGG_202307.xlsx"],
}
]

0 comments on commit 0e9914d

Please sign in to comment.