Skip to content

Defer REGISTRY import to fix empty validator snapshot#139

Open
cmttt wants to merge 2 commits intomainfrom
ls/lazy-query-registry
Open

Defer REGISTRY import to fix empty validator snapshot#139
cmttt wants to merge 2 commits intomainfrom
ls/lazy-query-registry

Conversation

@cmttt
Copy link
Collaborator

@cmttt cmttt commented Feb 13, 2026

Summary

Move the REGISTRY import from module-level to inside parse_query_to_validated_ast().

Problem

The query-language REGISTRY in ast_validator.py snapshots ValidatorRegistry.get_instance() at module import time. This import is triggered during engine bootstrap (via plugin_manager import chain) before bootstrap_ast_validators() populates the singleton. The snapshot captures an empty registry, so DruidQueryTransformer.transform_Call fails with KeyError on queries with UDF calls (e.g. DidAddLabel(...)).

Fix

Defer the REGISTRY import in __init__.py from module-level to inside parse_query_to_validated_ast(). The snapshot is then taken at first call (request time) when validators are already registered. One line removed, one line added.

Test plan

  • Existing query_language tests pass
  • Existing ast_druid_translator tests pass

@cmttt cmttt force-pushed the ls/lazy-query-registry branch from 3db2dcd to 339caee Compare February 13, 2026 03:30
@cmttt cmttt changed the title Defer query-language REGISTRY import to fix empty validator snapshot Bootstrap AST validators in ValidatorRegistry.get_instance() Feb 13, 2026
The query-language REGISTRY snapshots ValidatorRegistry.get_instance()
at import time. This import is triggered during engine bootstrap before
bootstrap_ast_validators() populates the singleton, resulting in an
empty REGISTRY and KeyError in DruidQueryTransformer on UDF queries.

Move the REGISTRY import into parse_query_to_validated_ast so the
snapshot is taken at first use (request time) when validators are
already registered.
@cmttt cmttt force-pushed the ls/lazy-query-registry branch from 339caee to c9e17cc Compare February 13, 2026 03:40
@cmttt cmttt changed the title Bootstrap AST validators in ValidatorRegistry.get_instance() Defer REGISTRY import to fix empty validator snapshot Feb 13, 2026
@cassidyjames cassidyjames requested review from a team as code owners March 4, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants