@@ -36,14 +36,23 @@ const prepareAnnotation = (metaConfig, query) => {
36
36
} ] ;
37
37
} ;
38
38
39
+ const dimensions = ( query . dimensions || [ ] ) ;
39
40
return {
40
41
measures : R . fromPairs ( ( query . measures || [ ] ) . map ( annotation ( 'measures' ) ) . filter ( a => ! ! a ) ) ,
41
- dimensions : R . fromPairs ( ( query . dimensions || [ ] ) . map ( annotation ( 'dimensions' ) ) . filter ( a => ! ! a ) ) ,
42
+ dimensions : R . fromPairs ( dimensions . map ( annotation ( 'dimensions' ) ) . filter ( a => ! ! a ) ) ,
42
43
segments : R . fromPairs ( ( query . segments || [ ] ) . map ( annotation ( 'segments' ) ) . filter ( a => ! ! a ) ) ,
43
- timeDimensions : R . fromPairs ( ( query . timeDimensions || [ ] )
44
- . filter ( td => ! ! td . granularity )
45
- . map ( td => annotation ( 'dimensions' ) ( `${ td . dimension } .${ td . granularity } ` ) )
46
- . filter ( a => ! ! a ) ) ,
44
+ timeDimensions : R . fromPairs (
45
+ R . unnest (
46
+ ( query . timeDimensions || [ ] )
47
+ . filter ( td => ! ! td . granularity )
48
+ . map (
49
+ td => [ annotation ( 'dimensions' ) ( `${ td . dimension } .${ td . granularity } ` ) ] . concat (
50
+ // TODO: deprecated: backward compatibility for referencing time dimensions without granularity
51
+ dimensions . indexOf ( td . dimension ) === - 1 ? [ annotation ( 'dimensions' ) ( td . dimension ) ] : [ ]
52
+ ) . filter ( a => ! ! a )
53
+ )
54
+ )
55
+ ) ,
47
56
} ;
48
57
} ;
49
58
@@ -55,7 +64,7 @@ const transformValue = (value, type) => {
55
64
} ;
56
65
57
66
58
- const transformData = ( aliasToMemberNameMap , annotation , data ) => ( data . map ( r => R . pipe (
67
+ const transformData = ( aliasToMemberNameMap , annotation , data , query ) => ( data . map ( r => R . pipe (
59
68
R . toPairs ,
60
69
R . map ( p => {
61
70
const memberName = aliasToMemberNameMap [ p [ 0 ] ] ;
@@ -72,7 +81,7 @@ const transformData = (aliasToMemberNameMap, annotation, data) => (data.map(r =>
72
81
73
82
// TODO: deprecated: backward compatibility for referencing time dimensions without granularity
74
83
const memberNameWithoutGranularity = [ path [ 0 ] , path [ 1 ] ] . join ( '.' ) ;
75
- if ( path . length === 3 && ! annotation [ memberNameWithoutGranularity ] ) {
84
+ if ( path . length === 3 && ( query . dimensions || [ ] ) . indexOf ( memberNameWithoutGranularity ) === - 1 ) {
76
85
return [
77
86
transformResult ,
78
87
[
@@ -389,7 +398,7 @@ class ApiGateway {
389
398
} ;
390
399
res ( {
391
400
query : normalizedQuery ,
392
- data : transformData ( aliasToMemberNameMap , flattenAnnotation , response . data ) ,
401
+ data : transformData ( aliasToMemberNameMap , flattenAnnotation , response . data , normalizedQuery ) ,
393
402
lastRefreshTime : response . lastRefreshTime && response . lastRefreshTime . toISOString ( ) ,
394
403
...( process . env . NODE_ENV === 'production' ? undefined : {
395
404
refreshKeyValues : response . refreshKeyValues ,
0 commit comments