@@ -273,7 +273,7 @@ describe('PreAggregations', () => {
273273 measures: [count],
274274 dimensions: [visitor_checkins.source],
275275 timeDimension: createdAt,
276- granularity: 'day',
276+ granularity: 'day'
277277 }
278278 }
279279 })
@@ -378,6 +378,13 @@ describe('PreAggregations', () => {
378378 select * from cards
379379 \`,
380380
381+ joins: {
382+ visitor_checkins: {
383+ relationship: 'one_to_many',
384+ sql: \`\${CUBE.visitorId} = \${visitor_checkins.visitor_id}\`
385+ }
386+ },
387+
381388 measures: {
382389 count: {
383390 type: 'count'
@@ -519,6 +526,23 @@ describe('PreAggregations', () => {
519526 includes: '*'
520527 }]
521528 });
529+
530+ view('cards_visitors_checkins_view', {
531+ cubes: [
532+ {
533+ join_path: visitors,
534+ includes: ['count', 'createdAt']
535+ },
536+ {
537+ join_path: visitors.cards,
538+ includes: [{ name: 'visitorId', alias: 'visitorIdFromCards'}]
539+ },
540+ {
541+ join_path: visitors.cards.visitor_checkins,
542+ includes: ['source']
543+ }
544+ ]
545+ });
522546 ` ) ;
523547
524548 it ( 'simple pre-aggregation' , async ( ) => {
@@ -1177,6 +1201,64 @@ describe('PreAggregations', () => {
11771201 } ) ;
11781202 } ) ;
11791203
1204+ it ( 'non-match because of join tree difference' , async ( ) => {
1205+ await compiler . compile ( ) ;
1206+ const query = new PostgresQuery ( { joinGraph, cubeEvaluator, compiler } , {
1207+ measures : [
1208+ 'cards_visitors_checkins_view.count'
1209+ ] ,
1210+ dimensions : [ 'cards_visitors_checkins_view.source' ] ,
1211+ timeDimensions : [ {
1212+ dimension : 'cards_visitors_checkins_view.createdAt' ,
1213+ granularity : 'day' ,
1214+ dateRange : [ '2017-01-01' , '2017-01-30' ]
1215+ } ] ,
1216+ order : [ {
1217+ id : 'cards_visitors_checkins_view.createdAt'
1218+ } , {
1219+ id : 'cards_visitors_checkins_view.source'
1220+ } ] ,
1221+ timezone : 'America/Los_Angeles' ,
1222+ preAggregationsSchema : ''
1223+ } ) ;
1224+
1225+ const queryAndParams = query . buildSqlAndParams ( ) ;
1226+ console . log ( queryAndParams ) ;
1227+ expect ( ( < any > query ) . preAggregations . preAggregationForQuery ) . toBeUndefined ( ) ;
1228+
1229+ return dbRunner . evaluateQueryWithPreAggregations ( query ) . then ( res => {
1230+ expect ( res ) . toEqual (
1231+ [
1232+ {
1233+ cards_visitors_checkins_view__count : '1' ,
1234+ cards_visitors_checkins_view__created_at_day : '2017-01-02T00:00:00.000Z' ,
1235+ cards_visitors_checkins_view__source : 'google' ,
1236+ } ,
1237+ {
1238+ cards_visitors_checkins_view__count : '1' ,
1239+ cards_visitors_checkins_view__created_at_day : '2017-01-02T00:00:00.000Z' ,
1240+ cards_visitors_checkins_view__source : null ,
1241+ } ,
1242+ {
1243+ cards_visitors_checkins_view__count : '1' ,
1244+ cards_visitors_checkins_view__created_at_day : '2017-01-04T00:00:00.000Z' ,
1245+ cards_visitors_checkins_view__source : null ,
1246+ } ,
1247+ {
1248+ cards_visitors_checkins_view__count : '1' ,
1249+ cards_visitors_checkins_view__created_at_day : '2017-01-05T00:00:00.000Z' ,
1250+ cards_visitors_checkins_view__source : null ,
1251+ } ,
1252+ {
1253+ cards_visitors_checkins_view__count : '2' ,
1254+ cards_visitors_checkins_view__created_at_day : '2017-01-06T00:00:00.000Z' ,
1255+ cards_visitors_checkins_view__source : null ,
1256+ } ,
1257+ ]
1258+ ) ;
1259+ } ) ;
1260+ } ) ;
1261+
11801262 it ( 'non-leaf additive measure' , async ( ) => {
11811263 await compiler . compile ( ) ;
11821264
0 commit comments