Embeddable analytical query engine for MoonBit: run SQL over CSV/Parquet files, native and WebAssembly from one codebase.
Dependencies
Status: all 22 TPC-H queries pass on official texts. The evaluator is columnar — vectorized expression kernels, a columnar hash join, and bind-time projection pruning — but APIs may still change.
uv run --with duckdb python harness/gen_tpch.py # TPC-H SF0.01 data + goldens
bash harness/check_all.sh # 27 goldens: all PASS (22 TPC-H + parquet + 3 multi-row-group)
MOONLAKE_DATA=harness/data/sf01 bash harness/check_all.sh # same at SF0.1 (regenerate first: gen_tpch.py 0.1)| query | moonlake native | duckdb |
|---|---|---|
| Pricing Summary Report | 183 ms | 3.3 ms |
| Shipping Priority | 142 ms | 4.1 ms |
| Local Supplier Volume | 151 ms | 4.1 ms |
| Forecasting Revenue Change | 124 ms | 0.8 ms |
| Volume Shipping | 166 ms | 4.7 ms |
| Returned Item Reporting | 143 ms | 7.4 ms |
| Shipping Modes and Order Priority | 147 ms | 3.3 ms |
| Promotion Effect | 122 ms | 1.4 ms |
git clone https://github.com/superbigcup325/moonlake && cd moonlake
moon run cmd/main -- exec --csv harness/data/sf001/lineitem.csv \
"SELECT l_returnflag, sum(l_extendedprice) FROM lineitem WHERE l_shipdate <= date '1998-09-02' GROUP BY l_returnflag ORDER BY l_returnflag"
# l_returnflag|sum_2
# A|532348211.6499983
# ...moon build cmd/main --target native --release
install -m755 _build/native/release/build/cmd/main/main.exe ~/.local/bin/moonlake
moonlake exec --csv lineitem.csv --file q6.sql # SQL from a file: no shell quotingmoon add superbigcup325/moonlakemoon add gives you the latest release from mooncakes (0.3.1). Everything this README describes is in it.
moon update # refresh the registry index; the graph downloads on the first check
moon checkln -s ../colenc .colenc
printf 'members = [".", "./.colenc"]\n' > moon.work// a @catalog.Catalog with registered table entries — @csv/@parquet
// scan into one; note the argument order: content/name, not name/content.
// registration is lazy: the schema is available at once, and a query decodes
// only the columns it projects, in 4096-row batches
///|
fn main raise {
let cat = @catalog.Catalog::new()
cat.register(@csv.scan_string("region,amount\nnorth,100\n", "events"))
// read results back cell by cell: names() gives the columns,
// row_count() the rows, get(row, col) a @types.Scalar (null via Null)
let result = @moonlake.execute(
"SELECT region, count(*) FROM events GROUP BY region", cat,
)
for r in 0..<result.row_count() {
println(result.get(r, 0).to_string() + "|" + result.get(r, 1).to_string())
}
}| project | what it is | boundary with moonlake |
|---|---|---|
| moonbit-community/sqlparser | SQL lexer/parser (AST) | parsing only, no execution; moonlake runs on its own in-house front-end (lexer, parser, AST in the in-repo sql package) and that is the roadmap, not a placeholder: sqlparser's select-statement AST is not destructurable cross-package, so the relationship is upstream cooperation (issues/PRs), not a planned swap-in |
| apache/parquet-format | Parquet format and encoding specs | moonlake implements the decoding itself (no dependency): the reader follows the specs and is diffed against DuckDB answers, so the format work is in-repo while the specification stays upstream |
| shunge/arrow (MoonArrow) | Arrow IPC format read/write | memory-format interchange; a future to_arrow bridge is cooperation, not competition |
| uiwcvb/moonsql | embedded OLTP database (row storage, CRUD, persistence) | different species — SQLite to moonlake's DuckDB: transactional storage vs external-file analytics |
| f4ah6o/duckdb, mizchi/duckdb | DuckDB C++ bindings | FFI route: the wasm-gc target is a stub upstream and the binding build is unstable; moonlake is pure MoonBit and runs natively in the browser |
moon check # type-check
moon test # run tests
moon fmt # format
moon run cmd/main # run the CLI
git config core.hooksPath hooks # once per clone: pre-commit gatelet VERSION : StringInstall
Download zipEmbeddable analytical query engine for MoonBit: run SQL over CSV/Parquet files, native and WebAssembly from one codebase.
Dependencies