Skip to content

Commit 5547f50

Browse files
authored
fix(tesseract): Fix for multi fact queries (#9421)
1 parent 0a50a8e commit 5547f50

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

+10-5
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,17 @@ export class BaseQuery {
307307
}
308308

309309
prebuildJoin() {
310-
/* if (!this.useNativeSqlPlanner) { We still need this join for the follback to preaggregation to work properly. This condition should be returned after the tesseract starts working with pre-aggregations
310+
if (this.useNativeSqlPlanner) {
311311
// Tesseract doesn't require join to be prebuilt and there's a case where single join can't be built for multi-fact query
312+
// But we need this join for a fallback when using pre-aggregations. So we’ll try to obtain the join but ignore any errors (which may occur if the query is a multi-fact one).
313+
try {
314+
this.join = this.joinGraph.buildJoin(this.allJoinHints);
315+
} catch (e) {
316+
// Ignore
317+
}
318+
} else {
312319
this.join = this.joinGraph.buildJoin(this.allJoinHints);
313-
} */
314-
315-
this.join = this.joinGraph.buildJoin(this.allJoinHints);
320+
}
316321
}
317322

318323
cacheValue(key, fn, { contextPropNames, inputProps, cache } = {}) {
@@ -391,7 +396,7 @@ export class BaseQuery {
391396
initUngrouped() {
392397
this.ungrouped = this.options.ungrouped;
393398
if (this.ungrouped) {
394-
if (!this.options.allowUngroupedWithoutPrimaryKey) {
399+
if (!this.options.allowUngroupedWithoutPrimaryKey && this.join) {
395400
const cubes = R.uniq([this.join.root].concat(this.join.joins.map(j => j.originalTo)));
396401
const primaryKeyNames = cubes.flatMap(c => this.primaryKeyNames(c));
397402
const missingPrimaryKeys = primaryKeyNames.filter(key => !this.dimensions.find(d => d.dimension === key));

0 commit comments

Comments
 (0)