Skip to content

Commit d8571d0

Browse files
committed
fix dateBin implementation across all Queries (timeStampCast → dateTimeCast)
1 parent 9e8b843 commit d8571d0

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

packages/cubejs-databricks-jdbc-driver/src/DatabricksQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export class DatabricksQuery extends BaseQuery {
9696
const [intervalFormatted, timeUnit] = this.formatInterval(interval);
9797
const beginOfTime = this.dateTimeCast('\'1970-01-01T00:00:00\'');
9898

99-
return `${this.timeStampCast(`'${origin}'`)} + INTERVAL ${intervalFormatted} *
99+
return `${this.dateTimeCast(`'${origin}'`)} + INTERVAL ${intervalFormatted} *
100100
floor(
101-
date_diff(${timeUnit}, ${this.timeStampCast(`'${origin}'`)}, ${source}) /
101+
date_diff(${timeUnit}, ${this.dateTimeCast(`'${origin}'`)}, ${source}) /
102102
date_diff(${timeUnit}, ${beginOfTime}, ${beginOfTime} + INTERVAL ${intervalFormatted})
103103
)`;
104104
}

packages/cubejs-duckdb-driver/src/DuckDBQuery.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export class DuckDBQuery extends BaseQuery {
3535
*/
3636
public dateBin(interval: string, source: string, origin: string): string {
3737
const timeUnit = this.diffTimeUnitForInterval(interval);
38-
const beginOfTime = this.timeStampCast('\'1970-01-01 00:00:00.000\'');
38+
const beginOfTime = this.dateTimeCast('\'1970-01-01 00:00:00.000\'');
3939

40-
return `${this.timeStampCast(`'${origin}'`)}' + INTERVAL '${interval}' *
40+
return `${this.dateTimeCast(`'${origin}'`)}' + INTERVAL '${interval}' *
4141
floor(
42-
date_diff('${timeUnit}', ${this.timeStampCast(`'${origin}'`)}, ${source}) /
42+
date_diff('${timeUnit}', ${this.dateTimeCast(`'${origin}'`)}, ${source}) /
4343
date_diff('${timeUnit}', ${beginOfTime}, ${beginOfTime} + INTERVAL '${interval}')
4444
)::int`;
4545
}

packages/cubejs-schema-compiler/src/adapter/ClickHouseQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ export class ClickHouseQuery extends BaseQuery {
7373

7474
return `date_add(${timeUnit},
7575
FLOOR(
76-
date_diff(${timeUnit}, ${this.timeStampCast(`'${origin}'`)}, ${source}) /
76+
date_diff(${timeUnit}, ${this.dateTimeCast(`'${origin}'`)}, ${source}) /
7777
date_diff(${timeUnit}, ${beginOfTime}, ${beginOfTime} + ${intervalFormatted})
7878
) * date_diff(${timeUnit}, ${beginOfTime}, ${beginOfTime} + ${intervalFormatted}),
79-
${this.timeStampCast(`'${origin}'`)}
79+
${this.dateTimeCast(`'${origin}'`)}
8080
)`;
8181
}
8282

