nl2sql

ASTPlannerNode

Overview


Responsibilities


Position in Execution Graph

Upstream:

Downstream:

Trigger conditions:

flowchart LR
    SchemaRetriever[SchemaRetrieverNode] --> Planner[ASTPlannerNode] --> Validator[LogicalValidatorNode]
    Refiner[RefinerNode] --> Planner
    Planner --> RetryHandler[retry_handler]

Inputs

From SubgraphExecutionState:

Validation performed:


Outputs

Mutations to SubgraphExecutionState:

Side effects:


Internal Flow (Step-by-Step)

  1. Serialize relevant_tables to JSON text.
  2. Build feedback string from existing errors.
  3. Build expected_schema payload from sub‑query.
  4. Invoke the LLM chain with prompt + structured output (PlanModel).
  5. Return ASTPlannerResponse with plan and reasoning.
  6. On exception, emit PLANNING_FAILURE error and return plan=None.

Contracts & Interfaces

Implements a LangGraph node callable:

def __call__(self, state: SubgraphExecutionState) -> Dict[str, Any]

Key contracts:


Determinism Guarantees


Error Handling

Emits PipelineError with:

Logs failures via logger.exception.


Retry + Idempotency


Performance Characteristics


Observability


Configuration


Extension Points


Known Limitations