andygrove commented on code in PR #4050:
URL: https://github.com/apache/arrow-datafusion/pull/4050#discussion_r1011992585


##########
datafusion/common/src/dfschema.rs:
##########
@@ -203,7 +203,20 @@ impl DFSchema {
                 // qualifier and name.
                 (Some(q), Some(field_q)) => q == field_q && field.name() == 
name,
                 // field to lookup is qualified but current field is 
unqualified.
-                (Some(_), None) => false,
+                (Some(qq), None) => {
+                    // the original field may now be aliased with a name that 
matches the
+                    // original qualified name
+                    let table_ref: TableReference = 
field.name().as_str().into();
+                    match table_ref {
+                        TableReference::Partial { schema, table } => {
+                            schema == qq && table == name
+                        }
+                        TableReference::Full { schema, table, .. } => {
+                            schema == qq && table == name
+                        }
+                        _ => false,
+                    }

Review Comment:
   Perhaps aliases should be `Column` instead of `String`?
   
   ```rust
   enum Expr {
     Alias(expr: Box<Expr>, alias: Column>
     ...
     }
   ```



-- 
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]

Reply via email to