Stream SQL
Mfd is a Streamhouse engine: ingest writes a write-ahead log (WAL), compact lands Apache Iceberg on your object store, and SQL reads both. You query Manifold once. The engine returns live stream plus history together. You do not choose a live view or a history view, and you do not wait for a warehouse load to ask what just arrived. CDC ingest is the same contract: current stream plus current history in one result.
mfd query is the SQL client on the machine that holds DATA_DIR. mfd serve is for other tools; Flight SQL uses the same Iceberg ∪ WAL registration. WAL-absent falls through to Iceberg history.
What a table is
Each namespace is <pipeline>.<namespace>, for example bikehire.rides. What you see depends on the destination:
| Destination | mfd query |
|---|---|
| ManifoldLake, Athena Iceberg, DuckDB | Committed Iceberg files union live WAL slices that have not compacted yet |
| No destination | The WAL is the dataset |
| Other warehouses (Snowflake, Postgres, Athena Hive, …) | Live WAL only. Query the warehouse itself for landed history |
Iceberg ∪ WAL is one SELECT. Compaction does not create a second table. Rows you ingested a second ago and rows already in Parquet sit in the same name.
SELECT
mfd query --plain --sql "SELECT count(*) AS n FROM bikehire.rides"
mfd query --sql "SELECT station, count(*) AS rides FROM bikehire.rides GROUP BY station ORDER BY rides DESC LIMIT 10"Python is the same engine:
import mfd
session = mfd.Session(mfd.Config.discover().get_pipeline("bikehire"))
table = session.query("SELECT count(*) AS n FROM bikehire.rides")
print(table.to_pylist())--plain prints one JSON document for scripts. Without --sql, query opens an interactive sql> prompt.
--warmup opens catalogs and runs the statement once, then times the second collect. Use it when you care about query time rather than process start.
STREAM
STREAM is the same Manifold SQL as SELECT on that table. It tails new results to stdout as they arrive, like watch. LIMIT stops the stream.
mfd query --sql "STREAM * FROM bikehire.rides LIMIT 100"SELECT is a snapshot of Iceberg plus the WAL slices frozen for that statement. STREAM follows new live rows on that same table. --watch <seconds> re-runs a SELECT in the interactive table view. It is a poll, not STREAM.
How Manifold Store supports the query
Manifold Store is the local KV next to the WAL. Payload bytes stay in .seg files or S3. The store is the catalog of which slices are live.
- Ingest holds the writer for that
DATA_DIR(writer.lock). One process writes catalog, schema, journal, and stream state. Theoffsetsfamily is rebuilt from the catalog on start. mfd querypins a Manifold Store snapshot (query_pin): which WAL slices are visible, and which Iceberg snapshot they sit beside.- A second reader process can query while ingest is still writing. It pins a flushed copy of the store. It does not take the writer lock and it does not commit.
- After compact,
query_pinreportswal_pin: drainedwhen the SELECT was lake-only, orwal_pin: livewhen the statement still held WAL (STREAM, overlap).
If you delete DATA_DIR, the pin is gone. Iceberg files in your bucket remain; the live WAL does not.
See Manifold Store.
Transforms and aggregates on the query path
Stateless compute (filter and derive) runs before WAL commit. Schema is ALTER TABLE. SQL sees the transformed rows, not the raw source batch.
Declared CREATE TABLE … GROUP BY / DISTINCT ON journals in Manifold Store and registers pipeline.compute_name in mfd query. See Materialised views and Transforms.
DDL (ALTER TABLE, mfd migrate) rewrites live WAL, applies destination DDL, then appends the ALTER log. Source discover metadata is unchanged. Later SELECTs use the new names. See ALTER operations.
Other tools
mfd serve exposes Iceberg REST and read-only Flight SQL. Flight SQL uses the same Iceberg ∪ WAL registration as mfd query; WAL-absent falls through to Iceberg history.
Grammar for every statement: mfd sql-help or mfd query --sql "SHOW DOCS".
