Skip to content

Commit cd6946d

Browse files
committed
Don't even try to match pre-agg if there are customSubQueryJoins
1 parent 3d94a3b commit cd6946d

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
@@ -326,6 +326,9 @@ export class BaseQuery {
326326
}).filter(R.identity).map(this.newTimeDimension.bind(this));
327327
this.allFilters = this.timeDimensions.concat(this.segments).concat(this.filters);
328328
/**
329+
* For now this might come only from SQL API, it might be some queries that uses measures and filters to
330+
* get the dimensions that are then used as join conditions to get the final results.
331+
* As consequence - if there are such sub query joins - pre-aggregations can't be used.
329332
* @type {Array<{sql: string, on: {expression: Function}, joinType: 'LEFT' | 'INNER', alias: string}>}
330333
*/
331334
this.customSubQueryJoins = this.options.subqueryJoins ?? [];
@@ -629,7 +632,7 @@ export class BaseQuery {
629632
if (this.from) {
630633
return this.simpleQuery();
631634
}
632-
if (!this.options.preAggregationQuery) {
635+
if (!this.options.preAggregationQuery && !this.customSubQueryJoins.length) {
633636
preAggForQuery =
634637
this.preAggregations.findPreAggregationForQuery();
635638
if (this.options.disableExternalPreAggregations && preAggForQuery?.preAggregation.external) {

0 commit comments

Comments
 (0)