Skip to content

Commit fd912a1

Browse files
committed
add memberShortNameFromPath() to Evaluator
1 parent 9f154d0 commit fd912a1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeEvaluator.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,18 @@ export class CubeEvaluator extends CubeSymbols {
731731
return !!this.evaluatedCubes[cube];
732732
}
733733

734+
public memberShortNameFromPath(path: string | string[]): string {
735+
if (!Array.isArray(path)) {
736+
path = path.split('.');
737+
}
738+
739+
if (path.length < 2) {
740+
throw new UserError(`Not full member name provided: ${path[0]}`);
741+
}
742+
743+
return `${path.at(-2)}.${path.at(-1)}`;
744+
}
745+
734746
public cubeFromPath(path: string): EvaluatedCube {
735747
return this.evaluatedCubes[this.cubeNameFromPath(path)];
736748
}

0 commit comments

Comments
 (0)