blaginin commented on code in PR #14684:
URL: https://github.com/apache/datafusion/pull/14684#discussion_r2121659097
##########
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:
It is indeed removed at the optimisation step! The idea behind that PR was
that sometimes you might want to call functions involving expr tree traversal
before performing optimisations. For example:
1. Create a df
2. Rename a lot of columns
3. Call something like `replace_params_with_values` ← then, it'll iterate
over a lot of projection layers
However, after revisiting the PR half a year later 😁, I feel like:
- this isn't actually a problem (spent 30 mins and couldn't easily reproduce
the problem)
- it's very niche
- it does make the code more complicated
So I'll close the PR for now, but will keep an eye on related issues and
resubmit if it turns out to be a real problem.
--
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]