Skip to content

Commit

Permalink
fix dateBin in BigQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Aug 28, 2024
1 parent 8c75fcb commit 6ca9d16
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export class BigqueryQuery extends BaseQuery {
*/
public dateBin(interval: string, source: string, origin: string): string {
const intervalFormatted = this.formatInterval(interval);
const beginOfTime = this.dateTimeCast('1970-01-01T00:00:00');
const beginOfTime = this.dateTimeCast(`'1970-01-01T00:00:00'`);

return `${this.dateTimeCast(origin)} + INTERVAL ${intervalFormatted} *
return `${this.dateTimeCast(`'${origin}'`)} + INTERVAL ${intervalFormatted} *
CAST(FLOOR(
DATETIME_DIFF(${source}, ${this.dateTimeCast(origin)}, SECOND) /
DATETIME_DIFF(${source}, ${this.dateTimeCast(`'${origin}'`)}, SECOND) /
DATETIME_DIFF(${beginOfTime} + INTERVAL ${intervalFormatted}, ${beginOfTime}, SECOND)
) AS INT64)`;
}
Expand Down

0 comments on commit 6ca9d16

Please sign in to comment.