@@ -945,45 +945,50 @@ export class BaseQuery {
945945 }
946946
947947 runningTotalDateJoinCondition ( ) {
948- return this . timeDimensions . map (
949- d => [
950- d ,
951- // eslint-disable-next-line @typescript-eslint/no-unused-vars
952- ( dateFrom , dateTo , dateField , dimensionDateFrom , dimensionDateTo ) => `${ dateField } >= ${ dimensionDateFrom } AND ${ dateField } <= ${ dateTo } `
953- ]
954- ) ;
948+ return this . timeDimensions
949+ . map (
950+ d => [
951+ d ,
952+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
953+ ( dateFrom , dateTo , dateField , dimensionDateFrom , dimensionDateTo ) => `${ dateField } >= ${ dimensionDateFrom } AND ${ dateField } <= ${ dateTo } `
954+ ]
955+ ) ;
955956 }
956957
957958 rollingWindowToDateJoinCondition ( granularity ) {
958- return this . timeDimensions . map (
959- d => [
960- d ,
961- ( dateFrom , dateTo , dateField , dimensionDateFrom , dimensionDateTo , isFromStartToEnd ) => `${ dateField } >= ${ this . timeGroupedColumn ( granularity , dateFrom ) } AND ${ dateField } <= ${ dateTo } `
962- ]
963- ) ;
959+ return this . timeDimensions
960+ . filter ( td => td . granularity )
961+ . map (
962+ d => [
963+ d ,
964+ ( dateFrom , dateTo , dateField , dimensionDateFrom , dimensionDateTo , isFromStartToEnd ) => `${ dateField } >= ${ this . timeGroupedColumn ( granularity , dateFrom ) } AND ${ dateField } <= ${ dateTo } `
965+ ]
966+ ) ;
964967 }
965968
966969 rollingWindowDateJoinCondition ( trailingInterval , leadingInterval , offset ) {
967970 offset = offset || 'end' ;
968- return this . timeDimensions . map (
969- d => [ d , ( dateFrom , dateTo , dateField , dimensionDateFrom , dimensionDateTo , isFromStartToEnd ) => {
971+ return this . timeDimensions
972+ . filter ( td => td . granularity )
973+ . map (
974+ d => [ d , ( dateFrom , dateTo , dateField , dimensionDateFrom , dimensionDateTo , isFromStartToEnd ) => {
970975 // dateFrom based window
971- const conditions = [ ] ;
972- if ( trailingInterval !== 'unbounded' ) {
973- const startDate = isFromStartToEnd || offset === 'start' ? dateFrom : dateTo ;
974- const trailingStart = trailingInterval ? this . subtractInterval ( startDate , trailingInterval ) : startDate ;
975- const sign = offset === 'start' ? '>=' : '>' ;
976- conditions . push ( `${ dateField } ${ sign } ${ trailingStart } ` ) ;
977- }
978- if ( leadingInterval !== 'unbounded' ) {
979- const endDate = isFromStartToEnd || offset === 'end' ? dateTo : dateFrom ;
980- const leadingEnd = leadingInterval ? this . addInterval ( endDate , leadingInterval ) : endDate ;
981- const sign = offset === 'end' ? '<=' : '<' ;
982- conditions . push ( `${ dateField } ${ sign } ${ leadingEnd } ` ) ;
983- }
984- return conditions . length ? conditions . join ( ' AND ' ) : '1 = 1' ;
985- } ]
986- ) ;
976+ const conditions = [ ] ;
977+ if ( trailingInterval !== 'unbounded' ) {
978+ const startDate = isFromStartToEnd || offset === 'start' ? dateFrom : dateTo ;
979+ const trailingStart = trailingInterval ? this . subtractInterval ( startDate , trailingInterval ) : startDate ;
980+ const sign = offset === 'start' ? '>=' : '>' ;
981+ conditions . push ( `${ dateField } ${ sign } ${ trailingStart } ` ) ;
982+ }
983+ if ( leadingInterval !== 'unbounded' ) {
984+ const endDate = isFromStartToEnd || offset === 'end' ? dateTo : dateFrom ;
985+ const leadingEnd = leadingInterval ? this . addInterval ( endDate , leadingInterval ) : endDate ;
986+ const sign = offset === 'end' ? '<=' : '<' ;
987+ conditions . push ( `${ dateField } ${ sign } ${ leadingEnd } ` ) ;
988+ }
989+ return conditions . length ? conditions . join ( ' AND ' ) : '1 = 1' ;
990+ } ]
991+ ) ;
987992 }
988993
989994 /**
0 commit comments