datum-sql
datum-sql is Datum's SQL front end: DataFusion parses, optimizes, and builds
physical expressions; Datum lowers the supported physical plan into ordinary
Datum stream stages and materializes it with Datum sinks.
The crate uses Arrow RecordBatch values as the SQL data unit. Append-only
queries stay as Source<RecordBatch>. Updating streams use
Source<ChangelogBatch>, where row-level ChangeOp metadata stays outside
Arrow row data so projections and filters cannot accidentally drop it.
Install
Enable connector adapters only when you need them:
What Works
- Register in-memory Datum sources as SQL tables.
- Register append-only, committable, and changelog/updating sources.
- Parse and plan SQL with DataFusion 54 over Arrow 58.
- Lower scans, projection, filter, coalesce, limit, windowed aggregation, and supported inner equi-joins into Datum stages.
- Run bounded append-only queries and collect Arrow batches.
- Build continuous
SqlEvent<RecordBatch>streams carrying data, watermarks, and future barrier markers outside row data. - Assign event-time watermarks from an Arrow timestamp column with bounded out-of-orderness.
- Register append-only and changelog-aware SQL sinks.
- Execute
INSERT INTO <registered_sink> SELECT ...with at-least-once source-position commit ordering for committable sources. - Opt into Kafka JSON table/sink adapters with the
mqfeature and PostgreSQL CDC changelog adapters with thecdcfeature.
Quick Start
use Arc;
use ;
use ;
use RecordBatch;
use Source;
use DatumSqlContext;
# async
Run the checked example from the repository:
Windowed Streaming Query
Event-time queries register the timestamp column at the table boundary. The
continuous lowering returns a Datum source of SqlEvent<RecordBatch> values, so
watermarks stay outside user row data.
use Arc;
use Duration;
use ;
use ;
use RecordBatch;
use Source;
use ;
# async
Continuous Queries And Sinks
For streaming use, call streaming_source to get a Datum source of
SqlEvent<RecordBatch> values, or call execute_streaming to materialize a
continuous query. SqlEvent::Data carries user rows; SqlEvent::Watermark and
SqlEvent::Barrier carry stream control metadata outside Arrow columns.
# use Arc;
# use Int64Array;
# use ;
# use RecordBatch;
# use Source;
# use DatumSqlContext;
# async
Feature Flags
datum-sql has no default features.
mqenables Kafka JSON source and sink adapters built ondatum-mq.cdcenables PostgreSQL CDC changelog table adapters built ondatum-cdc.
Known Limitations
- SQL coverage is intentionally narrow. Unsupported DataFusion physical nodes
return
DataFusionError::NotImplementedinstead of falling back to DataFusion execution. - Streaming joins support append-only inner equi-joins. Outer joins, semi/anti joins, non-equi joins, and changelog joins are not implemented yet.
- Windowed aggregation supports fixed tumbling and hopping windows over
event-time input, with a conservative aggregate set. Session windows,
grouping sets, aggregate
FILTER, distinct aggregates, and processing-time windows are deferred. - Changelog-aware sinks are explicit. Append-only sinks reject updating streams; there is no implicit adapter that drops retractions.
- Sink execution is at-least-once. Exactly-once requires checkpoint barriers, durable operator state, and transactional sink recovery work that is still design-only.
- Kafka support is JSON-row oriented today. Avro, Protobuf, schema registry integration, and long-lived producer batching are future work.
- CDC decoding covers the current
datum-cdcpgoutput text-value shape. Initial snapshots, DDL/schema history, and binary pgoutput decoding are not provided bydatum-sql. - The SQL benchmark record is frozen in
roadmap/benchmarks/sql.md. Current durable verdicts include a q3 all-metric win, q4/q7 wall wins, corrected q8 wall wins after WP-SQL-F1, and q5/ingest misses with named follow-up levers; cite that record for exact numbers and caveats.
Design References
The design record and go/no-go notes live in
roadmap/M11-datum-sql.md. Benchmark plans and
results live under roadmap/benchmarks/.