alamb commented on code in PR #17757:
URL: https://github.com/apache/datafusion/pull/17757#discussion_r2379502030
##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -618,12 +618,12 @@ async fn test_aggregate_with_pk2() -> Result<()> {
let df = df.filter(predicate)?;
assert_snapshot!(
physical_plan_to_string(&df).await,
- @r###"
- CoalesceBatchesExec: target_batch_size=8192
- FilterExec: id@0 = 1 AND name@1 = a
- AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[]
+ @r"
+ AggregateExec: mode=Single, gby=[id@0 as id, name@1 as name], aggr=[],
ordering_mode=Sorted
+ CoalesceBatchesExec: target_batch_size=8192
+ FilterExec: id@0 = 1 AND name@1 = a
DataSourceExec: partitions=1, partition_sizes=[1]
- "###
+ "
Review Comment:
The only changes I can see is the filter being pushed below the aggregate
exec, which seems like an improvement to me
##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -1647,6 +1677,41 @@ mod tests {
)
}
+ /// verifies that filters with unusual identifier names are pushed down
through window functions
+ #[test]
+ fn filter_window_special_identifier() -> Result<()> {
+ let schema = Schema::new(vec![
+ Field::new("$a", DataType::UInt32, false),
+ Field::new("$b", DataType::UInt32, false),
+ Field::new("$c", DataType::UInt32, false),
+ ]);
+ let table_scan = table_scan(Some("test"), &schema, None)?.build()?;
+
+ let window = Expr::from(WindowFunction::new(
+ WindowFunctionDefinition::WindowUDF(
+ datafusion_functions_window::rank::rank_udwf(),
+ ),
+ vec![],
+ ))
+ .partition_by(vec![col("$a"), col("$b")])
+ .order_by(vec![col("$c").sort(true, true)])
+ .build()
+ .unwrap();
+
+ let plan = LogicalPlanBuilder::from(table_scan)
+ .window(vec![window])?
+ .filter(col("$b").gt(lit(10i64)))?
+ .build()?;
+
+ assert_optimized_plan_equal!(
+ plan,
+ @r"
+ WindowAggr: windowExpr=[[rank() PARTITION BY [test.$a, test.$b] ORDER
BY [test.$c ASC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]
+ TableScan: test, full_filters=[test.$b > Int64(10)]
Review Comment:
nice to see this pushed down
--
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]