Skip to content

Commit 334d21d

Browse files
committed
fix(schema-compiler): Fix incorrect truncated time dimensions over time series queries for BigQuery
1 parent 02e58d6 commit 334d21d

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
const [intervalFormatted, timeUnit] = this.formatInterval(interval);
186162
if (['YEAR', 'MONTH', 'QUARTER'].includes(timeUnit) || intervalFormatted.includes('WEEK')) {

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
@@ -6327,47 +6327,47 @@ Array [
63276327
Object {
63286328
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
63296329
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
6330-
"BigECommerce.rollingCountApproxBy2Day": null,
6330+
"BigECommerce.rollingCountApproxBy2Day": 0,
63316331
},
63326332
Object {
63336333
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
63346334
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
6335-
"BigECommerce.rollingCountApproxBy2Day": null,
6335+
"BigECommerce.rollingCountApproxBy2Day": 0,
63366336
},
63376337
Object {
63386338
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
63396339
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
6340-
"BigECommerce.rollingCountApproxBy2Day": null,
6340+
"BigECommerce.rollingCountApproxBy2Day": 0,
63416341
},
63426342
Object {
63436343
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
63446344
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6345-
"BigECommerce.rollingCountApproxBy2Day": null,
6345+
"BigECommerce.rollingCountApproxBy2Day": 0,
63466346
},
63476347
Object {
63486348
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
63496349
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
6350-
"BigECommerce.rollingCountApproxBy2Day": null,
6350+
"BigECommerce.rollingCountApproxBy2Day": 0,
63516351
},
63526352
Object {
63536353
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
63546354
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
6355-
"BigECommerce.rollingCountApproxBy2Day": null,
6355+
"BigECommerce.rollingCountApproxBy2Day": 0,
63566356
},
63576357
Object {
63586358
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
63596359
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6360-
"BigECommerce.rollingCountApproxBy2Day": null,
6360+
"BigECommerce.rollingCountApproxBy2Day": 0,
63616361
},
63626362
Object {
63636363
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
63646364
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6365-
"BigECommerce.rollingCountApproxBy2Day": null,
6365+
"BigECommerce.rollingCountApproxBy2Day": 0,
63666366
},
63676367
Object {
63686368
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
63696369
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
6370-
"BigECommerce.rollingCountApproxBy2Day": null,
6370+
"BigECommerce.rollingCountApproxBy2Day": 0,
63716371
},
63726372
Object {
63736373
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
@@ -6377,12 +6377,12 @@ Array [
63776377
Object {
63786378
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
63796379
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
6380-
"BigECommerce.rollingCountApproxBy2Day": null,
6380+
"BigECommerce.rollingCountApproxBy2Day": 0,
63816381
},
63826382
Object {
63836383
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
63846384
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
6385-
"BigECommerce.rollingCountApproxBy2Day": null,
6385+
"BigECommerce.rollingCountApproxBy2Day": 0,
63866386
},
63876387
]
63886388
`;
@@ -6427,7 +6427,7 @@ Array [
64276427
Object {
64286428
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
64296429
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6430-
"BigECommerce.rollingCountApproxBy2Month": null,
6430+
"BigECommerce.rollingCountApproxBy2Month": 0,
64316431
},
64326432
Object {
64336433
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
@@ -6472,7 +6472,7 @@ Array [
64726472
Object {
64736473
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
64746474
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6475-
"BigECommerce.rollingCountApproxBy2Week": null,
6475+
"BigECommerce.rollingCountApproxBy2Week": 0,
64766476
},
64776477
Object {
64786478
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
@@ -6487,12 +6487,12 @@ Array [
64876487
Object {
64886488
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
64896489
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6490-
"BigECommerce.rollingCountApproxBy2Week": null,
6490+
"BigECommerce.rollingCountApproxBy2Week": 0,
64916491
},
64926492
Object {
64936493
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
64946494
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6495-
"BigECommerce.rollingCountApproxBy2Week": null,
6495+
"BigECommerce.rollingCountApproxBy2Week": 0,
64966496
},
64976497
Object {
64986498
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",

0 commit comments

Comments
 (0)