File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
packages/cubejs-schema-compiler Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,11 @@ export class CubeEvaluator extends CubeSymbols {
238238 if ( cube . isView && ( cube . includedMembers || [ ] ) . length ) {
239239 const includedMemberPaths : string [ ] = R . uniq ( cube . includedMembers . map ( it => it . memberPath ) ) ;
240240 const includedCubeNames : string [ ] = R . uniq ( includedMemberPaths . map ( it => it . split ( '.' ) [ 0 ] ) ) ;
241+ // Path to name (which can be prefixed or aliased) map for hierarchy
242+ const hierarchyPathToName = cube . includedMembers . filter ( it => it . type === 'hierarchies' ) . reduce ( ( acc , it ) => ( {
243+ ...acc ,
244+ [ it . memberPath ] : it . name
245+ } ) , { } ) ;
241246 const includedHierarchyNames = cube . includedMembers . filter ( it => it . type === 'hierarchies' ) . map ( it => it . memberPath . split ( '.' ) [ 1 ] ) ;
242247
243248 for ( const cubeName of includedCubeNames ) {
@@ -260,8 +265,13 @@ export class CubeEvaluator extends CubeSymbols {
260265 return null ;
261266 } ) . filter ( Boolean ) ;
262267
268+ const name = hierarchyPathToName [ [ cubeName , it . name ] . join ( '.' ) ] ;
269+ if ( ! name ) {
270+ throw new UserError ( `Hierarchy '${ it . name } ' not found in cube '${ cubeName } '` ) ;
271+ }
263272 return {
264273 ...it ,
274+ name,
265275 levels
266276 } ;
267277 } )
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ describe('Cube hierarchies', () => {
5050 ( it ) => it . config . name === 'all_hierarchy_view'
5151 ) ;
5252 expect ( allHierarchyView . config . hierarchies . length ) . toBe ( 3 ) ;
53+
54+ const prefixedHierarchy = allHierarchyView . config . hierarchies . find ( ( it ) => it . name === 'all_hierarchy_view.users_users_hierarchy' ) ;
55+ expect ( prefixedHierarchy ) . toBeTruthy ( ) ;
56+ expect ( prefixedHierarchy ?. levels ) . toEqual ( [ 'all_hierarchy_view.users_age' , 'all_hierarchy_view.users_city' ] ) ;
5357 } ) ;
5458
5559 it ( ( 'hierarchy with measure' ) , async ( ) => {
You can’t perform that action at this time.
0 commit comments