aiondb-planner

Turns parser AST into a LogicalPlan. The planner binds names against the catalog, type-checks expressions, rewrites pg_catalog and information_schema references into virtual scans, and dispatches Cypher statements to a separate Cypher plan builder.

cargo

[dependencies]
aiondb-planner = { path = "../aiondb-planner" }

modules

modulepurpose
binderResolves identifiers against the catalog and produces BoundStatement variants.
type_checkWalks the bound AST, assigns DataTypes to every expression, applies coercions.
logical_builderBuilds the actual LogicalPlan from typed/bound statements.
pg_catalogSynthetic pg_catalog tables and the synthetic relation-id allocator.
information_schemaSynthetic information_schema tables.

key types

entry points

itemrole
Planner::new(catalog)Build a planner backed by a CatalogReader.
Planner::plan(req)Bind, type-check and lower a Statement to LogicalPlan.
type_check_expression, type_check_expression_with_relation, type_check_expression_with_relation_and_session_contextStandalone expression type-checking helpers, used by other crates that need to type a single expression outside of a full statement.
is_virtual_synthetic_relation(id)Returns true when id denotes a synthetic pg_catalog or information_schema relation. Engines use this to distinguish "no physical storage by design" from "real storage failure".

example

use std::sync::Arc;
use aiondb_catalog::CatalogReader;
use aiondb_parser::parse_sql;
use aiondb_planner::{PlanRequest, Planner};
use aiondb_core::TxnId;

fn plan_first(catalog: Arc<dyn CatalogReader>, sql: &str, txn: TxnId) {
    let stmts = parse_sql(sql).expect("parse");
    let planner = Planner::new(catalog);
    let req = PlanRequest {
        statement: &stmts[0],
        txn_id: txn,
        default_schema: Some("public".to_string()),
        current_user: Some("alice".to_string()),
        session_user: Some("alice".to_string()),
        database_name: Some("aiondb".to_string()),
        datestyle: None,
        timezone: None,
    };
    let logical = planner.plan(req).expect("plan");
    let _ = logical;
}