@@ -59,6 +59,16 @@ describe('Multiple join paths', () => {
5959 type: 'sum',
6060 },
6161 },
62+
63+ preAggregations: {
64+ adex: {
65+ type: 'rollup',
66+ dimensionReferences: [a_id, CUBE.D.E.X.x_id],
67+ measureReferences: [a_sum, D.E.X.x_sum],
68+ // TODO implement and test segmentReferences
69+ // TODO implement and test timeDimensionReference
70+ },
71+ },
6272 });
6373
6474 cube('B', {
@@ -268,4 +278,27 @@ describe('Multiple join paths', () => {
268278 expect ( sql ) . not . toMatch ( / O N ' F ' = ' X ' / ) ;
269279 } ) ;
270280 } ) ;
281+
282+ describe ( 'PreAggregations join path' , ( ) => {
283+ it ( 'should respect join path from pre-aggregation declaration' , async ( ) => {
284+ const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
285+ measures : [ ] ,
286+ dimensions : [
287+ 'A.a_id'
288+ ] ,
289+ } ) ;
290+
291+ const preAggregationsDescription : any = query . preAggregations ?. preAggregationsDescription ( ) ;
292+ const { loadSql } = preAggregationsDescription . find ( p => p . preAggregationId === 'A.adex' ) ;
293+
294+ expect ( loadSql [ 0 ] ) . toMatch ( / O N ' A ' = ' D ' / ) ;
295+ expect ( loadSql [ 0 ] ) . toMatch ( / O N ' D ' = ' E ' / ) ;
296+ expect ( loadSql [ 0 ] ) . toMatch ( / O N ' E ' = ' X ' / ) ;
297+ expect ( loadSql [ 0 ] ) . not . toMatch ( / O N ' A ' = ' B ' / ) ;
298+ expect ( loadSql [ 0 ] ) . not . toMatch ( / O N ' B ' = ' C ' / ) ;
299+ expect ( loadSql [ 0 ] ) . not . toMatch ( / O N ' C ' = ' X ' / ) ;
300+ expect ( loadSql [ 0 ] ) . not . toMatch ( / O N ' A ' = ' F ' / ) ;
301+ expect ( loadSql [ 0 ] ) . not . toMatch ( / O N ' F ' = ' X ' / ) ;
302+ } ) ;
303+ } ) ;
271304} ) ;
0 commit comments