File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
packages/cubejs-api-gateway/src Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1167,6 +1167,7 @@ class ApiGateway {
11671167 let queryType : QueryType = QueryTypeEnum . REGULAR_QUERY ;
11681168 if ( ! Array . isArray ( query ) ) {
11691169 query = this . compareDateRangeTransformer ( query ) ;
1170+ query = this . fillMissingDateRangesForTimeDimensions ( query ) ;
11701171 if ( Array . isArray ( query ) ) {
11711172 queryType = QueryTypeEnum . COMPARE_DATE_RANGE_QUERY ;
11721173 }
@@ -2446,6 +2447,28 @@ class ApiGateway {
24462447 }
24472448 } ;
24482449
2450+ protected fillMissingDateRangesForTimeDimensions ( query ) {
2451+ if ( ! query . timeDimensions ) {
2452+ return query ;
2453+ }
2454+
2455+ const timeDimensionCount = query . timeDimensions . reduce ( ( acc , item ) => {
2456+ acc [ item . dimension ] = acc [ item . dimension ] || { } ;
2457+ if ( ! acc [ item . dimension ] . dateRange && item . dateRange ) {
2458+ acc [ item . dimension ] . dateRange = item . dateRange ;
2459+ }
2460+ return acc ;
2461+ } , { } ) ;
2462+
2463+ query . timeDimensions . forEach ( td => {
2464+ if ( ! td . dateRange && timeDimensionCount [ td . dimension ] . dateRange ) {
2465+ td . dateRange = timeDimensionCount [ td . dimension ] . dateRange ;
2466+ }
2467+ } ) ;
2468+
2469+ return query ;
2470+ }
2471+
24492472 protected compareDateRangeTransformer ( query ) {
24502473 let queryCompareDateRange ;
24512474 let compareDateRangeTDIndex ;
You can’t perform that action at this time.
0 commit comments