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.
| RPC | HTTP |
|---|---|
Materialize | POST /:bucket/tables/:source_table/materialize |
gRPC setup —
grpcurl, endpoints, reflection, and field-name casing — is covered once in Conventions → Using gRPC.
Materialize
Request
HTTP
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
HTTP
{
"targetTable": "events_sessionized",
"targetLocation": "s3://kb-prod/.../events_sessionized",
"rowsMaterialized": "12483",
"version": "1"
}Modes:
mode | Behavior |
|---|---|
create (default) | Fail if target_table already exists |
replace | Drop + recreate the target |
append | Require 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
- Execute — Overview — RPC contract, enums, refusals,
noopsemantics - DDL → CREATE TABLE AS SELECT — SQL-string equivalent (same dispatcher)
- Data → Query — typed shortcut for ad-hoc SELECTs without materializing
- Tables → Create — typed table creation
- Recipes → CTAS / Materialize — runnable end-to-end flow
grpcurlreference — full flag set + reflection-disabled fallbacks