packages/cubejs-schema-compiler/src/adapter/CubeStoreQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class CubeStoreQuery extends BaseQuery {
7171
* intervals relative to origin timestamp point.
7272
*/
7373
public dateBin(interval: string, source: string, origin: string): string {
74-
return `DATE_BIN(INTERVAL ${this.formatInterval(interval)}, ${this.timeStampCast(source)}, ${this.timeStampCast(`'${origin}'`)})`;
74+
return `DATE_BIN(INTERVAL ${this.formatInterval(interval)}, ${this.dateTimeCast(source)}, ${this.dateTimeCast(`'${origin}'`)})`;
7575
}
7676

7777
/**

packages/cubejs-schema-compiler/src/adapter/MssqlQuery.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ export class MssqlQuery extends BaseQuery {
8888
* The formula operates with seconds diffs so it won't produce human-expected dates aligned with offset date parts.
8989
*/
9090
public dateBin(interval: string, source: string, origin: string): string {
91-
const beginOfTime = this.timeStampCast('DATEFROMPARTS(1970, 1, 1)');
91+
const beginOfTime = this.dateTimeCast('DATEFROMPARTS(1970, 1, 1)');
9292
const timeUnit = this.diffTimeUnitForInterval(interval);
9393

9494
// Need to explicitly cast one argument of floor to float to trigger correct sign logic
9595
return `DATEADD(${timeUnit},
9696
FLOOR(
97-
CAST(DATEDIFF(${timeUnit}, ${this.timeStampCast(`'${origin}'`)}, ${source}) AS FLOAT) /
97+
CAST(DATEDIFF(${timeUnit}, ${this.dateTimeCast(`'${origin}'`)}, ${source}) AS FLOAT) /
9898
DATEDIFF(${timeUnit}, ${beginOfTime}, ${this.addInterval(beginOfTime, interval)})
9999
) * DATEDIFF(${timeUnit}, ${beginOfTime}, ${this.addInterval(beginOfTime, interval)}),
100-
${this.timeStampCast(`'${origin}'`)}
100+
${this.dateTimeCast(`'${origin}'`)}
101101
)`;
102102
}
103103

packages/cubejs-schema-compiler/src/adapter/MysqlQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ export class MysqlQuery extends BaseQuery {
7272

7373
return `TIMESTAMPADD(${timeUnit},
7474
FLOOR(
75-
TIMESTAMPDIFF(${timeUnit}, ${this.timeStampCast(`'${origin}'`)}, ${source}) /
75+
TIMESTAMPDIFF(${timeUnit}, ${this.dateTimeCast(`'${origin}'`)}, ${source}) /
7676
TIMESTAMPDIFF(${timeUnit}, '1970-01-01 00:00:00', '1970-01-01 00:00:00' + INTERVAL ${intervalFormatted})
7777
) * TIMESTAMPDIFF(${timeUnit}, '1970-01-01 00:00:00', '1970-01-01 00:00:00' + INTERVAL ${intervalFormatted}),
78-
${this.timeStampCast(`'${origin}'`)}
78+
${this.dateTimeCast(`'${origin}'`)}
7979
)`;
8080
}
8181

packages/cubejs-schema-compiler/src/adapter/OracleQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class OracleFilter extends BaseFilter {
1919
}
2020

2121
/**
22-
* "ILIKE" does't support
22+
* "ILIKE" is not supported
2323
*/
2424
public likeIgnoreCase(column, not, param, type) {
2525
const p = (!type || type === 'contains' || type === 'ends') ? '\'%\' || ' : '';
@@ -30,7 +30,7 @@ class OracleFilter extends BaseFilter {
3030

3131
export class OracleQuery extends BaseQuery {
3232
/**
33-
* "LIMIT" on Oracle it's illegal
33+
* "LIMIT" on Oracle is illegal
3434
* TODO replace with limitOffsetClause override
3535
*/
3636
public groupByDimensionLimit() {

packages/cubejs-schema-compiler/src/adapter/SnowflakeQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export class SnowflakeQuery extends BaseQuery {
5353

5454
return `DATEADD(${timeUnit},
5555
FLOOR(
56-
DATEDIFF(${timeUnit}, ${this.timeStampCast(`'${origin}'`)}, ${source}) /
56+
DATEDIFF(${timeUnit}, ${this.dateTimeCast(`'${origin}'`)}, ${source}) /
5757
DATEDIFF(${timeUnit}, ${beginOfTime}, (${beginOfTime} + interval '${intervalFormatted}'))
5858
) * DATEDIFF(${timeUnit}, ${beginOfTime}, (${beginOfTime} + interval '${intervalFormatted}')),
59-
${this.timeStampCast(`'${origin}'`)})`;
59+
${this.dateTimeCast(`'${origin}'`)})`;
6060
}
6161

6262
/**

0 commit comments

Comments
 (0)