alamb commented on code in PR #13187:
URL: https://github.com/apache/datafusion/pull/13187#discussion_r1823057420
##########
datafusion/physical-plan/src/filter.rs:
##########
@@ -371,7 +371,12 @@ impl ExecutionPlan for FilterExec {
/// The output statistics of a filtering operation can be estimated if the
/// predicate's selectivity value can be determined for the incoming data.
fn statistics(&self) -> Result<Statistics> {
- Self::statistics_helper(&self.input, self.predicate(),
self.default_selectivity)
+ let stats = Self::statistics_helper(
+ &self.input,
+ self.predicate(),
+ self.default_selectivity,
+ )?;
+ Ok(stats.project(self.projection.as_ref()))
Review Comment:
This is the bug fix
##########
datafusion/sqllogictest/test_files/parquet.slt:
##########
@@ -549,3 +549,52 @@ FixedSizeBinary(16) 0166ce1d46129ad104fa4990c6057c91
statement ok
DROP TABLE test_non_utf8_binary;
+
+
+## Tests for https://github.com/apache/datafusion/issues/13186
+statement ok
+create table cpu (time timestamp, usage_idle float, usage_user float, cpu int);
+
+statement ok
+insert into cpu values ('1970-01-01 00:00:00', 1.0, 2.0, 3);
+
+# must put it into a parquet file to get statistics
+statement ok
+copy (select * from cpu) to 'test_files/scratch/parquet/cpu.parquet';
+
+# Run queries against parquet files
+statement ok
+create external table cpu_parquet
+stored as parquet
+location 'test_files/scratch/parquet/cpu.parquet';
+
+# Double filtering
+#
+# Expect 1 row for both queries
+query PI
+select time, rn
+from (
+ select time, row_number() OVER (ORDER BY usage_idle, time) as rn
+ from cpu
+ where cpu = 3
+) where rn > 0;
+----
+1970-01-01T00:00:00 1
+
+query PI
+select time, rn
+from (
+ select time, row_number() OVER (ORDER BY usage_idle, time) as rn
+ from cpu_parquet
+ where cpu = 3
+) where rn > 0;
+----
+1970-01-01T00:00:00 1
Review Comment:
this query errors without the fix
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]