Preaggregations with different databases(schemas)

For a multi-tenant setup where I get the schema name from extendContext at request time

const {
  source
} = COMPILE_CONTEXT;

cube(`Products`, {
  sql: `select * from ${source}.products`,
});

How do I ensure Preaggregations only start getting built after a request comes in?

Hi @Chubi_Best !
Pre-aggregations should be built beforehand so make sure to use scheduledRefreshContexts to keep them up to date.
https://cube.dev/docs/config#scheduled-refresh-contexts

Preaggs that are not built automatically will be created only after the request by default. It’s easier to inspect queries in Cube Cloud so maybe it makes sense to get a free account to try that out and make sure your configuration works as expected.