LiaCastaneda commented on code in PR #16064: URL: https://github.com/apache/datafusion/pull/16064#discussion_r2095705227
########## datafusion/core/src/physical_planner.rs: ########## @@ -2069,29 +2071,37 @@ fn maybe_fix_physical_column_name( expr: Result<Arc<dyn PhysicalExpr>>, input_physical_schema: &SchemaRef, ) -> Result<Arc<dyn PhysicalExpr>> { - if let Ok(e) = &expr { - if let Some(column) = e.as_any().downcast_ref::<Column>() { - let physical_field = input_physical_schema.field(column.index()); - let expr_col_name = column.name(); - let physical_name = physical_field.name(); - - if physical_name != expr_col_name { - // handle edge cases where the physical_name contains ':'. - let colon_count = physical_name.matches(':').count(); - let mut splits = expr_col_name.match_indices(':'); - let split_pos = splits.nth(colon_count); - - if let Some((idx, _)) = split_pos { - let base_name = &expr_col_name[..idx]; - if base_name == physical_name { - let updated_column = Column::new(physical_name, column.index()); - return Ok(Arc::new(updated_column)); + expr.and_then(|e| { + e.transform_down(|node| { Review Comment: Sometimes `Columns` are inside other type of expression (they are not "top level") , for example: ``` BinaryExpr { left: IsNotNull( Column( Column { relation: Some( Bare { table: "left", }, ), name: "people_column", }, ), ), op: Or, right: IsNotNull( Column( Column { relation: Some( Bare { table: "left", }, ), name: "people_column:1", }, ), ), }, ``` if so [the current fix](https://github.com/apache/datafusion/blob/3e30f77f08aa9184029da80c7f7e2ec00999fa44/datafusion/core/src/physical_planner.rs#L2068) won't apply, this change handles those cases -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org