Skip to content

Commit 8100ae5

Browse files
committed
Don't even try to match pre-agg if there are customSubQueryJoins
1 parent 25af24a commit 8100ae5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ export class BaseQuery {
327327
}).filter(R.identity).map(this.newTimeDimension.bind(this));
328328
this.allFilters = this.timeDimensions.concat(this.segments).concat(this.filters);
329329
/**
330+
* For now this might come only from SQL API, it might be some queries that uses measures and filters to
331+
* get the dimensions that are then used as join conditions to get the final results.
332+
* As consequence - if there are such sub query joins - pre-aggregations can't be used.
330333
* @type {Array<{sql: string, on: {expression: Function}, joinType: 'LEFT' | 'INNER', alias: string}>}
331334
*/
332335
this.customSubQueryJoins = this.options.subqueryJoins ?? [];
@@ -703,7 +706,7 @@ export class BaseQuery {
703706
if (this.from) {
704707
return this.simpleQuery();
705708
}
706-
if (!this.options.preAggregationQuery) {
709+
if (!this.options.preAggregationQuery && !this.customSubQueryJoins.length) {
707710
preAggForQuery =
708711
this.preAggregations.findPreAggregationForQuery();
709712
if (this.options.disableExternalPreAggregations && preAggForQuery?.preAggregation.external) {

0 commit comments

Comments
 (0)