- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.9k
fix(schema-compiler): Add drillMembers to inherited properties by views #9959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
            paco-valdez
  wants to merge
  5
  commits into
  cube-js:master
from
paco-valdez:CT-1188-inherit-drill-members
  
      
      
   
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      10b40e7
              
                Add drillMembers and drillMembersGrouped to inhereted properties by v…
              
              
                paco-valdez b33b038
              
                feat: Implement drill member inheritance for view cubes and enhance e…
              
              
                paco-valdez 104c7fc
              
                PR comments
              
              
                paco-valdez aa6bc44
              
                Move filtering logic to generateIncludeMembers
              
              
                paco-valdez 453bd4a
              
                Merge branch 'master' into CT-1188-inherit-drill-members
              
              
                paco-valdez File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -47,7 +47,7 @@ cube(\`Orders\`, { | |
| measures: { | ||
| count: { | ||
| type: \`count\`, | ||
| //drillMembers: [id, createdAt] | ||
| drillMembers: [id, createdAt] | ||
| }, | ||
|  | ||
| runningTotal: { | ||
|  | @@ -255,6 +255,13 @@ view(\`OrdersView3\`, { | |
| split: true | ||
| }] | ||
| }); | ||
|  | ||
| view(\`OrdersSimpleView\`, { | ||
| cubes: [{ | ||
| join_path: Orders, | ||
| includes: ['createdAt', 'count'] | ||
| }] | ||
| }); | ||
| 
      Comment on lines
    
      +258
     to 
      +264
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The important part is that  | ||
| `); | ||
|  | ||
| async function runQueryTest(q: any, expectedResult: any, additionalTest?: (query: BaseQuery) => any) { | ||
|  | @@ -429,4 +436,71 @@ view(\`OrdersView3\`, { | |
| orders_view3__count: '2', | ||
| orders_view3__product_categories__name: 'Groceries', | ||
| }])); | ||
|  | ||
| it('check drillMembers are inherited in views', async () => { | ||
| await compiler.compile(); | ||
| const cube = metaTransformer.cubes.find(c => c.config.name === 'OrdersView'); | ||
| const countMeasure = cube.config.measures.find((m) => m.name === 'OrdersView.count'); | ||
| expect(countMeasure.drillMembers).toEqual(['OrdersView.id', 'OrdersView.createdAt']); | ||
| expect(countMeasure.drillMembersGrouped).toEqual({ | ||
| measures: [], | ||
| dimensions: ['OrdersView.id', 'OrdersView.createdAt'] | ||
| }); | ||
| }); | ||
|  | ||
| it('verify drill member inheritance functionality', async () => { | ||
| await compiler.compile(); | ||
|  | ||
| // Check that the source Orders cube has drill members | ||
| const sourceOrdersCube = metaTransformer.cubes.find(c => c.config.name === 'Orders'); | ||
| const sourceCountMeasure = sourceOrdersCube.config.measures.find((m) => m.name === 'Orders.count'); | ||
| expect(sourceCountMeasure.drillMembers).toEqual(['Orders.id', 'Orders.createdAt']); | ||
|  | ||
| // Check that the OrdersView cube inherits these drill members with correct naming | ||
| const viewCube = metaTransformer.cubes.find(c => c.config.name === 'OrdersView'); | ||
| const viewCountMeasure = viewCube.config.measures.find((m) => m.name === 'OrdersView.count'); | ||
|  | ||
| // Before our fix, this would have been undefined or empty | ||
| // After our fix, drill members are properly inherited and renamed to use the view naming | ||
| expect(viewCountMeasure.drillMembers).toBeDefined(); | ||
| expect(Array.isArray(viewCountMeasure.drillMembers)).toBe(true); | ||
| expect(viewCountMeasure.drillMembers.length).toBeGreaterThan(0); | ||
| expect(viewCountMeasure.drillMembers).toContain('OrdersView.id'); | ||
| expect(viewCountMeasure.drillMembersGrouped).toBeDefined(); | ||
| }); | ||
|  | ||
| it('check drill member inheritance with limited includes in OrdersSimpleView', async () => { | ||
| await compiler.compile(); | ||
| const cube = metaTransformer.cubes.find(c => c.config.name === 'OrdersSimpleView'); | ||
|  | ||
| if (!cube) { | ||
| throw new Error('OrdersSimpleView not found in compiled cubes'); | ||
| } | ||
|  | ||
| const countMeasure = cube.config.measures.find((m) => m.name === 'OrdersSimpleView.count'); | ||
|  | ||
| if (!countMeasure) { | ||
| throw new Error('OrdersSimpleView.count measure not found'); | ||
| } | ||
|  | ||
| // Check what dimensions are actually available in this limited view | ||
| const availableDimensions = cube.config.dimensions?.map(d => d.name) || []; | ||
|  | ||
| // This view only includes ['id', 'createdAt', 'count'] - should have both id and createdAt | ||
| expect(availableDimensions).not.toContain('OrdersSimpleView.id'); | ||
| expect(availableDimensions).toContain('OrdersSimpleView.createdAt'); | ||
|  | ||
| // The source measure has drillMembers: ['Orders.id', 'Orders.createdAt'] | ||
| // Both should be available in this view since we explicitly included them | ||
| expect(countMeasure.drillMembers).toBeDefined(); | ||
| expect(Array.isArray(countMeasure.drillMembers)).toBe(true); | ||
| expect(countMeasure.drillMembers.length).toBeGreaterThan(0); | ||
|  | ||
| // Verify drill members are inherited and correctly transformed to use View naming | ||
| expect(countMeasure.drillMembers).toEqual(['OrdersSimpleView.createdAt']); | ||
| expect(countMeasure.drillMembersGrouped).toEqual({ | ||
| measures: [], | ||
| dimensions: ['OrdersSimpleView.createdAt'] | ||
| }); | ||
| }); | ||
| 
      Comment on lines
    
      +500
     to 
      +505
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we test that  | ||
| }); | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.