chryso

Crates.iochryso
lib.rschryso
version0.0.1
created_at2026-01-23 17:59:15.192617+00
updated_at2026-01-23 17:59:15.192617+00
descriptionChryso is a Calcite-style SQL parser + optimizer engine in Rust.
homepagehttps://github.com/hawkingrei/chryso
repositoryhttps://github.com/hawkingrei/chryso
max_upload_size
id2065169
size168,348
Weizhen Wang (hawkingrei)

documentation

https://docs.rs/chryso

README

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):

cargo run --bin chryso-cli

Run the DuckDB demo:

cargo run --example duckdb_demo --features duckdb

Tests

All tests:

cargo test

With DuckDB:

cargo test --features duckdb

Plan snapshot tests:

  • Inputs: tests/testdata/plan/case1/in.json
  • Expected outputs: tests/testdata/plan/case1/out.json

Record snapshots:

CHRYSO_RECORD=1 cargo test --test plan_snapshot

Docs

  • docs/ARCHITECTURE.md for the planning pipeline and module overview
  • docs/RULES.md for rule conventions and current rule set
  • docs/ADAPTERS.md for adapter design
  • docs/ROADMAP.md for 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.

Commit count: 12

cargo fmt