Skip to Content
We are live but in Staging 🎉

Materialize — structured SELECT INTO

Same engine as CREATE TABLE AS SELECT via Execute, but with structured inputs instead of folding everything into a SQL string. Useful for UIs / programmatic callers that have separate fields for source / SQL / target / partition / mode. See the Execute hub for the RPC contract overview.

RPCHTTP
MaterializePOST /:bucket/tables/:source_table/materialize

gRPC setup — grpcurl, endpoints, reflection, and field-name casing — is covered once in Conventions → Using gRPC.

Materialize

Request

curl -sS -X POST "https://k3.dev.dodil.io/kb-prod/tables/events/materialize" \ -H "Authorization: Bearer $DODIL_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "bucket": "kb-prod", "sourceTable": "events", "sql": "SELECT user_id, occurred_at, event_type, payload, occurred_at - LAG(occurred_at) OVER (PARTITION BY user_id ORDER BY occurred_at) AS gap_us FROM events", "targetTable": "events_sessionized", "partitionColumns": ["event_type"], "mode": "create" }'

Response

{ "targetTable": "events_sessionized", "targetLocation": "s3://kb-prod/.../events_sessionized", "rowsMaterialized": "12483", "version": "1" }

Modes:

modeBehavior
create (default)Fail if target_table already exists
replaceDrop + recreate the target
appendRequire existing target with matching schema, append rows

lookup_tables is an alias → table-name map for broadcast JOINs in the source SQL — same shape as Query.lookup_tables.

See also