cetra3 commented on code in PR #26630:
URL: https://github.com/apache/datafusion/pull/26630#discussion_r4384281812


##########
datafusion/common/src/dfschema.rs:
##########
@@ -1766,6 +1930,135 @@ mod tests {
         Ok(())
     }
 
+    /// Builds a schema of `fields` padded with uniquely named fields to 
`width`.
+    /// Bypasses `check_names`, since `merge` can produce the same name both
+    /// qualified and unqualified.
+    fn name_lookup_schema(
+        fields: &[(Option<TableReference>, &str)],
+        width: usize,
+    ) -> DFSchema {
+        let mut qualifiers = vec![];
+        let mut arrow_fields = vec![];
+        for (qualifier, name) in fields {
+            qualifiers.push(qualifier.clone());
+            arrow_fields.push(Field::new(*name, DataType::Int32, true));
+        }
+        for i in fields.len()..width {
+            qualifiers.push(Some(TableReference::bare("pad")));
+            arrow_fields.push(Field::new(format!("pad_{i}"), DataType::Int32, 
true));
+        }
+        DFSchema {
+            inner: Arc::new(Schema::new(arrow_fields)),
+            field_qualifiers: qualifiers,
+            functional_dependencies: FunctionalDependencies::empty(),
+            name_index: OnceLock::new(),
+        }
+    }
+
+    /// The name lookups as they were before the name index, kept as a 
reference.
+    fn scan_index_of_column_by_name(
+        schema: &DFSchema,
+        qualifier: Option<&TableReference>,
+        name: &str,
+    ) -> Option<usize> {
+        schema.iter().position(|(q, f)| match (qualifier, q) {
+            (Some(q), Some(field_q)) => q.resolved_eq(field_q) && f.name() == 
name,
+            (Some(_), None) => false,
+            (None, _) => f.name() == name,
+        })
+    }
+
+    #[test]
+    fn name_index_matches_scan() {

Review Comment:
   This has been updated



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to