@@ -215,6 +215,29 @@ export class BigqueryQuery extends BaseQuery {
215215 return `UNIX_SECONDS(${ this . nowTimestampSql ( ) } )` ;
216216 }
217217
218+ // Should be protected, but BaseQuery is in js
219+ public override dateFromStartToEndConditionSql ( dateJoinCondition , fromRollup , isFromStartToEnd ) {
220+ return dateJoinCondition . map (
221+ ( [ d , f ] ) => ( {
222+ filterToWhere : ( ) => {
223+ const timeSeries = d . timeSeries ( ) ;
224+ return f (
225+ isFromStartToEnd ?
226+ this . timeStampCast ( this . paramAllocator . allocateParam ( timeSeries [ 0 ] [ 0 ] ) ) :
227+ `${ this . timeStampInClientTz ( d . dateFromParam ( ) ) } ` ,
228+ isFromStartToEnd ?
229+ this . timeStampCast ( this . paramAllocator . allocateParam ( timeSeries [ timeSeries . length - 1 ] [ 1 ] ) ) :
230+ `${ this . timeStampInClientTz ( d . dateToParam ( ) ) } ` ,
231+ `${ fromRollup ? this . dimensionSql ( d ) : d . convertedToTz ( ) } ` ,
232+ `${ this . timeStampInClientTz ( d . dateFromParam ( ) ) } ` ,
233+ `${ this . timeStampInClientTz ( d . dateToParam ( ) ) } ` ,
234+ isFromStartToEnd
235+ ) ;
236+ }
237+ } )
238+ ) ;
239+ }
240+
218241 // eslint-disable-next-line no-unused-vars
219242 public preAggregationLoadSql ( cube , preAggregation , tableName ) {
220243 return this . preAggregationSql ( cube , preAggregation ) ;
@@ -250,7 +273,7 @@ export class BigqueryQuery extends BaseQuery {
250273 const templates = super . sqlTemplates ( ) ;
251274 templates . quotes . identifiers = '`' ;
252275 templates . quotes . escape = '\\`' ;
253- templates . functions . DATETRUNC = 'DATETIME_TRUNC(CAST({{ args[1] }} AS DATETIME), {% if date_part|upper == \'WEEK\' %}{{ \'WEEK(MONDAY)\' }}{% else %}{{ date_part }}{% endif %})' ;
276+ templates . functions . DATETRUNC = 'TIMESTAMP( DATETIME_TRUNC(CAST({{ args[1] }} AS DATETIME), {% if date_part|upper == \'WEEK\' %}{{ \'WEEK(MONDAY)\' }}{% else %}{{ date_part }}{% endif %}) )' ;
254277 templates . functions . LOG = 'LOG({{ args_concat }}{% if args[1] is undefined %}, 10{% endif %})' ;
255278 templates . functions . BTRIM = 'TRIM({{ args_concat }})' ;
256279 templates . functions . STRPOS = 'STRPOS({{ args_concat }})' ;
@@ -263,7 +286,7 @@ export class BigqueryQuery extends BaseQuery {
263286 templates . expressions . binary = '{% if op == \'%\' %}MOD({{ left }}, {{ right }}){% else %}({{ left }} {{ op }} {{ right }}){% endif %}' ;
264287 templates . expressions . interval = 'INTERVAL {{ interval }}' ;
265288 templates . expressions . extract = 'EXTRACT({% if date_part == \'DOW\' %}DAYOFWEEK{% elif date_part == \'DOY\' %}DAYOFYEAR{% else %}{{ date_part }}{% endif %} FROM {{ expr }})' ;
266- templates . expressions . timestamp_literal = 'DATETIME( TIMESTAMP(\'{{ value }}\') )' ;
289+ templates . expressions . timestamp_literal = 'TIMESTAMP(\'{{ value }}\')' ;
267290 delete templates . expressions . ilike ;
268291 delete templates . expressions . like_escape ;
269292 templates . filters . like_pattern = 'CONCAT({% if start_wild %}\'%\'{% else %}\'\'{% endif %}, LOWER({{ value }}), {% if end_wild %}\'%\'{% else %}\'\'{% endif %})' ;
0 commit comments