Skip to main content

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.

Quickstart

import duckdb
from semql import Catalog, 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(Backend.POSTGRES, my_pg_adapter)
engine.register(Backend.BIGQUERY, my_bq_adapter)
rows = list(engine.run(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 runs plan.merge.sql 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.

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 compare mode, no boolean where tree across backends.

The engine itself is small; most of the federation logic lives in semql.federate.

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

semql_engine-0.2.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semql_engine-0.2.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file semql_engine-0.2.1.tar.gz.

File metadata

  • Download URL: semql_engine-0.2.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for semql_engine-0.2.1.tar.gz
Algorithm Hash digest
SHA256 23b1c8230a9a7f938ecfc81dcd3721d999705be368d3138bfdae2757d74a3fef
MD5 e8db90ebfdb64f4515a83cfba8026ed9
BLAKE2b-256 1b2410eb34196106ffa740d69c0d3115af1fe1c45c07a72988b211fb9d948c48

See more details on using hashes here.

File details

Details for the file semql_engine-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: semql_engine-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for semql_engine-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fced75df91a83e54e770eda6499a0f5525660f49630dca1b88ff6b69ca2c537
MD5 c9ccc0940a668934b1785437a6611b93
BLAKE2b-256 f94e0217da3cd55ea5a0be524c3895430721f3e81c6f0798bfaf1a886e3baf27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page