@@ -165,6 +165,7 @@ class PreAggregations {
165
165
const isAdditive = R . all ( m => m . isAdditive ( ) , query . measures ) ;
166
166
const leafMeasureAdditive = R . all ( path => query . newMeasure ( path ) . isAdditive ( ) , leafMeasurePaths ) ;
167
167
const granularityHierarchies = query . granularityHierarchies ( ) ;
168
+ const hasMultipliedMeasures = query . fullKeyQueryAggregateMeasures ( ) . multipliedMeasures . length > 0 ;
168
169
169
170
return {
170
171
sortedDimensions,
@@ -175,7 +176,8 @@ class PreAggregations {
175
176
hasNoTimeDimensionsWithoutGranularity,
176
177
allFiltersWithinSelectedDimensions,
177
178
isAdditive,
178
- granularityHierarchies
179
+ granularityHierarchies,
180
+ hasMultipliedMeasures
179
181
} ;
180
182
}
181
183
@@ -232,8 +234,7 @@ class PreAggregations {
232
234
// [[TimeDimension]]
233
235
const queryTimeDimensionsList = transformedQuery . sortedTimeDimensions . map ( expandTimeDimension ) ;
234
236
235
- const canUsePreAggregationNotAdditive = ( references ) =>
236
- transformedQuery . hasNoTimeDimensionsWithoutGranularity &&
237
+ const canUsePreAggregationNotAdditive = ( references ) => transformedQuery . hasNoTimeDimensionsWithoutGranularity &&
237
238
transformedQuery . allFiltersWithinSelectedDimensions &&
238
239
R . equals ( references . sortedDimensions || references . dimensions , transformedQuery . sortedDimensions ) &&
239
240
(
@@ -245,35 +246,18 @@ class PreAggregations {
245
246
references . sortedTimeDimensions || sortTimeDimensions ( references . timeDimensions )
246
247
) ;
247
248
248
- const canUsePreAggregationLeafMeasureAdditive = ( references ) =>
249
- R . all (
250
- d => ( references . sortedDimensions || references . dimensions ) . indexOf ( d ) !== - 1 ,
251
- transformedQuery . sortedDimensions
252
- ) &&
249
+ const canUsePreAggregationLeafMeasureAdditive = ( references ) => R . all (
250
+ d => ( references . sortedDimensions || references . dimensions ) . indexOf ( d ) !== - 1 ,
251
+ transformedQuery . sortedDimensions
252
+ ) &&
253
253
R . all ( m => references . measures . indexOf ( m ) !== - 1 , transformedQuery . leafMeasures ) &&
254
254
R . allPass (
255
255
queryTimeDimensionsList . map ( tds => R . anyPass ( tds . map ( td => R . contains ( td ) ) ) )
256
256
) ( references . sortedTimeDimensions || sortTimeDimensions ( references . timeDimensions ) ) ;
257
257
258
- const canUsePreAggregationAdditive = ( references ) =>
259
- R . all (
260
- d => ( references . sortedDimensions || references . dimensions ) . indexOf ( d ) !== - 1 ,
261
- transformedQuery . sortedDimensions
262
- ) &&
263
- (
264
- R . all ( m => references . measures . indexOf ( m ) !== - 1 , transformedQuery . measures ) ||
265
- R . all ( m => references . measures . indexOf ( m ) !== - 1 , transformedQuery . leafMeasures )
266
- ) &&
267
- R . allPass (
268
- queryTimeDimensionsList . map ( tds => R . anyPass ( tds . map ( td => R . contains ( td ) ) ) )
269
- ) ( references . sortedTimeDimensions || sortTimeDimensions ( references . timeDimensions ) ) ;
270
-
271
-
272
258
let canUseFn ;
273
- if ( transformedQuery . isAdditive ) {
274
- canUseFn = canUsePreAggregationAdditive ;
275
- } else if ( transformedQuery . leafMeasureAdditive ) {
276
- canUseFn = canUsePreAggregationLeafMeasureAdditive ;
259
+ if ( transformedQuery . leafMeasureAdditive && ! transformedQuery . hasMultipliedMeasures ) {
260
+ canUseFn = ( r ) => canUsePreAggregationLeafMeasureAdditive ( r ) || canUsePreAggregationNotAdditive ( r ) ;
277
261
} else {
278
262
canUseFn = canUsePreAggregationNotAdditive ;
279
263
}
0 commit comments