jonahgao commented on code in PR #12467:
URL: https://github.com/apache/datafusion/pull/12467#discussion_r1766072983


##########
datafusion/common/src/dfschema.rs:
##########
@@ -412,17 +412,32 @@ impl DFSchema {
         }
     }
 
+    /// Check whether the column reference is ambiguous
+    pub fn check_ambiguous_name(

Review Comment:
   We also need add `check_ambiguous_name` at 
[L132](https://github.com/apache/datafusion/blob/21e35eeb4e106835cc059205315d94ad0201a921/datafusion/sql/src/expr/identifier.rs#L146).
   
   The changes to `qualified_field_with_name` will cause the following query to 
produce an incorrect result.
   ```sh
   DataFusion CLI v41.0.0
   > create table t1(v1 int) as values(100);
   0 row(s) fetched.
   
   > select t1.v1 from t1 join t1 using(v1) cross join (select struct('foo' as 
v1) as t1);
   +--------+
   | t1[v1] |
   +--------+
   | foo    |
   +--------+
   ```
   On the main branch, it gives
   ```sh
   > select t1.v1 from t1 join t1 using(v1) cross join (select struct('foo' as 
v1) as t1);
   +-----+
   | v1  |
   +-----+
   | 100 |
   +-----+
   ```
   This is because it breaks 
[search_dfschema](https://github.com/apache/datafusion/blob/21e35eeb4e106835cc059205315d94ad0201a921/datafusion/sql/src/expr/identifier.rs#L274),
 making it unable to find `t1.v1`, but instead found the nested column `t1`.
   
   



-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to