Skip to content

Commit

Permalink
non-strict cast should always block predicate pushdown on that col (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Feb 10, 2022
1 parent 6f4d2a3 commit a04786c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ pub(super) fn other_column_is_pushdown_boundary(node: Node, expr_arena: &Arena<A
| AExpr::Function {options: FunctionOptions { collect_groups: ApplyOptions::ApplyList, .. }, ..}
| AExpr::BinaryExpr {..}
| AExpr::Cast {data_type: DataType::Float32 | DataType::Float64, ..}
// cast may create nulls
| AExpr::Cast {strict: false, ..}
// still need to investigate this one
| AExpr::Explode {..}
// A groupby needs all rows for aggregation
Expand Down
22 changes: 22 additions & 0 deletions polars/polars-lazy/src/tests/predicate_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,25 @@ fn test_filter_nulls_created_by_join() -> Result<()> {

Ok(())
}

#[test]
fn test_filter_null_creation_by_cast() -> Result<()> {
let df = df![
"int" => [1, 2, 3],
"empty" => ["", "", ""]
]?;

let out = df
.lazy()
.with_column(col("empty").cast(DataType::Int32).alias("empty"))
.filter(col("empty").is_null().and(col("int").eq(lit(3i32))))
.collect()?;

let expected = df![
"int" => [3],
"empty" => &[None, Some(1i32)][..1]
]?;
assert!(out.frame_equal_missing(&expected));

Ok(())
}

0 comments on commit a04786c

Please sign in to comment.