Keep writing Polars. IbexEngine is a Polars execution
engine: you build a lazy query with the ordinary Polars API, choose the
engine when you collect, and get a real Polars DataFrame
back. Polars builds and optimizes the plan; Ibex executes all of it.
The engine runs every query of the
PDS-H benchmark
unchanged, with results that match Polars in full. It is still
experimental, and the adapter is pinned to Polars 2.1.0,
because it reads Polars' internal plan format, which can change between
releases.
Install
Install the wheel
Prebuilt wheels cover Python 3.11–3.14 on Linux x86_64
(glibc 2.28+) and Windows x86_64; no compiler is needed. They bundle the
native bridge and its Arrow libraries, and pull in
polars==2.1.0, pyarrow and numpy.
Install the current main:
CI rebuilds the wheels-latest prerelease on every push to
main. Its wheels carry development versions (such as
0.4.1.dev539), and pip skips those unless given
--pre. Tagged
releases
after v0.4.0 attach wheels too: to pin one, replace
wheels-latest with the release tag and drop
--pre.
To build the same wheel from a checkout, run
pip wheel --no-deps ./python (it compiles Arrow, so the
first build is slow).
Or build the native bridge
For development, you need Clang 20, CMake 3.31+, Ninja, and a Python with development
headers, pyarrow and polars==2.1.0 installed.
Build Ibex with the Python bridge and Parquet support, pointing CMake at
that Python:
The build produces the ibex_pyarrow extension in
build-release/python; the ibex_polars package
lives in python/. Python has to find both, from whatever
directory your code runs in. The simplest way is to register them with
the venv once; run this from the repository root:
From then on, the venv's Python imports the engine from any directory:
cd /anywhere && /path/to/Ibex/.venv/bin/python -c "from ibex_polars import IbexEngine; print('ok')"
If you would rather not touch the venv, set PYTHONPATH
instead. It has to hold absolute paths, so set it from the repository
root, and set it again in every new shell:
Sources can be resident DataFrames, as above, or a local
Parquet file through pl.scan_parquet(path), which Ibex reads
with its own lazy Parquet reader. To make Ibex the default for every
lazy collect, set the engine affinity:
pl.Config.set_engine_affinity(engine)
result = query.collect() # runs on Ibex
pl.Config.set_engine_affinity("auto") # back to Polars
To write the result to a file instead, sink it through the engine. The
query runs in Ibex and Polars' own Parquet writer writes the result
batch by batch as Ibex produces it, so the file is the one Polars would
write and every sink_parquet option works unchanged:
query.sink_parquet("out.parquet", engine=engine)
Prepare and explain
Translate once, collect many times
engine.prepare(query)
Translates the plan and binds its inputs without running it. The
first collect does this implicitly. Preparing a query over resident
frames converts those frames once, which can take noticeably longer
than a collect for large inputs; prepare first if you want to keep
that out of a timed path. The engine keeps up to 32 prepared plans
(IbexEngine(cache_size=N), 0 to disable).
Plans are cached, results never are: each collect reads its sources
again.
engine.explain(query)
Returns the Ibex program the query becomes, so you can see exactly
what runs. Literals cross as typed bindings
(^_ibex_scalar_N), never as text pasted into the source.
The output above is wrapped for the page. The coalesce and
the null-sort columns are how Polars semantics are kept: a Polars sum of
no values is zero where Ibex's is null, and Polars' sort puts nulls
first.
Threads
Setting the thread budget
Ibex sizes its worker pool from the machine. Set
IBEX_CORES before the first collect to cap it, the
counterpart of Polars' POLARS_MAX_THREADS; set both to the
same value when comparing the two engines.
Column-key group_by with sum, mean, min, max, count, len, n_unique, first/last, median, std (ddof 1), Pearson corr and its square, including the null-on-empty sum pl.when(x.count() > 0).then(x.sum()).
Per-group rows: group_by(...).head(n), and agg(pl.col(x).top_k(k)).explode(...) on a numeric column.
Sorting, unique, slice/head/tail, rounding, string slicing and starts_with/ends_with/contains, Date years.
Integer, float, Boolean, String, Categorical, Date, Datetime and Duration columns.
Not yet
Quantiles, var, std with another ddof, Spearman corr, and powers other than a float squared; list-valued results (agg(pl.col(x).head(n)) without explode), and explode other than of a per-group head or top_k.
Window expressions (over), computed group or sort keys, Python UDFs.
As-of and general non-equi joins, nondefault join validation.
General regular expressions; multiple or remote files; struct and list columns.
Background and async execution, lazy sinks (lazy=True), and sinks other than sink_parquet.
There is no silent fallback. A plan the engine cannot
translate raises NotImplementedError before anything runs,
naming the construct. If you want Polars to take over in that case, say
so explicitly:
try:
result = query.collect(engine=engine)
except NotImplementedError as exc: # e.g. "unsupported function ('quantile', 'nearest')"
result = query.collect(engine="streaming")
On the two public benchmark suites: all 22 PDS-H queries run, and of the
h2o db-benchmark, all ten groupby questions and all five joins.
Performance
Measure it on your own machine
python/bench_polars_engines.sh runs the same Polars code on
Polars' streaming engine and on IbexEngine, over PDS-H
(scale 10, Parquet) and the h2o db-benchmark (10M rows, resident), at 8
and 1 threads, and checks every answer. It reports each query's
prepare() time beside the timed collects: for resident
frames, preparing imports them once, which Polars never does. Pin it
to one CPU per physical
core:
The benchmarks page compares Ibex's own
language against Polars and DuckDB on the same suites; the
PDS-H engine summary
has per-query measurements of the Polars engine.