Create a schema file (YAML or JavaScript) in the model directory and define a cube block with a sql_table or sql property pointing to your source table or query
Under measures, define each metric with its type (sum, count, count_distinct, avg, etc.) and the sql expression referencing the source column
Under dimensions, define categorical and time dimensions; mark the primary time dimension with primary_time: true for automatic time filtering
Add a pre_aggregations block inside the cube with a rollup entry listing the measures and dimensions to pre-aggregate, and set the partition_granularity (e.g., month) to split the materialized data by time period
Deploy the schema and verify that Cube selects the rollup for relevant queries by checking the Cube Cloud query profiler or the pre-aggregation match logs
Known gotchas
Rollup pre-aggregations are stored in Cube Store by default, not in your source warehouse; if you need the materialized data to reside in the warehouse (e.g., for compliance), use the external: true option with a supported warehouse destination
The refreshKey defaults to every: 1 hour, meaning Cube checks whether to rebuild the pre-aggregation each hour; a missing or overly broad refreshKey causes stale data to be served without warning
Cube resolves which pre-aggregation to use by matching query measures and dimensions against defined rollups; a query that adds a dimension not present in any rollup will fall through to the raw table rather than raising an error
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp