Skip to content

Scope extension-relation schema derivers to the ExtensionRegistry instead of a process-global #206

Description

@nielspardon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions