Nested types and domain aliases
Arrays nest to any depth over scalars, decimal/money and other arrays, and domain declares a transparent alias usable wherever a type is written. Compatibility remains structural and invariant (array(T) only matches an exact array(T), as array_concat already required).
strata
domain user_id = int64
domain matrix = array(array(int64))
domain amount = decimal(10, 2)
source events(ns: "app", dataset: "events") {
columns: { id: user_id, m: matrix, p: array(amount), xs: array(int64) }
}
model nested {
from events
select {
deep = array_construct(m),
first = array_get(m, 0),
size = array_length(m),
both = array_concat(m, m)
}
}Nested and parameterized arrays
- Declaration:
array(array(int64)),array(decimal(10, 2)),array(money(USD)), to any depth. The parser accepts it recursively and the checker resolves it the same way (type_from_spec). - Homogeneous construction:
array_constructaccepts elements of any supported type (including arrays, which must be identical to each other); at least one element with a known type, as before. Each element is emitted with aCASTto its type (BIGINT[][]in DuckDB/Postgres,ARRAY<ARRAY<INT64>>in BigQuery,ARRAYin Snowflake). - Access and measurement:
array_get(xss, 0)returns the element (including an array) andarray_lengthcounts positions in any array. - Concatenation:
array_concatrequires identical types, nested ones included. union/dedup/groupand contracts work on nested columns without changes (unification only matches equal types;DISTINCTverified in DuckDB on nested arrays).
What keeps being rejected, loudly and on purpose:
array_contains,array_sort,array_append/prepend/remove/index_ofon non-simple-scalar elements (E063): equality and ordering of composite elements, and the rectangular multi-dimensional arrays that Postgres requires, are not portable without per-engine verification.array_aggof an array (E063): it would aggregate ragged arrays that Postgres cannot represent.expandof a nested array (E075): expansion declares columns of scalar elements.array(array)orarray(decimal)without parameters are not types: a parse error, not a checking error.
Domains
strata
domain user_id = int64
domain ids = array(user_id)domain <name> = <type>at the top level; the type can be anything (including another domain). Used insource,contract,castand array elements. Transparent: contract compatibility, thereads/lineage and the physical types follow the underlying type (user_idisint64for all purposes from checking onward).- Domains are resolved when the project loads, failing early: a cycle (
a = b,b = a, or self-reference) and an undeclared name are E078, even if the alias is never used. Asourcewith no models reading it is not checked (lazy, as before), so its E078 shows up when it is used. fmtround-trips (domain user_id = int64) and the fingerprint is stable. The GBNF grammar accepts the declaration and the references (an identifier in type position); the deterministic sampler stays green because everything it generates parses.
Dialects and limits
- Real execution only in DuckDB (literals
[[1,2],[3]], one-levelUNNEST,DISTINCT/UNIONon nested values,BIGINT[][]andDECIMAL(10,2)[]casts, all verified); the other three engines verified by emission pattern. - The physical types of pins (
exec) reuse the recursive mapping (BIGINT[][],DECIMAL(10,2)[]);moneyisDECIMAL(38,2)also when nested. decimal/moneyas array elements can be declared, measured, accessed and concatenated, but element-wise operations reject them just like nested ones (E063): they are left for a delivery with per-engine verification.fnsignature types (List<...>) remain opaque and do not resolve domains; nor is there predicate validation (that is constraints/masking territory, not aliases).
Errors: E063 unsupported array elements, E078 unknown or cyclic domain, plus the existing ones of each function. Pending: struct/map (only mentioned in the proposal, no design), element-wise operations over decimal/money/nested values with per-engine verification, nested expand/array_agg and predicate validation on domains.