This document discusses Ibis, an analytics library that generates SQL expressions and strings for execution on SQL backends. It introduces Substrait, a standardized relational algebra format that can serialize Ibis expressions. Substrait decouples the expression building in Ibis from the execution engines, allowing Ibis to potentially support hundreds of different backends. The document demonstrates compiling an Ibis expression to the Substrait format and shows how Ibis can consume any SQL dialect by compiling it to Ibis expressions via a Substrait producer.
2. 2
Ibis produces Expressions or Strings for
execution on SQL backends
t.groupby('region')
.aggregate(topk=t.funding_rounds.count())
.sort_by(ibis.desc('topk'))
.head()
Produces
SELECT region
,count(funding_rounds) AS topk
FROM companies
GROUP BY region
ORDER BY topk
SQL Strings generated for
Execution Engine
SQL
Backends
<sqlalchemy.sql.selectable.S
elect object>
SQLAlchemy Expression
3. 3
String Execution Backend
Ibis API Operations Compile SQL String
Backend Speci鍖c SQL Flavor and Support
Type Check and Optimize
Rewrite
Build Ibis Expression
4. 4
Expression Generating Backends
API Operation Compile
SA
Expression
Backend Speci鍖c Expressions or SQLAlchemy
Type Check and Optimize
Rewrite
Build Ibis Expression
12. 12
Takeaways
Ibis as a substrait producer, decouples the execution
engines and expression building
Check out Gil Forsyths gist that explains the duckdb and
ibis substrait integration:
https://gist.github.com/gforsyth/496d680e1e29f0876df937e
e5091e1b8