Skip to content

Commit b8b5c57

Browse files
committed
fix(schema-compiler): Fix incorrect truncated time dimensions over time series queries for BigQuery
1 parent 84419ae commit b8b5c57

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
@@ -6303,47 +6303,47 @@ Array [
63036303
Object {
63046304
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
63056305
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
6306-
"BigECommerce.rollingCountApproxBy2Day": null,
6306+
"BigECommerce.rollingCountApproxBy2Day": 0,
63076307
},
63086308
Object {
63096309
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
63106310
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
6311-
"BigECommerce.rollingCountApproxBy2Day": null,
6311+
"BigECommerce.rollingCountApproxBy2Day": 0,
63126312
},
63136313
Object {
63146314
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
63156315
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
6316-
"BigECommerce.rollingCountApproxBy2Day": null,
6316+
"BigECommerce.rollingCountApproxBy2Day": 0,
63176317
},
63186318
Object {
63196319
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
63206320
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6321-
"BigECommerce.rollingCountApproxBy2Day": null,
6321+
"BigECommerce.rollingCountApproxBy2Day": 0,
63226322
},
63236323
Object {
63246324
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
63256325
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
6326-
"BigECommerce.rollingCountApproxBy2Day": null,
6326+
"BigECommerce.rollingCountApproxBy2Day": 0,
63276327
},
63286328
Object {
63296329
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
63306330
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
6331-
"BigECommerce.rollingCountApproxBy2Day": null,
6331+
"BigECommerce.rollingCountApproxBy2Day": 0,
63326332
},
63336333
Object {
63346334
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
63356335
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6336-
"BigECommerce.rollingCountApproxBy2Day": null,
6336+
"BigECommerce.rollingCountApproxBy2Day": 0,
63376337
},
63386338
Object {
63396339
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
63406340
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6341-
"BigECommerce.rollingCountApproxBy2Day": null,
6341+
"BigECommerce.rollingCountApproxBy2Day": 0,
63426342
},
63436343
Object {
63446344
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
63456345
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
6346-
"BigECommerce.rollingCountApproxBy2Day": null,
6346+
"BigECommerce.rollingCountApproxBy2Day": 0,
63476347
},
63486348
Object {
63496349
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
@@ -6353,12 +6353,12 @@ Array [
63536353
Object {
63546354
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
63556355
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
6356-
"BigECommerce.rollingCountApproxBy2Day": null,
6356+
"BigECommerce.rollingCountApproxBy2Day": 0,
63576357
},
63586358
Object {
63596359
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
63606360
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
6361-
"BigECommerce.rollingCountApproxBy2Day": null,
6361+
"BigECommerce.rollingCountApproxBy2Day": 0,
63626362
},
63636363
]
63646364
`;
@@ -6403,7 +6403,7 @@ Array [
64036403
Object {
64046404
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
64056405
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6406-
"BigECommerce.rollingCountApproxBy2Month": null,
6406+
"BigECommerce.rollingCountApproxBy2Month": 0,
64076407
},
64086408
Object {
64096409
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
@@ -6448,7 +6448,7 @@ Array [
64486448
Object {
64496449
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
64506450
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6451-
"BigECommerce.rollingCountApproxBy2Week": null,
6451+
"BigECommerce.rollingCountApproxBy2Week": 0,
64526452
},
64536453
Object {
64546454
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
@@ -6463,12 +6463,12 @@ Array [
64636463
Object {
64646464
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
64656465
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6466-
"BigECommerce.rollingCountApproxBy2Week": null,
6466+
"BigECommerce.rollingCountApproxBy2Week": 0,
64676467
},
64686468
Object {
64696469
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
64706470
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6471-
"BigECommerce.rollingCountApproxBy2Week": null,
6471+
"BigECommerce.rollingCountApproxBy2Week": 0,
64726472
},
64736473
Object {
64746474
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",

0 commit comments

Comments
 (0)