You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jackwener (via GitHub)" <gi...@apache.org> on 2023/02/21 12:56:38 UTC

[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5335: bugfix: fix tpcds_logical_q8 ambiguous name.

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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org