jackwener commented on code in PR #5335:
URL: https://github.com/apache/arrow-datafusion/pull/5335#discussion_r1113015207
##########
datafusion/common/src/dfschema.rs:
##########
@@ -284,12 +284,29 @@ impl DFSchema {
match matches.len() {
0 => Err(field_not_found(None, name, self)),
1 => Ok(matches[0]),
- _ => Err(DataFusionError::SchemaError(
- SchemaError::AmbiguousReference {
- qualifier: None,
- name: name.to_string(),
- },
- )),
+ _ => {
+ // When `matches` size > 1, it doesn't necessarily mean an
`ambiguous name` problem.
+ // Because name may generate from Alias/... . It means that it
don't own qualifier.
+ // For example:
+ // Join on id = b.id
+ // Project a.id as id TableScan b id
+ // In this case, there isn't `ambiguous name` problem. When
`matches` just contains
+ // one field without qualifier, we should return it.
+ let fields_without_qualifier = matches
+ .iter()
+ .filter(|f| f.qualifier.is_none())
+ .collect::<Vec<_>>();
+ if fields_without_qualifier.len() == 1 {
+ Ok(fields_without_qualifier[0])
Review Comment:
When `fields_without_qualifier` size > 1, we should still return a Error.
So we shouldn't use `find`
--
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]