alamb commented on code in PR #14684:
URL: https://github.com/apache/datafusion/pull/14684#discussion_r2110094173
##########
datafusion/core/src/dataframe/mod.rs:
##########
@@ -1972,41 +1972,85 @@ impl DataFrame {
.config_options()
.sql_parser
.enable_ident_normalization;
+
let old_column: Column = if ident_opts {
Column::from_qualified_name(old_name)
} else {
Column::from_qualified_name_ignore_case(old_name)
};
- let (qualifier_rename, field_rename) =
- match self.plan.schema().qualified_field_from_column(&old_column) {
- Ok(qualifier_and_field) => qualifier_and_field,
- // no-op if field not found
- Err(DataFusionError::SchemaError(
- SchemaError::FieldNotFound { .. },
- _,
- )) => return Ok(self),
- Err(err) => return Err(err),
- };
- let projection = self
- .plan
- .schema()
- .iter()
- .map(|(qualifier, field)| {
- if qualifier.eq(&qualifier_rename) && field.as_ref() ==
field_rename {
- (
- col(Column::from((qualifier, field)))
- .alias_qualified(qualifier.cloned(), new_name),
- false,
- )
- } else {
- (col(Column::from((qualifier, field))), false)
- }
- })
- .collect::<Vec<_>>();
- let project_plan = LogicalPlanBuilder::from(self.plan)
- .project_with_validation(projection)?
- .build()?;
+ let project_plan = if let LogicalPlan::Projection(Projection {
Review Comment:
to be clear, the projections are flattened as part of the planning process
right? So this PR mostly is about making logical EXPLAIN plans look nicer with
`with_column_renamed`?
If so it seems like a lot of complexity for (just) that feature. Maybe we
can switch to showing optimized explain plans or something for people who want
to see a simpler version
--
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]