@@ -417,7 +417,7 @@ export class BaseQuery {
417417 */
418418 get allJoinHints ( ) {
419419 if ( ! this . collectedJoinHints ) {
420- // let joinHints = this.collectJoinHints();
420+ // this.collectedJoinHints = this.collectJoinHints();
421421 const allMembersJoinHints = this . collectJoinHintsFromMembers ( this . allMembersConcat ( false ) ) ;
422422 const customSubQueryJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromCustomSubQuery ( ) ) ;
423423 let joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
@@ -435,7 +435,7 @@ export class BaseQuery {
435435 ...joinMembersJoinHints ,
436436 ...customSubQueryJoinHints ,
437437 ] ) ;
438- while ( ! R . equals ( this . join , newJoin ) ) {
438+ while ( newJoin ?. joins . length > 0 && ! R . equals ( this . join , newJoin ) ) {
439439 this . join = newJoin ;
440440 joinMembersJoinHints = this . collectJoinHintsFromMembers ( this . joinMembersFromJoin ( ) ) ;
441441 newJoin = this . joinGraph . buildJoin ( [
@@ -2438,6 +2438,26 @@ export class BaseQuery {
24382438 targetIdx = joinHints . findIndex ( e => e === targetCube ) ;
24392439 }
24402440 joinHints . push ( targetCube ) ;
2441+
2442+ // Special processing is required when one cube extends another, because in this case
2443+ // cube names collected during joins evaluation might belong to ancestors which are out of scope of
2444+ // the current query and thus will lead to `Can't find join path to join cubes` error.
2445+ // To work around this we change the all ancestors cube names in collected join hints to the original one.
2446+ if ( s . cube ( ) . extends ) {
2447+ const cubeName = s . cube ( ) . name ;
2448+ let parentCube = this . cubeEvaluator . resolveSymbolsCall ( s . cube ( ) . extends , ( name ) => this . cubeEvaluator . cubeFromPath ( name ) ) ;
2449+ while ( parentCube ) {
2450+ // eslint-disable-next-line no-loop-func
2451+ joinHints . forEach ( ( item , index , array ) => {
2452+ if ( item === parentCube . name ) {
2453+ array [ index ] = cubeName ;
2454+ }
2455+ } ) ;
2456+ parentCube = parentCube . extends ?
2457+ this . cubeEvaluator . resolveSymbolsCall ( parentCube . extends , ( name ) => this . cubeEvaluator . cubeFromPath ( name ) )
2458+ : null ;
2459+ }
2460+ }
24412461 }
24422462 return res ;
24432463 }
0 commit comments