Skip to content

fix(query-orchestrator): replace pre-aggregation usage aliases before base table names (fixes #10929)#10942

Open
mystichronicle wants to merge 2 commits into
cube-js:masterfrom
mystichronicle:master
Open

fix(query-orchestrator): replace pre-aggregation usage aliases before base table names (fixes #10929)#10942
mystichronicle wants to merge 2 commits into
cube-js:masterfrom
mystichronicle:master

Conversation

@mystichronicle
Copy link
Copy Markdown
Contributor

Check List

  • Tests have been run in packages where changes have been made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Issue Reference this PR resolves

#10929

Description of Changes Made (if issue reference is not provided)

Fixed the __usage_N pre-aggregation alias replacement path so usage-specific table names are rewritten before their base table name. This prevents the final /load query from resolving to a missing __usage_0 relation in Tesseract multi-fact views with paired source-db pre-aggregations.

Also added a regression test covering the alias replacement order, and resolved the orchestrator package typecheck issues that surfaced while validating the change.

Copilot AI review requested due to automatic review settings May 23, 2026 16:04
@mystichronicle mystichronicle requested a review from a team as a code owner May 23, 2026 16:04
@github-actions github-actions Bot added the pr:community Contribution from Cube.js community members. label May 23, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates TypeScript module resolution and internal typings in cubejs-query-orchestrator, and fixes a pre-aggregation table name replacement edge case (with new test coverage).

Changes:

  • Adjusts @cubejs-backend/* TS path mappings to include additional package sources.
  • Introduces a local LoggerFn type and switches orchestrator modules to use it instead of @cubejs-backend/shared.
  • Fixes pre-aggregation table replacement ordering by sorting table names by length and adds a regression test.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tsconfig.base.json Adds additional source roots to @cubejs-backend/* path mapping.
packages/cubejs-query-orchestrator/test/unit/QueryQueue.abstract.ts Removes dependency on concrete Cubestore connection type in tests via a lightweight “like” type.
packages/cubejs-query-orchestrator/test/unit/QueryCache.abstract.ts Adds regression test for alias/base-table replacement ordering.
packages/cubejs-query-orchestrator/src/orchestrator/QueryQueue.ts Refactors externalId derivation and changes typing/import source for LoggerFn.
packages/cubejs-query-orchestrator/src/orchestrator/QueryOrchestrator.ts Switches LoggerFn import to local type.
packages/cubejs-query-orchestrator/src/orchestrator/QueryCache.ts Sorts temp-table mappings by key length before replacement; switches LoggerFn import.
packages/cubejs-query-orchestrator/src/orchestrator/PreAggregations.ts Switches LoggerFn import to local type.
packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationPartitionRangeLoader.ts Switches LoggerFn import to local type.
packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationLoader.ts Switches LoggerFn import to local type.
packages/cubejs-query-orchestrator/src/orchestrator/Logger.ts Adds local LoggerFn/LoggerFnParams type definitions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// query (initialized by the /cubejs-system/v1/pre-aggregations/jobs
// endpoint).
let result = !query.forceBuild && await queueConnection.getResult(queryKey, options.externalId);
let result = !query.forceBuild && await (queueConnection as any).getResult(queryKey, externalId);
const idx = options.requestId.lastIndexOf('-span-');
return idx !== -1 ? options.requestId.substring(0, idx) : options.requestId;
})()
: undefined;
@@ -0,0 +1,5 @@
export type LoggerFnParams = {
[key: string]: any;
Comment thread tsconfig.base.json
Comment on lines +16 to 22
"packages/cubejs-backend-shared/src",
"packages/cubejs-base-driver/src",
"packages/cubejs-cubestore-driver/src",
"rust/js-wrapper",
"packages/cubejs-api-gateway/src",
"packages/cubejs-cli/src",
"packages/cubejs-query-orchestrator/src",
@mystichronicle
Copy link
Copy Markdown
Contributor Author

@KSDaemon Could you please review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants