Skip to content

Commit

Permalink
working version trial 2
Browse files Browse the repository at this point in the history
  • Loading branch information
barak1412 committed Sep 18, 2024
1 parent 997966d commit 28658bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions crates/polars-core/src/chunked_array/struct_/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ impl StructChunked {
pub fn zip_outer_validity(&mut self, other: &StructChunked) {
if self.chunks.len() != other.chunks.len()
|| !self
.chunks
.iter()
.zip(other.chunks.iter())
.map(|(a, b)| a.len() == b.len())
.all_equal()
.chunks
.iter()
.zip(other.chunks.iter())
.map(|(a, b)| a.len() == b.len())
.all_equal()
{
*self = self.rechunk();
let other = other.rechunk();
Expand Down
5 changes: 5 additions & 0 deletions crates/polars-plan/src/plans/conversion/dsl_to_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,11 @@ fn expand_filter(
| Expr::DtypeColumn(_)
| Expr::IndexColumn(_)
| Expr::Nth(_) => true,
#[cfg(feature = "dtype-struct")]
Expr::Function {
function: FunctionExpr::StructExpr(StructFunction::FieldByIndex(_)),
..
} => true,
_ => false,
}) {
let mut rewritten = rewrite_projections(vec![predicate], &schema, &[], opt_flags)?;
Expand Down
2 changes: 1 addition & 1 deletion py-polars/tests/unit/operations/namespaces/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_field_by_index_18732() -> None:
df = pl.DataFrame({"foo": [{"a": 1, "b": 2}, {"a": 2, "b": 1}]})

# illegal upper bound
with pytest.raises(OutOfBoundsError, match=r"Given field index 2 is out of bound"):
with pytest.raises(OutOfBoundsError, match=r"index 2 for length: 2"):
df.filter(pl.col.foo.struct[2] == 1)

# legal
Expand Down

0 comments on commit 28658bb

Please sign in to comment.