Skip to content

Commit

Permalink
fix: replace n-th in filter (#11206)
Browse files Browse the repository at this point in the history
  • Loading branch information
reswqa authored Sep 20, 2023
1 parent db6aa20 commit 4390604
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/polars-plan/src/logical_plan/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,11 @@ impl LogicalPlanBuilder {
pub fn filter(self, predicate: Expr) -> Self {
let predicate = if has_expr(&predicate, |e| match e {
Expr::Column(name) => is_regex_projection(name),
Expr::Wildcard | Expr::RenameAlias { .. } | Expr::Columns(_) | Expr::DtypeColumn(_) => {
true
},
Expr::Wildcard
| Expr::RenameAlias { .. }
| Expr::Columns(_)
| Expr::DtypeColumn(_)
| Expr::Nth(_) => true,
_ => false,
}) {
let schema = try_delayed!(self.0.schema(), &self.0, into);
Expand Down
5 changes: 5 additions & 0 deletions py-polars/tests/unit/operations/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def test_simplify_expression_lit_true_4376() -> None:
).rows() == [(1, 2, 3), (4, 5, 6), (7, 8, 9)]


def test_filter_contains_nth_11205() -> None:
df = pl.DataFrame({"x": [False]})
assert df.filter(pl.first()).is_empty()


def test_melt_values_predicate_pushdown() -> None:
lf = pl.DataFrame(
{
Expand Down

0 comments on commit 4390604

Please sign in to comment.