In-process executor for semql FederatedPlans — runs per-backend fragments via caller-supplied adapters and merges results in DuckDB.
Project description
semql-engine
In-process executor for semql
FederatedPlan results. Runs each per-backend fragment via a
caller-supplied Adapter, materialises the rows into in-memory DuckDB,
then runs the plan's merge SQL against the assembled tables.
semql core stays sans-io. semql-engine is the opt-in package that
turns a FederatedPlan into result rows when you want the cross-source
execution done for you.
Install
pip install semql-engine
Quickstart
import duckdb
from semql import Catalog, Dialect, compile_federated_query
from semql_engine import DuckDBAdapter, Engine
catalog = Catalog([...]) # cubes spanning multiple backends
plan = compile_federated_query(query, catalog.as_dict())
engine = Engine()
engine.register(Dialect.POSTGRES, my_pg_adapter)
engine.register(Dialect.BIGQUERY, my_bq_adapter)
result = engine.run(plan)
result.columns # ['region', 'revenue', ...]
result.rows # [(...), ...] — or stream with engine.iter_rows(plan)
What it does
For every fragment in the plan, the engine calls the adapter registered
for that backend with (sql, params). It loads the resulting rows into
a DuckDB table named frag_<i> (matching FederatedPlan.fragments
indices) and finally applies plan.merge_spec — rendered to DuckDB SQL
by semql_engine.merge — to produce the merged shape.
Single-fragment plans (single-backend queries that went through
compile_federated_query anyway) work transparently — the merge is a
pass-through.
Adapters
An Adapter is anything with execute(sql, params) -> AdapterResult
where AdapterResult carries columns: list[str] and an iterable of
row dicts. Built-ins:
DuckDBAdapter(con)— runs the SQL inside an existing DuckDB connection. Useful for local CSV / Parquet enrichment cubes.DBAPIAdapter(con)— wraps any PEP-249 connection (psycopg, mysql, sqlite, etc).
Bring your own for warehouses that need a vendor SDK.
Semi-joins
A cross-backend semi-join (restrict an outer dimension to the value set
of an inner query, shipped as a value list rather than a join) compiles
to a SemiJoinPlan via semql.compile_semi_join_query. Run it with
run_semi_join(plan, engine) — it executes each inner plan, projects the
key column to a value list, and runs the outer query with that list bound
as an IN / NOT IN filter:
from semql import compile_semi_join_query
from semql_engine import Engine, run_semi_join
plan = compile_semi_join_query(query, catalog.as_dict())
result = run_semi_join(plan, engine) # same ExecutionResult shape as run()
Scope
v1 mirrors compile_federated_query v1:
- Sum / count / avg supported (avg is decomposed at compile and recomposed in the merge SQL); other aggregations are refused by the compiler before the engine ever sees them.
- Equality bridge joins only.
- No
comparemode, no booleanwheretree across backends.
The engine itself is small; most of the federation logic lives in
semql.federate.
Status
Early development. The Adapter contract is stable; the federation
shape mirrors compile_federated_query v1 (sum / count / avg and
equality bridge joins only).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semql_engine-0.7.0.tar.gz.
File metadata
- Download URL: semql_engine-0.7.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0ce033e5163bb12e528b5635dd3b972fae73a828ad6451ad3c1719cef79e912
|
|
| MD5 |
f9baa6d890420291234e6af31e2f995d
|
|
| BLAKE2b-256 |
b0e9ced93a07f9a050cd103e57dc6370b16fd22f73eeb33aadeff12c931683e0
|
Provenance
The following attestation bundles were made for semql_engine-0.7.0.tar.gz:
Publisher:
release.yml on semql-io/semql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semql_engine-0.7.0.tar.gz -
Subject digest:
d0ce033e5163bb12e528b5635dd3b972fae73a828ad6451ad3c1719cef79e912 - Sigstore transparency entry: 2210121853
- Sigstore integration time:
-
Permalink:
semql-io/semql@d9cef366e8300cd714ecf165317da3bf2d408e5a -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/semql-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d9cef366e8300cd714ecf165317da3bf2d408e5a -
Trigger Event:
push
-
Statement type:
File details
Details for the file semql_engine-0.7.0-py3-none-any.whl.
File metadata
- Download URL: semql_engine-0.7.0-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46fa8d1a06ca94fe79f8812a08e53ad3b3ae2e4a8846051e7d2fb19fecfd87d1
|
|
| MD5 |
f7643641aea37cc3754e4283afe86e94
|
|
| BLAKE2b-256 |
fedaa72f1dbaf029c76e51a21e660fcb2fd893ce389088eb2e502589ede5a319
|
Provenance
The following attestation bundles were made for semql_engine-0.7.0-py3-none-any.whl:
Publisher:
release.yml on semql-io/semql
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semql_engine-0.7.0-py3-none-any.whl -
Subject digest:
46fa8d1a06ca94fe79f8812a08e53ad3b3ae2e4a8846051e7d2fb19fecfd87d1 - Sigstore transparency entry: 2210122267
- Sigstore integration time:
-
Permalink:
semql-io/semql@d9cef366e8300cd714ecf165317da3bf2d408e5a -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/semql-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d9cef366e8300cd714ecf165317da3bf2d408e5a -
Trigger Event:
push
-
Statement type: