File tree Expand file tree Collapse file tree 2 files changed +8
-9
lines changed
packages/cubejs-schema-compiler/src/adapter Expand file tree Collapse file tree 2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -1485,23 +1485,22 @@ export class BaseQuery {
14851485 }
14861486
14871487 // We can't do meaningful query if few time dimensions with different ranges passed,
1488- // it won't be possible to join them together without loosing some rows.
1488+ // it won't be possible to join them together without losing some rows.
14891489 const rangedTimeDimensions = this . timeDimensions . filter ( d => d . dateRange && d . granularity ) ;
14901490 const uniqTimeDimensionWithRanges = R . uniqBy ( d => d . dateRange , rangedTimeDimensions ) ;
14911491 if ( uniqTimeDimensionWithRanges . length > 1 ) {
14921492 throw new Error ( 'Can\'t build query for time dimensions with different date ranges' ) ;
14931493 }
14941494
14951495 // We need to generate time series table for the lowest granularity among all time dimensions
1496- let dateSeriesDimension ;
1497- const dateSeriesGranularity = this . timeDimensions . filter ( d => d . granularity )
1498- . reduce ( ( acc , d ) => {
1499- const mg = this . minGranularity ( acc , d . resolvedGranularity ( ) ) ;
1496+ const [ dateSeriesDimension , dateSeriesGranularity ] = this . timeDimensions . filter ( d => d . granularity )
1497+ . reduce ( ( [ prevDim , prevGran ] , d ) => {
1498+ const mg = this . minGranularity ( prevGran , d . resolvedGranularity ( ) ) ;
15001499 if ( mg === d . resolvedGranularity ( ) ) {
1501- dateSeriesDimension = d ;
1500+ return [ d , mg ] ;
15021501 }
1503- return mg ;
1504- } , undefined ) ;
1502+ return [ prevDim , mg ] ;
1503+ } , [ null , null ] ) ;
15051504
15061505 const dateSeriesSql = this . dateSeriesSql ( dateSeriesDimension ) ;
15071506
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ export class BaseTimeDimension extends BaseFilter {
8585 return this . query . escapeColumnName ( `${ this . dimension } _series` ) ;
8686 }
8787
88- public dateSeriesSelectColumn ( dateSeriesAliasName : string , dateSeriesGranularity : string ) {
88+ public dateSeriesSelectColumn ( dateSeriesAliasName : string | null , dateSeriesGranularity ? : string ) {
8989 if ( ! this . granularityObj ) {
9090 return null ;
9191 }
You can’t perform that action at this time.
0 commit comments