@@ -967,6 +967,60 @@ describe('PreAggregations', () => {
967967 ]
968968 });
969969
970+ // Cube with not full paths in rollupJoin pre-aggregation
971+ cube('cube_a_to_fail_pre_agg', {
972+ sql: \`SELECT 1 as id, 'dim_a' as dim_a\`,
973+
974+ joins: {
975+ cube_b: {
976+ relationship: 'many_to_one',
977+ sql: \`\${CUBE.dim_a} = \${cube_b.dim_a}\`
978+ },
979+ cube_c: {
980+ relationship: 'many_to_one',
981+ sql: \`\${CUBE.dim_a} = \${cube_c.dim_a}\`
982+ }
983+ },
984+
985+ dimensions: {
986+ id: {
987+ sql: 'id',
988+ type: 'string',
989+ primary_key: true
990+ },
991+
992+ dim_a: {
993+ sql: 'dim_a',
994+ type: 'string'
995+ },
996+
997+ dim_b: {
998+ sql: 'dim_b',
999+ type: 'string'
1000+ },
1001+ },
1002+
1003+ pre_aggregations: {
1004+ aaa_rollup: {
1005+ dimensions: [
1006+ dim_a
1007+ ]
1008+ },
1009+ rollupJoinAB: {
1010+ type: 'rollupJoin',
1011+ dimensions: [
1012+ dim_a,
1013+ cube_b.dim_b,
1014+ cube_c.dim_c
1015+ ],
1016+ rollups: [
1017+ aaa_rollup,
1018+ cube_b.bbb_rollup
1019+ ]
1020+ }
1021+ }
1022+ });
1023+
9701024 // Models with transitive joins for rollupJoin matching
9711025 cube('merchant_dims', {
9721026 sql: \`
@@ -3537,4 +3591,23 @@ describe('PreAggregations', () => {
35373591 ] ) ;
35383592 } ) ;
35393593 } ) ;
3594+
3595+ if ( getEnv ( 'nativeSqlPlanner' ) ) {
3596+ it . skip ( 'FIXME(tesseract): rollupJoin pre-aggregation with not-full paths should fail' , ( ) => {
3597+ // Need to investigate tesseract internals of how pre-aggs members are resolved and how
3598+ // rollups are used to construct rollupJoins.
3599+ } ) ;
3600+ } else {
3601+ it ( 'rollupJoin pre-aggregation with not-full paths should fail' , async ( ) => {
3602+ await compiler . compile ( ) ;
3603+
3604+ const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
3605+ dimensions : [ 'cube_a_to_fail_pre_agg.dim_a' , 'cube_b.dim_b' , 'cube_c.dim_c' ] ,
3606+ timezone : 'America/Los_Angeles' ,
3607+ preAggregationsSchema : ''
3608+ } ) ;
3609+
3610+ expect ( ( ) => query . buildSqlAndParams ( ) ) . toThrow ( 'No rollups found that can be used for rollup join' ) ;
3611+ } ) ;
3612+ }
35403613} ) ;
0 commit comments