@@ -459,124 +459,6 @@ export class BaseQuery {
459459 ...newCollectedHints ,
460460 ...allMembersJoinHints ,
461461 ] ) ;
462-
463- //
464- // let joinMembersJoinHints = [];
465- // let originalQueryMembersJoinPredecessors = {};
466- //
467- // // One cube may join the other cube via transitive joined cubes,
468- // // members from which are referenced in the join `on` clauses.
469- // // We need to collect such join hints and push them upfront of the joining one
470- // // but only if they don't exist yet. Cause in other case we might affect what
471- // // join path will be constructed in join graph.
472- // // It is important to use queryLevelJoinHints during the calculation if it is set.
473- //
474- // const constructJH = () => {
475- // const filteredJoinMembersJoinHints = joinMembersJoinHints.filter(m => !allMembersJoinHints.includes(m) && m !== rootOfJoin);
476- // return [
477- // ...this.queryLevelJoinHints,
478- // ...(rootOfJoin ? [rootOfJoin] : []),
479- // ...filteredJoinMembersJoinHints,
480- // ...allMembersJoinHints.filter(m => m !== rootOfJoin),
481- // ...customSubQueryJoinHints,
482- // ];
483- // };
484- //
485- // if (this.join) {
486- // joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin(this.join));
487- // originalQueryMembersJoinPredecessors = this.buildPredecessors(joinMembersJoinHints.flat());
488- // rootOfJoin = this.join.root;
489- // }
490- //
491- // let prevJoin = this.join;
492- // let newJoin = this.joinGraph.buildJoin(constructJH());
493- // if (newJoin) {
494- // rootOfJoin = newJoin.root;
495- // }
496- //
497- // if (!this.join) {
498- // joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin(newJoin));
499- // originalQueryMembersJoinPredecessors = this.buildPredecessors(joinMembersJoinHints.flat());
500- // }
501- //
502- // const isOrderPreserved = (updatedJoinHints) => {
503- // for (let i = 0, l = updatedJoinHints.length; i < l; i++) {
504- // const predecessors = originalQueryMembersJoinPredecessors[updatedJoinHints[i]];
505- //
506- // if (predecessors?.length > 0) {
507- // const predLen = predecessors.length;
508- //
509- // let predIdx = 0;
510- // let joinHintIdx = 0;
511- //
512- // while (joinHintIdx < i && predIdx < predLen) {
513- // if (updatedJoinHints[joinHintIdx] === predecessors[predIdx]) {
514- // joinHintIdx++;
515- // predIdx++;
516- // } else {
517- // joinHintIdx++;
518- // }
519- // }
520- //
521- // if (predIdx < predLen) {
522- // // We still have a must be present predecessor for current hint
523- // return [false, `${updatedJoinHints[i]} <-> ${predecessors[predIdx]}`];
524- // }
525- // }
526- // }
527- //
528- // return [true, ''];
529- // };
530- //
531- // const isJoinTreesEqual = (a, b) => {
532- // if (!a || !b || a.root !== b.root || a.joins.length !== b.joins.length) {
533- // return false;
534- // }
535- //
536- // // We don't care about the order of joins on the same level, so
537- // // we can compare them as sets.
538- // const aJoinsSet = new Set(a.joins.map(j => `${j.originalFrom}->${j.originalTo}`));
539- // const bJoinsSet = new Set(b.joins.map(j => `${j.originalFrom}->${j.originalTo}`));
540- //
541- // if (aJoinsSet.size !== bJoinsSet.size) {
542- // return false;
543- // }
544- //
545- // for (const val of aJoinsSet) {
546- // if (!bJoinsSet.has(val)) {
547- // return false;
548- // }
549- // }
550- //
551- // return true;
552- // };
553- //
554- // // Safeguard against infinite loop in case of cyclic joins somehow managed to slip through
555- // let cnt = 0;
556- //
557- // while (newJoin?.joins.length > 0 && cnt < 10000) {
558- // prevJoin = newJoin;
559- // joinMembersJoinHints = this.collectJoinHintsFromMembers(this.joinMembersFromJoin(newJoin));
560- // newJoin = this.joinGraph.buildJoin(constructJH());
561- //
562- // if (isJoinTreesEqual(prevJoin, newJoin)) {
563- // break;
564- // }
565- //
566- // const [isOrdered, msg] = isOrderPreserved(joinMembersJoinHints.flat());
567- //
568- // if (!isOrdered) {
569- // throw new UserError(`Can not construct joins for the query, potential loop detected around ${msg}`);
570- // }
571- //
572- // cnt++;
573- // }
574- //
575- // if (cnt >= 10000) {
576- // throw new UserError('Can not construct joins for the query, potential loop detected');
577- // }
578- //
579- // this.collectedJoinHints = R.uniq(constructJH());
580462 }
581463 return this . collectedJoinHints ;
582464 }
0 commit comments