@@ -418,8 +418,10 @@ export class BaseQuery {
418418 */
419419 get allJoinHints ( ) {
420420 if ( ! this . collectedJoinHints ) {
421- let joinHints = this . collectJoinHints ( ) ;
422- // let joinHints = this.collectJoinHintsFromMembers(this.allMembersConcat(false));
421+ // let joinHints = this.collectJoinHints();
422+ const allMembersJoinHints = this . collectJoinHintsFromMembers ( this . allMembersConcat ( false ) ) ;
423+ const customSubQueryJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromCustomSubQuery ( ) ) ;
424+ let joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
423425
424426 // One cube may join the other cube via transitive joined cubes,
425427 // members from which are referenced in the join `on` clauses.
@@ -428,16 +430,28 @@ export class BaseQuery {
428430
429431 const prevJoins = this . join ;
430432
431- let newJoin = this . joinGraph . buildJoin ( [ ...this . queryLevelJoinHints , ...joinHints ] ) ;
433+ let newJoin = this . joinGraph . buildJoin ( [
434+ ...this . queryLevelJoinHints ,
435+ ...allMembersJoinHints ,
436+ ...joinMembersJoinHints ,
437+ ...customSubQueryJoinHints ,
438+ ] ) ;
432439 while ( ! R . equals ( this . join , newJoin ) ) {
433440 this . join = newJoin ;
434- joinHints = R . uniq ( [ joinHints [ 0 ] , ...this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) , ...joinHints ] ) ;
435- newJoin = this . joinGraph . buildJoin ( [ ...this . queryLevelJoinHints , ...joinHints ] ) ;
441+ joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
442+ newJoin = this . joinGraph . buildJoin ( [
443+ ...this . queryLevelJoinHints ,
444+ ...allMembersJoinHints ,
445+ ...joinMembersJoinHints ,
446+ ...customSubQueryJoinHints ,
447+ ] ) ;
436448 }
437449
438450 this . collectedJoinHints = [
439451 ...this . queryLevelJoinHints ,
440- ...joinHints ,
452+ ...allMembersJoinHints ,
453+ ...joinMembersJoinHints ,
454+ ...customSubQueryJoinHints ,
441455 ] ;
442456
443457 this . join = prevJoins ;
@@ -2471,7 +2485,17 @@ export class BaseQuery {
24712485 * @returns {Array<Array<string>> }
24722486 */
24732487 collectJoinHints ( excludeTimeDimensions = false ) {
2474- const customSubQueryJoinMembers = this . customSubQueryJoins . map ( j => {
2488+ const membersToCollectFrom = [
2489+ ...this . allMembersConcat ( excludeTimeDimensions ) ,
2490+ ...this . joinMembersFromJoin ( ) ,
2491+ ...this . joinMembersFromCustomSubQuery ( ) ,
2492+ ] ;
2493+
2494+ return this . collectJoinHintsFromMembers ( membersToCollectFrom ) ;
2495+ }
2496+
2497+ joinMembersFromCustomSubQuery ( ) {
2498+ return this . customSubQueryJoins . map ( j => {
24752499 const res = {
24762500 path : ( ) => null ,
24772501 cube : ( ) => this . cubeEvaluator . cubeFromPath ( j . on . cubeName ) ,
@@ -2485,14 +2509,6 @@ export class BaseQuery {
24852509 getMembers : ( ) => [ res ] ,
24862510 } ;
24872511 } ) ;
2488-
2489- const membersToCollectFrom = [
2490- ...this . allMembersConcat ( excludeTimeDimensions ) ,
2491- ...this . joinMembersFromJoin ( ) ,
2492- ...customSubQueryJoinMembers ,
2493- ] ;
2494-
2495- return this . collectJoinHintsFromMembers ( membersToCollectFrom ) ;
24962512 }
24972513
24982514 joinMembersFromJoin ( ) {
0 commit comments