malloy-materialization
Materialization (Malloy Persistence)
Materialize an expensive source once so queries read a pre-built warehouse table instead of recomputing it every time. You tag a source #@ persist, a materialization run builds it into a physical table, and queries against it are rewritten to read that table.
The #1 gotcha, up front: if a persist source isn't materializing, it is almost always one of two things - a
.malloyfile in the package missing the##! experimental.persistenceflag (which aborts the whole package's build plan), or no build ever ran (a standalone Publisher does not build on publish - see Building and refreshing). Jump to Debugging a no-op build.
The recipe (get this right and it just works)
-
##! experimental.persistenceon EVERY.malloyfile in the package - not only the file that declares the persist source. Either form enables it:##! experimental.persistence, or##! experimental { access_modifiers, sql_functions, persistence }(addpersistenceto the existing list).
Why every file: the build plan is computed by asking every
.malloyfile in the package for its persist sources, and that call throws on any file whose model lacks the flag (Model must have ##! experimental.persistence). One unflagged helper or import file, even one with no persist source of its own, aborts the whole package's build plan, so every persist source in the package drops out. This is the most common cause of a no-op build.