Skip to content

Commit f33cd5f

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

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 ?? [];
@@ -630,7 +633,7 @@ export class BaseQuery {
630633
if (this.from) {
631634
return this.simpleQuery();
632635
}
633-
if (!this.options.preAggregationQuery) {
636+
if (!this.options.preAggregationQuery && !this.customSubQueryJoins.length) {
634637
preAggForQuery =
635638
this.preAggregations.findPreAggregationForQuery();
636639
if (this.options.disableExternalPreAggregations && preAggForQuery?.preAggregation.external) {

0 commit comments

Comments
 (0)