Chryso is an HTAP optimizer engine in Rust. It aims to provide a Calcite-style planning core for hybrid transactional/analytical systems: parse SQL, build a dialect-neutral logical plan, explore alternatives with a Cascades optimizer, choose a costed physical plan, and lower that plan into execution engines such as DuckDB, Velox, or future storage/compute adapters.
The project keeps the optimizer engine execution-agnostic. SQL dialect support, statistics collection, cost modeling, physical properties, and executor adapters are explicit extension points so Chryso can evolve from a runnable demo pipeline into a reusable HTAP planning layer.
- Multi-dialect SQL front-end, with PostgreSQL and MySQL compatibility first.
- Dialect-neutral logical planning for scans, filters, projections, joins, aggregates, sorting, limits, subqueries, and DML/DDL hooks.
- Cascades-style optimizer with memo exploration, logical rewrites, physical implementation rules, physical property tracking, join ordering, and tracing.
- Cost and statistics hooks via
ANALYZE, a lightweight catalog, cardinality estimation, and cost profiles. - Execution-adapter boundary for HTAP backends, starting with DuckDB and Velox.
- Facade API and FFI/bindings scaffolding for embedding the optimizer in other systems.
- Parser, planner, metadata, and Cascades optimizer crates are implemented.
- Logical and physical plans cover the main MVP operators needed for HTAP query planning.
- DuckDB adapter translates physical plans to SQL and executes simple queries/DML.
- Velox adapter and FFI are available behind feature gates, with CI coverage for an exec-only build.
- CI builds and tests the core workspace with and without optional adapters.
crates/
core/ AST, errors, formatting helpers
parser/ Dialect-aware parser
planner/ Logical/physical plan definitions + builder
optimizer/ Property-driven Cascades search (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
Run the CLI (requires DuckDB feature):
cargo run --bin chryso-cli --features duckdbBuild with Bazel:
bazel build //:chryso
bazel build //:chryso_cliRun the DuckDB demo:
cargo run --example duckdb_demo --features duckdbAll tests:
cargo testWith DuckDB:
cargo test --features duckdbVelox exec-only build (FFI):
cmake -S ffi/velox -B ffi/velox/build \
-DCHRYSO_VELOX_USE_SUBMODULE=ON \
-DCHRYSO_VELOX_USE_ARROW=OFF \
-DCHRYSO_ARROW_STRICT_VERSION=OFF \
-DCHRYSO_VELOX_BUILD_TESTS=ON \
-DCHRYSO_VELOX_EXEC_ONLY=ON
cmake --build ffi/velox/build --parallelPlan 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_snapshotdocs/ARCHITECTURE.mdfor the planning pipeline and module overviewdocs/RULES.mdfor rule conventions and current rule setdocs/COST_MODEL.mdfor cost coefficients, stats fallback, and tuning workflowdocs/ADAPTERS.mdfor adapter designdocs/BAZEL.mdfor Bazel targets and scopedocs/ROADMAP.mdfor milestones and TODOs
- HTAP planning model: make transactional and analytical execution trade-offs visible in physical properties, costs, and adapter capabilities.
- Parser: expand PostgreSQL/MySQL dialect coverage and AST compatibility.
- Logical rewrites: deepen predicate inference, subquery decorrelation, and projection/column pruning.
- Cascades: improve rule scheduling, join order enumeration, and explainable optimizer traces.
- Costing: integrate richer
ANALYZEstatistics, histograms, calibration data, and backend-specific cost profiles. - Physical planning: strengthen distribution, ordering, parallelism, and enforcer handling for mixed OLTP/OLAP engines.
- Adapters: stabilize DuckDB, mature Velox, and keep the adapter API open for future HTAP storage/compute backends.
TBD.