@@ -418,7 +418,7 @@ export class BaseQuery {
418418 */
419419 get allJoinHints ( ) {
420420 if ( ! this . collectedJoinHints ) {
421- // let joinHints = this.collectJoinHints();
421+ // this.collectedJoinHints = this.collectJoinHints();
422422 const allMembersJoinHints = this . collectJoinHintsFromMembers ( this . allMembersConcat ( false ) ) ;
423423 const customSubQueryJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromCustomSubQuery ( ) ) ;
424424 let joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
@@ -436,7 +436,7 @@ export class BaseQuery {
436436 ...joinMembersJoinHints ,
437437 ...customSubQueryJoinHints ,
438438 ] ) ;
439- while ( ! R . equals ( this . join , newJoin ) ) {
439+ while ( newJoin ?. joins . length > 0 && ! R . equals ( this . join , newJoin ) ) {
440440 this . join = newJoin ;
441441 joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
442442 newJoin = this . joinGraph . buildJoin ( [
@@ -2446,6 +2446,26 @@ export class BaseQuery {
24462446 targetIdx = joinHints . findIndex ( e => e === targetCube ) ;
24472447 }
24482448 joinHints . push ( targetCube ) ;
2449+
2450+ // Special processing is required when one cube extends another, because in this case
2451+ // cube names collected during joins evaluation might belong to ancestors which are out of scope of
2452+ // the current query and thus will lead to `Can't find join path to join cubes` error.
2453+ // To work around this we change the all ancestors cube names in collected join hints to the original one.
2454+ if ( s . cube ( ) . extends ) {
2455+ const cubeName = s . cube ( ) . name ;
2456+ let parentCube = this . cubeEvaluator . resolveSymbolsCall ( s . cube ( ) . extends , ( name ) => this . cubeEvaluator . cubeFromPath ( name ) ) ;
2457+ while ( parentCube ) {
2458+ // eslint-disable-next-line no-loop-func
2459+ joinHints . forEach ( ( item , index , array ) => {
2460+ if ( item === parentCube . name ) {
2461+ array [ index ] = cubeName ;
2462+ }
2463+ } ) ;
2464+ parentCube = parentCube . extends ?
2465+ this . cubeEvaluator . resolveSymbolsCall ( parentCube . extends , ( name ) => this . cubeEvaluator . cubeFromPath ( name ) )
2466+ : null ;
2467+ }
2468+ }
24492469 }
24502470 return res ;
24512471 }
0 commit comments