Skip to content

Commit 527ea92

Browse files
committed
fix(schema-compiler): Fix incorrect truncated time dimensions over time series queries for BigQuery
1 parent fe810c4 commit 527ea92

File tree

2 files changed

+15
-39
lines changed

2 files changed

+15
-39
lines changed

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ export class BigqueryQuery extends BaseQuery {
142142
return new BigqueryFilter(this, filter);
143143
}
144144

145-
public dateSeriesSql(timeDimension: BaseTimeDimension) {
146-
return `${timeDimension.dateSeriesAliasName()} AS (${this.seriesSql(timeDimension)})`;
147-
}
148-
149145
public seriesSql(timeDimension: BaseTimeDimension) {
150146
const values = timeDimension.timeSeries().map(
151147
([from, to]) => `select '${from}' f, '${to}' t`
@@ -161,26 +157,6 @@ export class BigqueryQuery extends BaseQuery {
161157
return 6;
162158
}
163159

164-
public overTimeSeriesSelect(cumulativeMeasures, dateSeriesSql, baseQuery, dateJoinConditionSql, baseQueryAlias) {
165-
const forSelect = this.overTimeSeriesForSelect(cumulativeMeasures);
166-
const outerSeriesAlias = this.cubeAlias('outer_series');
167-
const outerBase = this.cubeAlias('outer_base');
168-
const timeDimensionAlias = this.timeDimensions.map(d => d.aliasName()).filter(d => !!d)[0];
169-
const aliasesForSelect = this.timeDimensions.map(d => d.dateSeriesSelectColumn(outerSeriesAlias)).concat(
170-
this.dimensions.concat(cumulativeMeasures).map(s => s.aliasName())
171-
).filter(c => !!c).join(', ');
172-
const dateSeriesAlias = this.timeDimensions.map(d => `${d.dateSeriesAliasName()}`).filter(c => !!c)[0];
173-
return `
174-
WITH ${dateSeriesSql} SELECT ${aliasesForSelect} FROM
175-
${dateSeriesAlias} ${outerSeriesAlias}
176-
LEFT JOIN (
177-
SELECT ${forSelect} FROM ${dateSeriesAlias}
178-
INNER JOIN (${baseQuery}) AS ${baseQueryAlias} ON ${dateJoinConditionSql}
179-
${this.groupByClause()}
180-
) AS ${outerBase} ON ${outerSeriesAlias}.${this.escapeColumnName('date_from')} = ${outerBase}.${timeDimensionAlias}
181-
`;
182-
}
183-
184160
public subtractInterval(date, interval) {
185161
return `DATETIME_SUB(${date}, INTERVAL ${this.formatInterval(interval)[0]})`;
186162
}

packages/cubejs-testing-drivers/test/__snapshots__/bigquery-export-bucket-gcs-full.test.ts.snap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6311,47 +6311,47 @@ Array [
63116311
Object {
63126312
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
63136313
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
6314-
"BigECommerce.rollingCountApproxBy2Day": null,
6314+
"BigECommerce.rollingCountApproxBy2Day": 0,
63156315
},
63166316
Object {
63176317
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
63186318
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
6319-
"BigECommerce.rollingCountApproxBy2Day": null,
6319+
"BigECommerce.rollingCountApproxBy2Day": 0,
63206320
},
63216321
Object {
63226322
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
63236323
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
6324-
"BigECommerce.rollingCountApproxBy2Day": null,
6324+
"BigECommerce.rollingCountApproxBy2Day": 0,
63256325
},
63266326
Object {
63276327
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
63286328
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6329-
"BigECommerce.rollingCountApproxBy2Day": null,
6329+
"BigECommerce.rollingCountApproxBy2Day": 0,
63306330
},
63316331
Object {
63326332
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
63336333
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
6334-
"BigECommerce.rollingCountApproxBy2Day": null,
6334+
"BigECommerce.rollingCountApproxBy2Day": 0,
63356335
},
63366336
Object {
63376337
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
63386338
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
6339-
"BigECommerce.rollingCountApproxBy2Day": null,
6339+
"BigECommerce.rollingCountApproxBy2Day": 0,
63406340
},
63416341
Object {
63426342
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
63436343
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6344-
"BigECommerce.rollingCountApproxBy2Day": null,
6344+
"BigECommerce.rollingCountApproxBy2Day": 0,
63456345
},
63466346
Object {
63476347
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
63486348
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6349-
"BigECommerce.rollingCountApproxBy2Day": null,
6349+
"BigECommerce.rollingCountApproxBy2Day": 0,
63506350
},
63516351
Object {
63526352
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
63536353
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
6354-
"BigECommerce.rollingCountApproxBy2Day": null,
6354+
"BigECommerce.rollingCountApproxBy2Day": 0,
63556355
},
63566356
Object {
63576357
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
@@ -6361,12 +6361,12 @@ Array [
63616361
Object {
63626362
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
63636363
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
6364-
"BigECommerce.rollingCountApproxBy2Day": null,
6364+
"BigECommerce.rollingCountApproxBy2Day": 0,
63656365
},
63666366
Object {
63676367
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
63686368
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
6369-
"BigECommerce.rollingCountApproxBy2Day": null,
6369+
"BigECommerce.rollingCountApproxBy2Day": 0,
63706370
},
63716371
]
63726372
`;
@@ -6411,7 +6411,7 @@ Array [
64116411
Object {
64126412
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
64136413
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6414-
"BigECommerce.rollingCountApproxBy2Month": null,
6414+
"BigECommerce.rollingCountApproxBy2Month": 0,
64156415
},
64166416
Object {
64176417
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
@@ -6456,7 +6456,7 @@ Array [
64566456
Object {
64576457
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
64586458
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6459-
"BigECommerce.rollingCountApproxBy2Week": null,
6459+
"BigECommerce.rollingCountApproxBy2Week": 0,
64606460
},
64616461
Object {
64626462
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
@@ -6471,12 +6471,12 @@ Array [
64716471
Object {
64726472
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
64736473
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6474-
"BigECommerce.rollingCountApproxBy2Week": null,
6474+
"BigECommerce.rollingCountApproxBy2Week": 0,
64756475
},
64766476
Object {
64776477
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
64786478
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6479-
"BigECommerce.rollingCountApproxBy2Week": null,
6479+
"BigECommerce.rollingCountApproxBy2Week": 0,
64806480
},
64816481
Object {
64826482
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",

0 commit comments

Comments
 (0)