@@ -77,7 +77,14 @@ describe('MySqlPreAggregations', function test() {
77
77
timeDimensionReference: createdAt,
78
78
granularity: 'day',
79
79
partitionGranularity: 'month'
80
- }
80
+ },
81
+ googleRollup: {
82
+ type: 'rollup',
83
+ measureReferences: [count],
84
+ segmentReferences: [google],
85
+ timeDimensionReference: createdAt,
86
+ granularity: 'day',
87
+ },
81
88
}
82
89
})
83
90
` ) ;
@@ -163,4 +170,47 @@ describe('MySqlPreAggregations', function test() {
163
170
} ) ;
164
171
} ) ;
165
172
} ) ;
173
+
174
+ it ( 'segment' , ( ) => compiler . compile ( ) . then ( ( ) => {
175
+ const query = new MySqlQuery ( { joinGraph, cubeEvaluator, compiler } , {
176
+ measures : [
177
+ 'visitors.count'
178
+ ] ,
179
+ dimensions : [ ] ,
180
+ segments : [ 'visitors.google' ] ,
181
+ timezone : 'UTC' ,
182
+ preAggregationsSchema : '' ,
183
+ timeDimensions : [ {
184
+ dimension : 'visitors.createdAt' ,
185
+ granularity : 'day' ,
186
+ dateRange : [ '2016-12-30' , '2017-01-06' ]
187
+ } ] ,
188
+ order : [ {
189
+ id : 'visitors.createdAt'
190
+ } ] ,
191
+ } ) ;
192
+
193
+ const queryAndParams = query . buildSqlAndParams ( ) ;
194
+ console . log ( queryAndParams ) ;
195
+ const preAggregationsDescription = query . preAggregations . preAggregationsDescription ( ) ;
196
+ console . log ( preAggregationsDescription ) ;
197
+
198
+ const queries = tempTablePreAggregations ( preAggregationsDescription ) ;
199
+
200
+ console . log ( JSON . stringify ( queries . concat ( queryAndParams ) ) ) ;
201
+
202
+ return dbRunner . testQueries (
203
+ queries . concat ( [ queryAndParams ] ) . map ( q => replaceTableName ( q , preAggregationsDescription , 142 ) )
204
+ ) . then ( res => {
205
+ console . log ( JSON . stringify ( res ) ) ;
206
+ res . should . be . deepEqual (
207
+ [
208
+ {
209
+ "visitors__created_at_day" : "2017-01-06T00:00:00.000" ,
210
+ "visitors__count" : 1
211
+ }
212
+ ]
213
+ ) ;
214
+ } ) ;
215
+ } ) ) ;
166
216
} ) ;
0 commit comments