Skip to content

Commit f5e2222

Browse files
committed
fix allJoinHints() for cases when there are no members
1 parent 9ce0807 commit f5e2222

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ export class BaseQuery {
421421
// this.collectedJoinHints = this.collectJoinHints();
422422
const [rootOfJoin, ...allMembersJoinHints] = this.collectJoinHintsFromMembers(this.allMembersConcat(false));
423423
const customSubQueryJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromCustomSubQuery());
424-
let joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin());
424+
let joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin(this.join));
425425

426426
// One cube may join the other cube via transitive joined cubes,
427427
// members from which are referenced in the join `on` clauses.
@@ -434,25 +434,23 @@ export class BaseQuery {
434434
const filteredJoinMembersJoinHints = joinMembersJoinHints.filter(m => !allMembersJoinHints.includes(m));
435435
return [
436436
...this.queryLevelJoinHints,
437-
rootOfJoin,
437+
...(rootOfJoin ? [rootOfJoin] : []),
438438
...filteredJoinMembersJoinHints,
439439
...allMembersJoinHints,
440440
...customSubQueryJoinHints,
441441
];
442442
};
443443

444-
const prevJoins = this.join;
445-
444+
let prevJoins = this.join;
446445
let newJoin = this.joinGraph.buildJoin(constructJP());
447-
while (newJoin?.joins.length > 0 && !R.equals(this.join, newJoin)) {
448-
this.join = newJoin;
449-
joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin());
446+
447+
while (newJoin?.joins.length > 0 && !R.equals(prevJoins, newJoin)) {
448+
prevJoins = newJoin;
449+
joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin(newJoin));
450450
newJoin = this.joinGraph.buildJoin(constructJP());
451451
}
452452

453-
this.collectedJoinHints = constructJP();
454-
455-
this.join = prevJoins;
453+
this.collectedJoinHints = R.uniq(constructJP());
456454
}
457455
return this.collectedJoinHints;
458456
}
@@ -2505,7 +2503,7 @@ export class BaseQuery {
25052503
collectJoinHints(excludeTimeDimensions = false) {
25062504
const membersToCollectFrom = [
25072505
...this.allMembersConcat(excludeTimeDimensions),
2508-
...this.joinMembersFromJoin(),
2506+
...this.joinMembersFromJoin(this.join),
25092507
...this.joinMembersFromCustomSubQuery(),
25102508
];
25112509

@@ -2529,8 +2527,8 @@ export class BaseQuery {
25292527
});
25302528
}
25312529

2532-
joinMembersFromJoin() {
2533-
return this.join ? this.join.joins.map(j => ({
2530+
joinMembersFromJoin(join) {
2531+
return join ? join.joins.map(j => ({
25342532
getMembers: () => [{
25352533
path: () => null,
25362534
cube: () => this.cubeEvaluator.cubeFromPath(j.originalFrom),

0 commit comments

Comments
 (0)