Skip to content

Commit 9a6a898

Browse files
committed
feat: Expose aliasMember for hierarchy in View
1 parent 635ea38 commit 9a6a898

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/cubejs-api-gateway/openspec.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ components:
182182
properties:
183183
name:
184184
type: "string"
185+
aliasMember:
186+
description: "When hierarchy is defined in Cube, it keeps the original path: Cube.hierarchy"
187+
type: "string"
185188
title:
186189
type: "string"
187190
levels:

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ export class CubeEvaluator extends CubeSymbols {
308308
if (cube.isView && (cube.includedMembers || []).length) {
309309
const includedMemberPaths: string[] = R.uniq(cube.includedMembers.map(it => it.memberPath));
310310
const includedCubeNames: string[] = R.uniq(includedMemberPaths.map(it => it.split('.')[0]));
311+
311312
// Path to name (which can be prefixed or aliased) map for hierarchy
312313
const hierarchyPathToName = cube.includedMembers.filter(it => it.type === 'hierarchies').reduce((acc, it) => ({
313314
...acc,
@@ -336,14 +337,18 @@ export class CubeEvaluator extends CubeSymbols {
336337
})
337338
.filter(Boolean);
338339

339-
const name = hierarchyPathToName[[cubeName, it.name].join('.')];
340+
const aliasMember = [cubeName, it.name].join('.');
341+
342+
const name = hierarchyPathToName[aliasMember];
340343
if (!name) {
341344
throw new UserError(`Hierarchy '${it.name}' not found in cube '${cubeName}'`);
342345
}
346+
343347
return {
344348
// Title might be overridden in the view
345349
title: cube.hierarchies?.[it.name]?.override?.title || it.title,
346350
...it,
351+
aliasMember,
347352
name,
348353
levels
349354
};

packages/cubejs-schema-compiler/src/compiler/CubeToMetaTransformer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export class CubeToMetaTransformer {
109109
)(cube.segments || {}),
110110
hierarchies: (cube.evaluatedHierarchies || []).map((it) => ({
111111
...it,
112+
aliasMember: it.aliasMember,
112113
public: it.public ?? true,
113114
name: `${cube.name}.${it.name}`,
114115
})),

0 commit comments

Comments
 (0)