Skip to content

Commit

Permalink
fix(rust, python): evaluate whole branch expression to determine if r… (
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Dec 21, 2022
1 parent 43598c3 commit 7f304e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions polars/polars-lazy/polars-pipe/src/pipeline/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ where
match &payload.file_type {
FileType::Parquet(options) => {
Box::new(ParquetSink::new(path, *options, input_schema.as_ref())?)
as Box<dyn Sink>
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions polars/polars-lazy/src/physical_plan/expressions/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,20 @@ mod stats {

impl BinaryExpr {
fn impl_should_read(&self, stats: &BatchStats) -> PolarsResult<bool> {
// See: #5864 for the rationale behind this.
use Expr::*;
use Operator::*;
if !self.expr.into_iter().all(|e| match e {
BinaryExpr { op, .. } => !matches!(
op,
Multiply | Divide | TrueDivide | FloorDivide | Modulus | Eq | NotEq
),
Column(_) | Literal(_) | Alias(_, _) => true,
_ => false,
}) {
return Ok(true);
}

let schema = stats.schema();
let fld_l = self.left.to_field(schema)?;
let fld_r = self.right.to_field(schema)?;
Expand Down
4 changes: 4 additions & 0 deletions py-polars/tests/unit/io/test_lazy_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ def test_parquet_stats(io_test_dir: str) -> None:
assert (
pl.scan_parquet(file).filter(4 < pl.col("a")).select(pl.col("a").sum())
).collect()[0, "a"] == 10.0
assert pl.scan_parquet(file).filter((pl.col("a") * 10) > 5.0).collect().shape == (
8,
1,
)


def test_row_count_schema(io_test_dir: str) -> None:
Expand Down

0 comments on commit 7f304e6

Please sign in to comment.