{"record":{"id":"3b9b1c173fc805d3","repo":"cube-js/cube","slug":"no-pre-aggregation-partitions-were-built-yet-for-t","errorCode":null,"errorMessage":"No pre-aggregation partitions were built yet for the pre-aggregation serving this query and this API instance wasn't set up to build pre-aggregations. Please make sure your refresh worker is configured correctly, running, pre-aggregation tables are built and all pre-aggregation refresh settings like timezone match. Expected table name patterns: ${expectedTableNames.join(', ')}","messagePattern":"No pre-aggregation partitions were built yet for the pre-aggregation serving this query and this API instance wasn't set up to build pre-aggregations\\. Please make sure your refresh worker is configured correctly, running, pre-aggregation tables are built and all pre-aggregation refresh settings like timezone match\\. Expected table name patterns: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationLoader.ts","lineNumber":171,"sourceCode":"          ? this.preAggregationQueryKey(refreshKeyValues)\n          : undefined,\n      };\n    } else {\n      // Serve whatever version already exists rather than making this request wait for a build\n      const structureVersion = getStructureVersion(this.preAggregation);\n      const getVersionsStarted = new Date();\n      const { byStructure } = await this.loadCache.getVersionEntries(this.preAggregation);\n      this.logger('Load PreAggregations Tables', {\n        preAggregation: this.preAggregation,\n        requestId: this.requestId,\n        duration: (new Date().getTime() - getVersionsStarted.getTime())\n      });\n\n      const versionEntryByStructureVersion = byStructure[`${this.preAggregation.tableName}_${structureVersion}`];\n      if (this.externalRefresh) {\n        if (!versionEntryByStructureVersion && throwOnMissingPartition) {\n          // eslint-disable-next-line no-use-before-define\n          throw new Error(PreAggregations.noPreAggregationPartitionsBuiltMessage([this.preAggregation]));\n        }\n        if (!versionEntryByStructureVersion) {\n          return null;\n        } else {\n          // the rollups are being maintained independently of this instance of cube.js\n          // immediately return the latest rollup data that instance already has\n          return {\n            targetTableName: this.targetTableName(versionEntryByStructureVersion),\n            refreshKeyValues: [],\n            lastUpdatedAt: versionEntryByStructureVersion.last_updated_at,\n            buildRangeEnd: versionEntryByStructureVersion.build_range_end,\n          };\n        }\n      }\n\n      if (versionEntryByStructureVersion) {\n        // this triggers an asynchronous/background load of the pre-aggregation but immediately\n        // returns the latest data it already has","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationLoader.ts#L153-L189","documentation":"When externalRefresh is enabled, this API instance only reads pre-aggregation partitions built by a refresh worker; it never builds them itself. loadPreAggregation throws this when no version entry matching the pre-aggregation's structure version exists (i.e., no partitions built yet) and throwOnMissingPartition is set, telling the user their refresh worker setup isn't producing the expected tables.","triggerScenarios":"Query executed against an API instance with externalRefresh=true before any refresh worker has built the pre-aggregation; structureVersion mismatch (pre-aggregation definition/timezone changed after partitions were built); refresh worker not running or building into a different store.","commonSituations":"Deploying the API with externalRefresh enabled but forgetting to schedule the refresh worker; refresh settings (timezone, refreshKey, date range) differing from the query's; rollup definition changed so built partitions no longer match the expected structure version; pre-aggregation tables exist under different names than the expected patterns.","solutions":["Ensure the refresh worker is running (scheduledInvoker / dbScheduling or external cron calling the refresh API) and building this pre-aggregation.","Match all refresh settings: timezone, refreshKey, partition granularity and pre-aggregation definition must be identical between refresh worker and API instance.","Check the store: built partition tables should exist in the shared external store; list tables and compare against the expected table name patterns in the message.","Temporarily rebuild the pre-aggregation (buildRollup/pre-aggregations API) to confirm partitions can be produced, then inspect for definition drift.","Disable throwOnMissingPartition or externalRefresh only if you intend this instance to build pre-aggregations itself."],"exampleFix":"// before (querying before any build)\ncubejsServer.event('rollupOnly')\n// after: run a refresh worker that builds first\nscheduledRefreshContexts / refreshWorker: { enabled: true } // then query","handlingStrategy":"try-catch","validationCode":"// before querying, confirm partitions exist in the external store\nconst tables = await externalDriver.tables();\nconst hasPartition = tables.some(t => t.startsWith(expectedTablePrefix));\nif (externalRefresh && !hasPartition) throw new Error('No partitions built yet: run refresh worker first');","typeGuard":null,"tryCatchPattern":"try {\n  return await preAggregations.loadPreAggregation({...});\n} catch (e) {\n  if (String(e.message).includes('No pre-aggregation partitions were built yet')) {\n    // trigger refresh worker / inform user to configure refresh\n    throw new Error('Configure and run your refresh worker, then retry the query.');\n  }\n  throw e;\n}","preventionTips":["Always run a refresh worker when externalRefresh=true.","Keep timezone, refreshKey and rollup definitions identical between worker and API.","Alert when built table names stop matching expected patterns.","Rebuild pre-aggregations after changing rollup definitions."],"tags":["pre-aggregation","refresh-worker","external-refresh","partitions"],"backgroundTag":"no-preaggregation-partitions-built","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}