{"record":{"id":"79c8524273c4940f","repo":"pola-rs/polars","slug":"invalid-plan-stage-plan-stage","errorCode":null,"errorMessage":"invalid plan stage '{plan_stage}'","messagePattern":"invalid plan stage '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/frame.py","lineNumber":1596,"sourceCode":"        if plan_stage is None:\n            warnings.warn(\n                \"The default value of `plan_stage` will change from 'ir' to 'physical' in Polars 2.0. \"\n                'Explicitly set `plan_stage=\"ir\"` to suppress this warning.',\n                category=FutureWarning,\n                stacklevel=find_stacklevel(),\n            )\n            plan_stage = \"ir\"\n\n        if plan_stage == \"ir\":\n            dot = _ldf.to_dot(optimized)\n        elif plan_stage == \"physical\":\n            if engine_.plan_engine == \"streaming\":\n                dot = _ldf.to_dot_streaming_phys(optimized)\n            else:\n                dot = _ldf.to_dot(optimized)\n        else:\n            error_msg = f\"invalid plan stage '{plan_stage}'\"\n            raise TypeError(error_msg)\n\n        return display_dot_graph(\n            dot=dot,\n            show=show,\n            output_path=output_path,\n            raw_output=raw_output,\n            figsize=figsize,\n        )\n\n    def inspect(self, fmt: str = \"{}\") -> LazyFrame:\n        \"\"\"\n        Inspect a node in the computation graph.\n\n        Print the value that this node in the computation graph evaluates to and pass on\n        the value.\n\n        .. engine-support:: in-memory\n","sourceCodeStart":1578,"sourceCodeEnd":1614,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/lazyframe/frame.py#L1578-L1614","documentation":"LazyFrame.show_graph() accepts plan_stage of only 'ir' (logical plan) or 'physical' (executed physical plan). Any other value raises TypeError. The physical stage additionally branches on the engine: streaming engines render the streaming physical plan, others the regular one.","triggerScenarios":"Calling lf.show_graph(plan_stage='optimized'), 'logical', 'dag', or None. Passing a variable that defaulted incorrectly, or using a value valid in a different polars version or in LazyFrame.explain() contexts.","commonSituations":"Typos; code written against older/newer APIs where stage names differed; interactive debugging of query plans.","solutions":["Use plan_stage='ir' for the logical plan view","Use plan_stage='physical' for the physical plan","Check the value at runtime for typos or None","Prefer lf.explain() when you only need the plan as text"],"exampleFix":"# before\nlf.show_graph(plan_stage='optimized')\n\n# after\nlf.show_graph(plan_stage='ir')","handlingStrategy":"validation","validationCode":"plan_stage = plan_stage if plan_stage in ('ir', 'physical') else 'ir'\nlf.show_graph(plan_stage=plan_stage)","typeGuard":"def is_valid_plan_stage(stage: str) -> bool:\n    return stage in {'ir', 'physical'}","tryCatchPattern":null,"preventionTips":["Use Literal['ir','physical'] typing for the parameter","Default the argument explicitly instead of deriving it from user input"],"tags":["polars","lazyframe","show-graph","plan-visualization"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}