fix(plan): add explainer visit method for PhysicalLayerSchemaCreationStage - #5925
Open
nkwork9999 wants to merge 1 commit into
Open
Conversation
nkwork9999
force-pushed
the
fix/explainer-physical-layer-schema-creation-stage
branch
from
July 28, 2026 13:19
53cd09a to
6cffcaf
Compare
…Stage `RichExplainerConsole` had no `visit_physical_layer_schema_creation_stage`, so explaining a plan that includes `PhysicalLayerSchemaCreationStage` logged `ERROR - Unexpected stage: PhysicalLayerSchemaCreationStage` and silently omitted the stage from the explained plan. Add the missing visit method. It mirrors the schema derivation in `SnapshotEvaluator.create_physical_schemas` (non-symbolic models only, table name resolved through the deployability index) and lists the distinct physical schemas that will be created. `test_plan_explain` now asserts that no stage is reported as unexpected, which covers this stage and guards against the same omission for future ones. Fixes SQLMesh#5619 Signed-off-by: nkwork9999 <143652584+nkwork9999@users.noreply.github.com>
nkwork9999
force-pushed
the
fix/explainer-physical-layer-schema-creation-stage
branch
from
July 28, 2026 13:22
6cffcaf to
40e26aa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5619
Problem
RichExplainerConsolehas novisit_physical_layer_schema_creation_stage, so when a plan containsPhysicalLayerSchemaCreationStage,explain()falls into thehasattrguard atexplainer.py:134:The stage is then silently dropped from the explained plan, even though
PlanEvaluatorhandles it inevaluator.py:209.Change
Add the missing visit method. It mirrors the schema derivation in
SnapshotEvaluator.create_physical_schemas/_create_schemas— non-symbolic models only, table name resolved through the stage's deployability index, deduplicated by(db, catalog)— and lists the distinct physical schemas that will be created. ReturnsNonewhen there is nothing to create, consistent with the otherOptional[Tree]visit methods.Placed directly before
visit_physical_layer_update_stageto match the stage ordering produced instages.py.Output on
examples/sushi:Tests
test_plan_explainpreviously only asserted that explaining does not raise, which is why this went unnoticed. It now asserts that no stage is reported as unexpected, which covers this stage and guards against the same omission for stages added later.Verified the test fails on
mainwith the fix reverted:tests/core/test_plan.py,tests/core/test_plan_stages.py,tests/core/test_context.pyandtests/core/integration/test_plan_options.pypass (207 tests), as doruff format,ruff checkandmypyon the changed files.