Skip to content

Commit 0c3a255

Browse files
committed
in work
1 parent ed9dfb4 commit 0c3a255

File tree

9 files changed

+306
-12
lines changed

9 files changed

+306
-12
lines changed

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ export class BaseQuery {
761761
}
762762
}
763763

764-
const res = this.compilers.compiler.withQuery(
764+
return this.compilers.compiler.withQuery(
765765
this,
766766
() => this.cacheValue(
767767
['buildSqlAndParams', exportAnnotatedSql],
@@ -773,8 +773,6 @@ export class BaseQuery {
773773
{ cache: this.queryCache }
774774
)
775775
);
776-
console.log("!!!! old res ", res[0]);
777-
return res;
778776
}
779777

780778
buildSqlAndParamsRust(exportAnnotatedSql) {
@@ -819,7 +817,6 @@ export class BaseQuery {
819817
if (preAggregation) {
820818
this.preAggregations.preAggregationForQuery = preAggregation;
821819
}
822-
console.log("!!!! new res ", query);
823820
return [query, paramsArray];
824821
}
825822

packages/cubejs-testing-drivers/fixtures/_schemas.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@
421421
"trailing": "2 month"
422422
}
423423
},
424+
{
425+
"name": "rollingCountYTD",
426+
"type": "count",
427+
"rollingWindow": {
428+
"type": "to_date",
429+
"granularity": "year"
430+
}
431+
},
424432
{
425433
"name": "rollingCountApproxBy2Day",
426434
"type": "count_distinct_approx",

packages/cubejs-testing-drivers/fixtures/postgres.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
"---------------------------------------",
156156
"querying Products: dimensions -- doesn't work wo ordering",
157157
"querying ECommerce: total quantity, avg discount, total sales, total profit by product + order + total -- rounding in athena",
158-
"querying ECommerce: total quantity, avg discount, total sales, total profit by product + order + total -- noisy test"
158+
"querying ECommerce: total quantity, avg discount, total sales, total profit by product + order + total -- noisy test",
159+
"querying BigECommerce: rolling window by 2 day without date range -- requires tesseract",
160+
"querying BigECommerce: rolling window by 2 month without date range -- requires tesseract",
161+
"querying BigECommerce: rolling window YTD without date range -- requires tesseract"
159162
]
160163
}

packages/cubejs-testing-drivers/src/tests/testQueries.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,33 @@ export function testQueries(type: string, { includeIncrementalSchemaSuite, exten
15791579
expect(response.rawData()).toMatchSnapshot();
15801580
});
15811581

