alamb commented on code in PR #14109:
URL: https://github.com/apache/datafusion/pull/14109#discussion_r1914000944
##########
datafusion/optimizer/src/push_down_filter.rs:
##########
@@ -1001,23 +1002,34 @@ impl OptimizerRule for PushDownFilter {
// multiple window functions, each with potentially different
partition keys.
// Therefore, we need to ensure that any potential partition
key returned is used in
// ALL window functions. Otherwise, filters cannot be pushed
by through that column.
+ let extract_partition_keys = |func: &WindowFunction| {
+ func.partition_by
+ .iter()
+ .map(|c|
Column::from_qualified_name(c.schema_name().to_string()))
+ .collect::<HashSet<_>>()
+ };
let potential_partition_keys = window
.window_expr
.iter()
.map(|e| {
- if let Expr::WindowFunction(window_expression) = e {
- window_expression
- .partition_by
- .iter()
- .map(|c| {
- Column::from_qualified_name(
- c.schema_name().to_string(),
- )
- })
- .collect::<HashSet<_>>()
- } else {
- // window functions expressions are only
Expr::WindowFunction
- unreachable!()
+ match e {
+ Expr::WindowFunction(window_func) => {
+ extract_partition_keys(window_func)
+ }
+ Expr::Alias(alias) => {
+ if let Expr::WindowFunction(window_func) =
+ alias.expr.as_ref()
+ {
+ extract_partition_keys(window_func)
+ } else {
+ // window functions expressions are only
Expr::WindowFunction
+ unreachable!()
Review Comment:
maybe we can turn this into returning an internal error rather than a panic
for safety
--
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]