@@ -420,7 +420,7 @@ export class BaseQuery {
420420 // this.collectedJoinHints = this.collectJoinHints();
421421 const [ rootOfJoin , ...allMembersJoinHints ] = this . collectJoinHintsFromMembers ( this . allMembersConcat ( false ) ) ;
422422 const customSubQueryJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromCustomSubQuery ( ) ) ;
423- let joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
423+ let joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( this . join ) ) ;
424424
425425 // One cube may join the other cube via transitive joined cubes,
426426 // members from which are referenced in the join `on` clauses.
@@ -433,25 +433,23 @@ export class BaseQuery {
433433 const filteredJoinMembersJoinHints = joinMembersJoinHints . filter ( m => ! allMembersJoinHints . includes ( m ) ) ;
434434 return [
435435 ...this . queryLevelJoinHints ,
436- rootOfJoin ,
436+ ... ( rootOfJoin ? [ rootOfJoin ] : [ ] ) ,
437437 ...filteredJoinMembersJoinHints ,
438438 ...allMembersJoinHints ,
439439 ...customSubQueryJoinHints ,
440440 ] ;
441441 } ;
442442
443- const prevJoins = this . join ;
444-
443+ let prevJoins = this . join ;
445444 let newJoin = this . joinGraph . buildJoin ( constructJP ( ) ) ;
446- while ( newJoin ?. joins . length > 0 && ! R . equals ( this . join , newJoin ) ) {
447- this . join = newJoin ;
448- joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
445+
446+ while ( newJoin ?. joins . length > 0 && ! R . equals ( prevJoins , newJoin ) ) {
447+ prevJoins = newJoin ;
448+ joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( newJoin ) ) ;
449449 newJoin = this . joinGraph . buildJoin ( constructJP ( ) ) ;
450450 }
451451
452- this . collectedJoinHints = constructJP ( ) ;
453-
454- this . join = prevJoins ;
452+ this . collectedJoinHints = R . uniq ( constructJP ( ) ) ;
455453 }
456454 return this . collectedJoinHints ;
457455 }
@@ -2481,7 +2479,7 @@ export class BaseQuery {
24812479 collectJoinHints ( excludeTimeDimensions = false ) {
24822480 const membersToCollectFrom = [
24832481 ...this . allMembersConcat ( excludeTimeDimensions ) ,
2484- ...this . joinMembersFromJoin ( ) ,
2482+ ...this . joinMembersFromJoin ( this . join ) ,
24852483 ...this . joinMembersFromCustomSubQuery ( ) ,
24862484 ] ;
24872485
@@ -2505,8 +2503,8 @@ export class BaseQuery {
25052503 } ) ;
25062504 }
25072505
2508- joinMembersFromJoin ( ) {
2509- return this . join ? this . join . joins . map ( j => ( {
2506+ joinMembersFromJoin ( join ) {
2507+ return join ? join . joins . map ( j => ( {
25102508 getMembers : ( ) => [ {
25112509 path : ( ) => null ,
25122510 cube : ( ) => this . cubeEvaluator . cubeFromPath ( j . originalFrom ) ,
0 commit comments