Chryso
Chryso is a Calcite-style SQL parser + optimizer engine in Rust. It focuses on a clean, modular pipeline (AST -> logical plan -> Cascades optimizer -> physical plan -> adapter) and keeps the core engine execution-agnostic.
Features
- Multi-dialect SQL parsing (Postgres + MySQL first)
- Cascades optimizer with logical and physical rules
- Cost and statistics hooks via ANALYZE and a lightweight catalog
- Adapter-based execution (DuckDB first, Velox next)
Status
- Parser, planner, and core Cascades skeleton are implemented
- DuckDB adapter translates physical plans to SQL and executes simple queries/DML
- CI builds and tests with and without the DuckDB feature
Workspace Layout
crates/
core/ AST, errors, formatting helpers
parser/ Dialect-aware parser
planner/ Logical/physical plan definitions + builder
optimizer/ Cascades skeleton (memo, rules, cost)
metadata/ Catalog, stats cache, analyze hooks
adapter/ Execution adapters (DuckDB, mock)
parser_yacc/ Yacc scaffold (validation)
src/
lib.rs Facade crate re-exports
bin/
chryso-cli.rs
Quick Start
Run the CLI (mock adapter by default):
Run the DuckDB demo:
Tests
All tests:
With DuckDB:
Plan snapshot tests:
- Inputs:
tests/testdata/plan/case1/in.json - Expected outputs:
tests/testdata/plan/case1/out.json
Record snapshots:
CHRYSO_RECORD=1
Docs
docs/ARCHITECTURE.mdfor the planning pipeline and module overviewdocs/RULES.mdfor rule conventions and current rule setdocs/ADAPTERS.mdfor adapter designdocs/ROADMAP.mdfor milestones and TODOs
Roadmap (Highlights)
- Parser: expand dialect coverage and AST compatibility
- Logical rewrites: constant folding and predicate simplification
- Cascades: richer rule library and join order enumeration
- Costing: integrate ANALYZE stats into cost models
- Physical planning: enforcers and required properties
- Adapters: stabilize DuckDB, then add Velox
License
TBD.