jayzhan211 commented on code in PR #14057:
URL: https://github.com/apache/datafusion/pull/14057#discussion_r1911886029


##########
datafusion/common/src/dfschema.rs:
##########
@@ -442,22 +603,24 @@ impl DFSchema {
 
     /// Find all fields that match the given name
     pub fn fields_with_unqualified_name(&self, name: &str) -> Vec<&Field> {
-        self.fields()
-            .iter()
-            .filter(|field| field.name() == name)
-            .map(|f| f.as_ref())
-            .collect()
+        let mut fields: Vec<&Field> = 
self.inner.fields_with_unqualified_name(name);
+        if let Some(schema) = self.metadata_schema() {
+            fields.append(&mut schema.fields_with_unqualified_name(name));

Review Comment:
   ```suggestion
               fields.append(schema.fields_with_unqualified_name(name));
   ```



##########
datafusion/common/src/dfschema.rs:
##########
@@ -442,22 +603,24 @@ impl DFSchema {
 
     /// Find all fields that match the given name
     pub fn fields_with_unqualified_name(&self, name: &str) -> Vec<&Field> {
-        self.fields()
-            .iter()
-            .filter(|field| field.name() == name)
-            .map(|f| f.as_ref())
-            .collect()
+        let mut fields: Vec<&Field> = 
self.inner.fields_with_unqualified_name(name);
+        if let Some(schema) = self.metadata_schema() {
+            fields.append(&mut schema.fields_with_unqualified_name(name));
+        }
+        fields
     }
 
     /// Find all fields that match the given name and return them with their 
qualifier
     pub fn qualified_fields_with_unqualified_name(
         &self,
         name: &str,
     ) -> Vec<(Option<&TableReference>, &Field)> {
-        self.iter()
-            .filter(|(_, field)| field.name() == name)
-            .map(|(qualifier, field)| (qualifier, field.as_ref()))
-            .collect()
+        let mut fields: Vec<(Option<&TableReference>, &Field)> =
+            self.inner.qualified_fields_with_unqualified_name(name);
+        if let Some(schema) = self.metadata_schema() {
+            fields.append(&mut 
schema.qualified_fields_with_unqualified_name(name));

Review Comment:
   ```suggestion
               
fields.append(schema.qualified_fields_with_unqualified_name(name));
   ```



##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -2600,6 +2619,16 @@ impl TableScan {
                 let df_schema = DFSchema::new_with_metadata(
                     p.iter()
                         .map(|i| {
+                            if *i >= schema.fields.len() {
+                                if let Some(metadata) = &metadata {
+                                    return (
+                                        Some(table_name.clone()),
+                                        Arc::new(
+                                            metadata.field(*i - 
METADATA_OFFSET).clone(),

Review Comment:
   handle where i < METADATA_OFFSET



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