Follow-up cleanup from review of #204 (non-blocking; not a correctness bug).
substrait.api's user-defined extension relations register their schema deriver in a process-global dict rather than on the ExtensionRegistry instance:
type_inference.register_extension_relation writes to the module-global _extension_relation_derivers (src/substrait/type_inference.py), keyed by type_url.
ExtensionRegistry.register_extension_relation also writes self._extension_relations[...], but that per-instance dict is never read by inference — it's effectively dead state.
Consequences:
- Two
ExtensionRegistry instances silently share one deriver map; registering a detail class on one changes schema derivation for plans built with another.
- Last-writer-wins if two detail classes share a
type_url.
- There is no way to unregister or isolate — state leaks across otherwise-independent registries (and across tests).
Every other registry capability is scoped to the instance; extension-relation derivation should be too. Suggested direction: store derivers on the ExtensionRegistry and have _derive_extension_schema consult the registry already threaded through inference, then drop the global and the dead instance dict.
🤖 Filed with AI assistance as a follow-up to #204.
Follow-up cleanup from review of #204 (non-blocking; not a correctness bug).
substrait.api's user-defined extension relations register their schema deriver in a process-global dict rather than on theExtensionRegistryinstance:type_inference.register_extension_relationwrites to the module-global_extension_relation_derivers(src/substrait/type_inference.py), keyed bytype_url.ExtensionRegistry.register_extension_relationalso writesself._extension_relations[...], but that per-instance dict is never read by inference — it's effectively dead state.Consequences:
ExtensionRegistryinstances silently share one deriver map; registering a detail class on one changes schema derivation for plans built with another.type_url.Every other registry capability is scoped to the instance; extension-relation derivation should be too. Suggested direction: store derivers on the
ExtensionRegistryand have_derive_extension_schemaconsult the registry already threaded through inference, then drop the global and the dead instance dict.🤖 Filed with AI assistance as a follow-up to #204.