Skip to content

Commit

Permalink
perf: avoid repeat format in calc_func_dependencies_for_project (#12305)
Browse files Browse the repository at this point in the history
  • Loading branch information
haohuaijin authored Sep 4, 2024
1 parent 5ff5a6c commit 6bbad7e
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions datafusion/expr/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2793,22 +2793,28 @@ fn calc_func_dependencies_for_project(
.filter_map(|(qualifier, f)| {
let flat_name = qualifier
.map(|t| format!("{}.{}", t, f.name()))
.unwrap_or(f.name().clone());
.unwrap_or_else(|| f.name().clone());
input_fields.iter().position(|item| *item == flat_name)
})
.collect::<Vec<_>>(),
)
}
Expr::Alias(alias) => Ok(input_fields
.iter()
.position(|item| *item == format!("{}", alias.expr))
.map(|i| vec![i])
.unwrap_or(vec![])),
_ => Ok(input_fields
.iter()
.position(|item| *item == format!("{}", expr))
.map(|i| vec![i])
.unwrap_or(vec![])),
Expr::Alias(alias) => {
let name = format!("{}", alias.expr);
Ok(input_fields
.iter()
.position(|item| *item == name)
.map(|i| vec![i])
.unwrap_or(vec![]))
}
_ => {
let name = format!("{}", expr);
Ok(input_fields
.iter()
.position(|item| *item == name)
.map(|i| vec![i])
.unwrap_or(vec![]))
}
})
.collect::<Result<Vec<_>>>()?
.into_iter()
Expand Down

0 comments on commit 6bbad7e

Please sign in to comment.