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


##########
datafusion/common/src/dfschema.rs:
##########
@@ -467,6 +464,36 @@ impl DFSchema {
             .collect()
     }
 
+    /// Find all fields that match the given name with qualifier and return 
them with their qualifier
+    pub fn qualified_fields_with_qualified_name(
+        &self,
+        qualifier: &TableReference,
+        name: &str,
+    ) -> Vec<(Option<&TableReference>, &Field)> {
+        self.iter()
+            .filter(|(q, f)| match (qualifier, q) {
+                // field to lookup is qualified.
+                // current field is qualified and not shared between 
relations, compare both
+                // qualifier and name.
+                (q, Some(field_q)) => q.resolved_eq(field_q) && f.name() == 
name,
+                // field to lookup is qualified but current field is 
unqualified.
+                (qq, None) => {
+                    // the original field may now be aliased with a name that 
matches the
+                    // original qualified name
+                    let column = Column::from_qualified_name(f.name());
+                    match column {
+                        Column {
+                            relation: Some(r),
+                            name: column_name,
+                        } => &r == qq && column_name == name,
+                        _ => false,
+                    }

Review Comment:
   Thanks!Refine this part by the clearer way.



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