Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schema-compiler) Resolve rollup join pre-aggregation param allocator issue #8279

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
13 changes: 9 additions & 4 deletions packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2651,13 +2651,18 @@ export class BaseQuery {

newSubQuery(options) {
const QueryClass = this.constructor;
return new QueryClass(this.compilers, this.subQueryOptions(options));
return new QueryClass(this.compilers, { ...this.subQueryOptions(options), paramAllocator: undefined });
Copy link
Member

Choose a reason for hiding this comment

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

We can't unset param allocator here as it should reused in case of actual sub_query: true members.

Copy link
Author

Choose a reason for hiding this comment

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

What would you recommend here then, reverting the last commit and pushing forward with just the initial implementation?

}

newSubQueryForCube(cube, options) {
return this.options.queryFactory
? this.options.queryFactory.createQuery(cube, this.compilers, this.subQueryOptions(options))
: this.newSubQuery(options);
if (this.options.queryFactory) {
// When dealing with rollup joins, it's crucial to use the correct parameter allocator for the specific cube in use.
// By default, we'll use BaseQuery, but it's important to note that different databases (Oracle, PostgreSQL, MySQL, Druid, etc.)
// have unique parameter allocator symbols. Using the wrong allocator can break the query, especially when rollup joins involve
// different cubes that require different allocators.
return this.options.queryFactory.createQuery(cube, this.compilers, { ...this.subQueryOptions(options), paramAllocator: undefined });
Copy link
Author

@pauldheinrichs pauldheinrichs May 21, 2024

Choose a reason for hiding this comment

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

Unset the paramAllocator set by this.subQueryOptions to allow QueryClasses to assume their default paramAllocator class

}
return this.newSubQuery(options);
}

subQueryOptions(options) {
Expand Down
Loading