1582+
execute('querying BigECommerce: rolling window YTD', async () => {
1583+
const response = await client.load({
1584+
measures: [
1585+
'BigECommerce.rollingCountYTD',
1586+
],
1587+
timeDimensions: [{
1588+
dimension: 'BigECommerce.orderDate',
1589+
granularity: 'month',
1590+
dateRange: ['2020-01-01', '2020-12-31'],
1591+
}],
1592+
});
1593+
expect(response.rawData()).toMatchSnapshot();
1594+
});
1595+
1596+
execute('querying BigECommerce: rolling window YTD without date range', async () => {
1597+
const response = await client.load({
1598+
measures: [
1599+
'BigECommerce.rollingCountYTD',
1600+
],
1601+
timeDimensions: [{
1602+
dimension: 'BigECommerce.orderDate',
1603+
granularity: 'month',
1604+
}],
1605+
});
1606+
expect(response.rawData()).toMatchSnapshot();
1607+
});
1608+
15821609
if (includeHLLSuite) {
15831610
execute('querying BigECommerce: rolling count_distinct_approx window by 2 day', async () => {
15841611
const response = await client.load({

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

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6493,6 +6493,136 @@ Array [
64936493
]
64946494
`;
64956495

6496+
exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: rolling window YTD 1`] = `
6497+
Array [
6498+
Object {
6499+
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
6500+
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
6501+
"BigECommerce.rollingCountYTD": 2,
6502+
},
6503+
Object {
6504+
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
6505+
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
6506+
"BigECommerce.rollingCountYTD": 3,
6507+
},
6508+
Object {
6509+
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
6510+
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
6511+
"BigECommerce.rollingCountYTD": 5,
6512+
},
6513+
Object {
6514+
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
6515+
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6516+
"BigECommerce.rollingCountYTD": 6,
6517+
},
6518+
Object {
6519+
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
6520+
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
6521+
"BigECommerce.rollingCountYTD": 11,
6522+
},
6523+
Object {
6524+
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
6525+
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
6526+
"BigECommerce.rollingCountYTD": 18,
6527+
},
6528+
Object {
6529+
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
6530+
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6531+
"BigECommerce.rollingCountYTD": 18,
6532+
},
6533+
Object {
6534+
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
6535+
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6536+
"BigECommerce.rollingCountYTD": 18,
6537+
},
6538+
Object {
6539+
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
6540+
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
6541+
"BigECommerce.rollingCountYTD": 24,
6542+
},
6543+
Object {
6544+
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
6545+
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
6546+
"BigECommerce.rollingCountYTD": 28,
6547+
},
6548+
Object {
6549+
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
6550+
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
6551+
"BigECommerce.rollingCountYTD": 37,
6552+
},
6553+
Object {
6554+
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
6555+
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
6556+
"BigECommerce.rollingCountYTD": 44,
6557+
},
6558+
]
6559+
`;
6560+
6561+
exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: rolling window YTD without date range 1`] = `
6562+
Array [
6563+
Object {
6564+
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
6565+
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
6566+
"BigECommerce.rollingCountYTD": 2,
6567+
},
6568+
Object {
6569+
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
6570+
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
6571+
"BigECommerce.rollingCountYTD": 3,
6572+
},
6573+
Object {
6574+
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
6575+
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
6576+
"BigECommerce.rollingCountYTD": 5,
6577+
},
6578+
Object {
6579+
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
6580+
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
6581+
"BigECommerce.rollingCountYTD": 6,
6582+
},
6583+
Object {
6584+
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
6585+
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
6586+
"BigECommerce.rollingCountYTD": 11,
6587+
},
6588+
Object {
6589+
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
6590+
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
6591+
"BigECommerce.rollingCountYTD": 18,
6592+
},
6593+
Object {
6594+
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
6595+
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
6596+
"BigECommerce.rollingCountYTD": 18,
6597+
},
6598+
Object {
6599+
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
6600+
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
6601+
"BigECommerce.rollingCountYTD": 18,
6602+
},
6603+
Object {
6604+
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
6605+
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
6606+
"BigECommerce.rollingCountYTD": 24,
6607+
},
6608+
Object {
6609+
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
6610+
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
6611+
"BigECommerce.rollingCountYTD": 28,
6612+
},
6613+
Object {
6614+
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
6615+
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
6616+
"BigECommerce.rollingCountYTD": 37,
6617+
},
6618+
Object {
6619+
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
6620+
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
6621+
"BigECommerce.rollingCountYTD": 44,
6622+
},
6623+
]
6624+
`;
6625+
64966626
exports[`Queries with the @cubejs-backend/bigquery-driver querying BigECommerce: rolling window by 2 day 1`] = `
64976627
Array [
64986628
Object {

packages/cubejs-testing-drivers/test/__snapshots__/postgres-full.test.ts.snap

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11365,6 +11365,136 @@ Array [
1136511365
]
1136611366
`;
1136711367

11368+
exports[`Queries with the @cubejs-backend/postgres-driver querying BigECommerce: rolling window YTD 1`] = `
11369+
Array [
11370+
Object {
11371+
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
11372+
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
11373+
"BigECommerce.rollingCountYTD": "2",
11374+
},
11375+
Object {
11376+
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
11377+
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
11378+
"BigECommerce.rollingCountYTD": "3",
11379+
},
11380+
Object {
11381+
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
11382+
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
11383+
"BigECommerce.rollingCountYTD": "5",
11384+
},
11385+
Object {
11386+
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
11387+
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
11388+
"BigECommerce.rollingCountYTD": "6",
11389+
},
11390+
Object {
11391+
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
11392+
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
11393+
"BigECommerce.rollingCountYTD": "11",
11394+
},
11395+
Object {
11396+
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
11397+
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
11398+
"BigECommerce.rollingCountYTD": "18",
11399+
},
11400+
Object {
11401+
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
11402+
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
11403+
"BigECommerce.rollingCountYTD": "18",
11404+
},
11405+
Object {
11406+
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
11407+
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
11408+
"BigECommerce.rollingCountYTD": "18",
11409+
},
11410+
Object {
11411+
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
11412+
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
11413+
"BigECommerce.rollingCountYTD": "24",
11414+
},
11415+
Object {
11416+
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
11417+
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
11418+
"BigECommerce.rollingCountYTD": "28",
11419+
},
11420+
Object {
11421+
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
11422+
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
11423+
"BigECommerce.rollingCountYTD": "37",
11424+
},
11425+
Object {
11426+
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
11427+
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
11428+
"BigECommerce.rollingCountYTD": "44",
11429+
},
11430+
]
11431+
`;
11432+
11433+
exports[`Queries with the @cubejs-backend/postgres-driver querying BigECommerce: rolling window YTD without date range 1`] = `
11434+
Array [
11435+
Object {
11436+
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
11437+
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
11438+
"BigECommerce.rollingCountYTD": "2",
11439+
},
11440+
Object {
11441+
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
11442+
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
11443+
"BigECommerce.rollingCountYTD": "3",
11444+
},
11445+
Object {
11446+
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
11447+
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
11448+
"BigECommerce.rollingCountYTD": "5",
11449+
},
11450+
Object {
11451+
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
11452+
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
11453+
"BigECommerce.rollingCountYTD": "6",
11454+
},
11455+
Object {
11456+
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
11457+
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
11458+
"BigECommerce.rollingCountYTD": "11",
11459+
},
11460+
Object {
11461+
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
11462+
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
11463+
"BigECommerce.rollingCountYTD": "18",
11464+
},
11465+
Object {
11466+
"BigECommerce.orderDate": "2020-07-01T00:00:00.000",
11467+
"BigECommerce.orderDate.month": "2020-07-01T00:00:00.000",
11468+
"BigECommerce.rollingCountYTD": "18",
11469+
},
11470+
Object {
11471+
"BigECommerce.orderDate": "2020-08-01T00:00:00.000",
11472+
"BigECommerce.orderDate.month": "2020-08-01T00:00:00.000",
11473+
"BigECommerce.rollingCountYTD": "18",
11474+
},
11475+
Object {
11476+
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
11477+
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
11478+
"BigECommerce.rollingCountYTD": "24",
11479+
},
11480+
Object {
11481+
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
11482+
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
11483+
"BigECommerce.rollingCountYTD": "28",
11484+
},
11485+
Object {
11486+
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
11487+
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
11488+
"BigECommerce.rollingCountYTD": "37",
11489+
},
11490+
Object {
11491+
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
11492+
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
11493+
"BigECommerce.rollingCountYTD": "44",
11494+
},
11495+
]
11496+
`;
11497+
1136811498
exports[`Queries with the @cubejs-backend/postgres-driver querying BigECommerce: rolling window by 2 day 1`] = `
1136911499
Array [
1137011500
Object {

rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ impl PhysicalPlanBuilder {
980980

981981
let templates = self.query_tools.plan_sql_templates();
982982

983-
let ts_date_range = if templates.supports_generated_time_series() {
983+
let ts_date_range = if templates.supports_generated_time_series() && granularity_obj.is_predefined_granularity() {
984984
if let Some(date_range) = time_dimension_symbol
985985
.get_range_for_time_series(date_range, self.query_tools.timezone())?
986986
{
@@ -998,8 +998,8 @@ impl PhysicalPlanBuilder {
998998
if let Some(date_range) = &time_series.date_range {
999999
TimeSeriesDateRange::Filter(date_range[0].clone(), date_range[1].clone())
10001000
} else {
1001-
return Err(CubeError::internal(
1002-
"Date range is required for time series without date range".to_string(),
1001+
return Err(CubeError::user(
1002+
"Date range is required for time series".to_string(),
10031003
));
10041004
}
10051005
};

0 commit comments

Comments
 (0)