nl2sql

GeneratorNode

Overview


Responsibilities


Position in Execution Graph

Upstream:

Downstream:

Trigger conditions:

flowchart LR
    Validator[LogicalValidatorNode] --> Generator[GeneratorNode] --> Executor[ExecutorNode]

Inputs

From SubgraphExecutionState:

From NL2SQLContext:

Validation performed:


Outputs

Mutations to SubgraphExecutionState:

Side effects:


Internal Flow (Step-by-Step)

  1. Validate presence of datasource ID and plan.
  2. Resolve adapter and dialect.
  3. Compute effective limit from plan/adapter row limit.
  4. Traverse AST with SqlVisitor to build sqlglot expression tree.
  5. Render SQL with query.sql(dialect=...).
  6. Return GeneratorResponse with SQL and reasoning.
  7. On exception, emit SQL_GEN_FAILED.

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 exceptions via logger.exception.


Retry + Idempotency


Performance Characteristics


Observability


Configuration


Extension Points


Known Limitations