You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2023/01/04 13:04:38 UTC
[GitHub] [arrow-datafusion] HaoYang670 commented on a diff in pull request #4797: rewrite the function `ensure_any_column_reference_is_unambiguous`
HaoYang670 commented on code in PR #4797:
URL: https://github.com/apache/arrow-datafusion/pull/4797#discussion_r1061462002
##########
datafusion/sql/src/planner.rs:
##########
@@ -3251,43 +3251,44 @@ fn ensure_any_column_reference_is_unambiguous(
if schemas.len() == 1 {
return Ok(());
}
-
- // extract columns both in one more schemas.
- let mut column_count_map: HashMap<&str, usize> = HashMap::new();
- schemas
+ // all referenced columns in the expression that don't have relation
+ let referenced_cols = expr.to_columns()?;
+ let mut no_relation_cols = referenced_cols
+ .iter()
+ .filter_map(|col| {
+ if col.relation.is_none() {
+ Some((col.name.as_str(), 0))
+ } else {
+ None
+ }
+ })
+ .collect::<HashMap<&str, u8>>();
+ // find the name of the column existing in multi schemas.
+ let ambiguous_col_name = schemas
.iter()
.flat_map(|schema| schema.fields())
- .for_each(|field| {
- column_count_map
- .entry(field.name())
- .and_modify(|v| *v += 1)
- .or_insert(1usize);
+ .map(|field| field.name())
Review Comment:
Op, sorry we could not do this as the return type of `fields()` is `Vec<DFField>`.
--
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-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org