Copilot commented on code in PR #24316:
URL: https://github.com/apache/datafusion/pull/24316#discussion_r3771977303
##########
datafusion/common/src/dfschema.rs:
##########
@@ -117,15 +116,55 @@ pub struct DFSchema {
field_qualifiers: Vec<Option<TableReference>>,
/// Stores functional dependencies in the schema.
functional_dependencies: FunctionalDependencies,
+ /// Lazily built accelerator for name lookups: maps a field name to the
+ /// ascending list of indices carrying it. Purely derived from `inner`, so
+ /// it takes no part in equality or `Debug`.
+ name_index: OnceLock<HashMap<String, Vec<usize>>>,
}
Review Comment:
`name_index` is cached derived state, but `DFSchema::merge(&mut self, ...)`
mutates `self.inner` / `field_qualifiers` in place without clearing the cache.
If `name_index()` has been initialized before `merge` runs, subsequent
`index_of_column_by_name` / `qualified_fields_with_unqualified_name` calls can
return stale results (missing newly merged fields). Consider resetting
`self.name_index` (e.g. `self.name_index = OnceLock::new()`) at the end of
`merge`.
--
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]