Skip to content

Commit 8ae4bc4

Browse files
committed
fix
1 parent 678e2cb commit 8ae4bc4

File tree

5 files changed

+107
-98
lines changed

5 files changed

+107
-98
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
"querying BigECommerce with Retail Calendar: totalCountRetailMonthAgo",
225225
"querying BigECommerce with Retail Calendar: totalCountRetailWeekAgo",
226226
"SQL API: Timeshift measure from cube",
227+
"querying BigECommerce: multi-stage group by time dimension",
227228

228229
"---- Different results comparing to baseQuery version. Need to investigate ----",
229230
"SQL API: SQL push down push to cube quoted alias",

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@
278278
"SQL API: Extended nested Rollup over asterisk",
279279
"SQL API: SQL push down push to cube quoted alias",
280280

281-
"querying BigECommerce: multi-stage group by time dimension",
282281

283282

284283
"querying BigECommerce: rolling window by 2 day without date range",

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,71 @@ Array [
66
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
77
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
88
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
9-
"BigECommerce.totalProfit": "29.65480",
10-
"BigECommerce.totalProfitForQuarter": "619.44850",
9+
"BigECommerce.totalProfit": 29.6548,
10+
"BigECommerce.totalProfitForQuarter": 619.4485,
1111
},
1212
Object {
1313
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
1414
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
1515
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
16-
"BigECommerce.totalProfit": "6.19920",
17-
"BigECommerce.totalProfitForQuarter": "619.44850",
16+
"BigECommerce.totalProfit": 6.1992,
17+
"BigECommerce.totalProfitForQuarter": 619.4485,
1818
},
1919
Object {
2020
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
2121
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
2222
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
23-
"BigECommerce.totalProfit": "583.59450",
24-
"BigECommerce.totalProfitForQuarter": "619.44850",
23+
"BigECommerce.totalProfit": 583.5945,
24+
"BigECommerce.totalProfitForQuarter": 619.4485,
2525
},
2626
Object {
2727
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
2828
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
2929
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
30-
"BigECommerce.totalProfit": "6.41760",
31-
"BigECommerce.totalProfitForQuarter": "394.33860",
30+
"BigECommerce.totalProfit": 6.4176,
31+
"BigECommerce.totalProfitForQuarter": 394.3386,
3232
},
3333
Object {
3434
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
3535
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
3636
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
37-
"BigECommerce.totalProfit": "353.68490",
38-
"BigECommerce.totalProfitForQuarter": "394.33860",
37+
"BigECommerce.totalProfit": 353.6849,
38+
"BigECommerce.totalProfitForQuarter": 394.3386,
3939
},
4040
Object {
4141
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
4242
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
4343
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
44-
"BigECommerce.totalProfit": "34.23610",
45-
"BigECommerce.totalProfitForQuarter": "394.33860",
44+
"BigECommerce.totalProfit": 34.2361,
45+
"BigECommerce.totalProfitForQuarter": 394.3386,
4646
},
4747
Object {
4848
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
4949
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
5050
"BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000",
51-
"BigECommerce.totalProfit": "461.13320",
52-
"BigECommerce.totalProfitForQuarter": "461.13320",
51+
"BigECommerce.totalProfit": "461.1332",
52+
"BigECommerce.totalProfitForQuarter": 461.1332,
5353
},
5454
Object {
5555
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
5656
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
5757
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
58-
"BigECommerce.totalProfit": "139.99700",
59-
"BigECommerce.totalProfitForQuarter": "1576.63240",
58+
"BigECommerce.totalProfit": 139.997,
59+
"BigECommerce.totalProfitForQuarter": 1576.6324,
6060
},
6161
Object {
6262
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
6363
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
6464
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
65-
"BigECommerce.totalProfit": "1132.66170",
66-
"BigECommerce.totalProfitForQuarter": "1576.63240",
65+
"BigECommerce.totalProfit": 1132.66170,
66+
"BigECommerce.totalProfitForQuarter": 1576.63240,
6767
},
6868
Object {
6969
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
7070
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
7171
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
72-
"BigECommerce.totalProfit": "303.97370",
73-
"BigECommerce.totalProfitForQuarter": "1576.63240",
72+
"BigECommerce.totalProfit": 303.9737,
73+
"BigECommerce.totalProfitForQuarter": 1576.6324,
7474
},
7575
]
7676
`;

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

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,5 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Queries with the @cubejs-backend/snowflake-driver querying BigECommerce: multi-stage group by time dimension 1`] = `
4-
Array [
5-
Object {
6-
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
7-
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
8-
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
9-
"BigECommerce.totalProfit": "29.65480",
10-
"BigECommerce.totalProfitForQuarter": "619.44850",
11-
},
12-
Object {
13-
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
14-
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
15-
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
16-
"BigECommerce.totalProfit": "6.19920",
17-
"BigECommerce.totalProfitForQuarter": "619.44850",
18-
},
19-
Object {
20-
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
21-
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
22-
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
23-
"BigECommerce.totalProfit": "583.59450",
24-
"BigECommerce.totalProfitForQuarter": "619.44850",
25-
},
26-
Object {
27-
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
28-
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
29-
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
30-
"BigECommerce.totalProfit": "6.41760",
31-
"BigECommerce.totalProfitForQuarter": "394.33860",
32-
},
33-
Object {
34-
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
35-
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
36-
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
37-
"BigECommerce.totalProfit": "353.68490",
38-
"BigECommerce.totalProfitForQuarter": "394.33860",
39-
},
40-
Object {
41-
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
42-
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
43-
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
44-
"BigECommerce.totalProfit": "34.23610",
45-
"BigECommerce.totalProfitForQuarter": "394.33860",
46-
},
47-
Object {
48-
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
49-
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
50-
"BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000",
51-
"BigECommerce.totalProfit": "461.13320",
52-
"BigECommerce.totalProfitForQuarter": "461.13320",
53-
},
54-
Object {
55-
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
56-
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
57-
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
58-
"BigECommerce.totalProfit": "139.99700",
59-
"BigECommerce.totalProfitForQuarter": "1576.63240",
60-
},
61-
Object {
62-
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
63-
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
64-
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
65-
"BigECommerce.totalProfit": "1132.66170",
66-
"BigECommerce.totalProfitForQuarter": "1576.63240",
67-
},
68-
Object {
69-
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
70-
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
71-
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
72-
"BigECommerce.totalProfit": "303.97370",
73-
"BigECommerce.totalProfitForQuarter": "1576.63240",
74-
},
75-
]
76-
`;
77-
783
exports[`Queries with the @cubejs-backend/snowflake-driver SQL API: Complex Rollup 1`] = `
794
Array [
805
Object {
@@ -11813,6 +11738,81 @@ Array [
1181311738
]
1181411739
`;
1181511740

11741+
exports[`Queries with the @cubejs-backend/snowflake-driver querying BigECommerce: multi-stage group by time dimension 1`] = `
11742+
Array [
11743+
Object {
11744+
"BigECommerce.orderDate": "2020-01-01T00:00:00.000",
11745+
"BigECommerce.orderDate.month": "2020-01-01T00:00:00.000",
11746+
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
11747+
"BigECommerce.totalProfit": "29.6548",
11748+
"BigECommerce.totalProfitForQuarter": "619.4485",
11749+
},
11750+
Object {
11751+
"BigECommerce.orderDate": "2020-02-01T00:00:00.000",
11752+
"BigECommerce.orderDate.month": "2020-02-01T00:00:00.000",
11753+
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
11754+
"BigECommerce.totalProfit": "6.1992",
11755+
"BigECommerce.totalProfitForQuarter": "619.4485",
11756+
},
11757+
Object {
11758+
"BigECommerce.orderDate": "2020-03-01T00:00:00.000",
11759+
"BigECommerce.orderDate.month": "2020-03-01T00:00:00.000",
11760+
"BigECommerce.orderDate.quarter": "2020-01-01T00:00:00.000",
11761+
"BigECommerce.totalProfit": "583.5945",
11762+
"BigECommerce.totalProfitForQuarter": "619.4485",
11763+
},
11764+
Object {
11765+
"BigECommerce.orderDate": "2020-04-01T00:00:00.000",
11766+
"BigECommerce.orderDate.month": "2020-04-01T00:00:00.000",
11767+
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
11768+
"BigECommerce.totalProfit": "6.4176",
11769+
"BigECommerce.totalProfitForQuarter": "394.3386",
11770+
},
11771+
Object {
11772+
"BigECommerce.orderDate": "2020-05-01T00:00:00.000",
11773+
"BigECommerce.orderDate.month": "2020-05-01T00:00:00.000",
11774+
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
11775+
"BigECommerce.totalProfit": "353.6849",
11776+
"BigECommerce.totalProfitForQuarter": "394.3386",
11777+
},
11778+
Object {
11779+
"BigECommerce.orderDate": "2020-06-01T00:00:00.000",
11780+
"BigECommerce.orderDate.month": "2020-06-01T00:00:00.000",
11781+
"BigECommerce.orderDate.quarter": "2020-04-01T00:00:00.000",
11782+
"BigECommerce.totalProfit": "34.2361",
11783+
"BigECommerce.totalProfitForQuarter": "394.3386",
11784+
},
11785+
Object {
11786+
"BigECommerce.orderDate": "2020-09-01T00:00:00.000",
11787+
"BigECommerce.orderDate.month": "2020-09-01T00:00:00.000",
11788+
"BigECommerce.orderDate.quarter": "2020-07-01T00:00:00.000",
11789+
"BigECommerce.totalProfit": "461.1332",
11790+
"BigECommerce.totalProfitForQuarter": "461.1332",
11791+
},
11792+
Object {
11793+
"BigECommerce.orderDate": "2020-10-01T00:00:00.000",
11794+
"BigECommerce.orderDate.month": "2020-10-01T00:00:00.000",
11795+
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
11796+
"BigECommerce.totalProfit": "139.9970",
11797+
"BigECommerce.totalProfitForQuarter": "1576.6324",
11798+
},
11799+
Object {
11800+
"BigECommerce.orderDate": "2020-11-01T00:00:00.000",
11801+
"BigECommerce.orderDate.month": "2020-11-01T00:00:00.000",
11802+
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
11803+
"BigECommerce.totalProfit": "1132.6617",
11804+
"BigECommerce.totalProfitForQuarter": "1576.6324",
11805+
},
11806+
Object {
11807+
"BigECommerce.orderDate": "2020-12-01T00:00:00.000",
11808+
"BigECommerce.orderDate.month": "2020-12-01T00:00:00.000",
11809+
"BigECommerce.orderDate.quarter": "2020-10-01T00:00:00.000",
11810+
"BigECommerce.totalProfit": "303.9737",
11811+
"BigECommerce.totalProfitForQuarter": "1576.6324",
11812+
},
11813+
]
11814+
`;
11815+
1181611816
exports[`Queries with the @cubejs-backend/snowflake-driver querying BigECommerce: partitioned pre-agg 1`] = `
1181711817
Array [
1181811818
Object {

rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/multi_stage_measure_calculation.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<'a> LogicalNodeProcessor<'a, MultiStageMeasureCalculation>
2626
measure_calculation: &MultiStageMeasureCalculation,
2727
context: &PushDownBuilderContext,
2828
) -> Result<Self::PhysycalNode, CubeError> {
29-
let query_tools = self.builder.query_tools();
29+
let (query_tools, templates) = self.builder.qtools_and_templates();
3030
let from = self
3131
.builder
3232
.process_node(measure_calculation.source.as_ref(), context)?;
@@ -81,7 +81,16 @@ impl<'a> LogicalNodeProcessor<'a, MultiStageMeasureCalculation>
8181
if let Some(reference) =
8282
references_builder.find_reference_for_member(&dim.full_name(), &None)
8383
{
84-
Ok(format!("{}", reference))
84+
let table_ref = if let Some(table_name) = reference.source() {
85+
format!("{}.", templates.quote_identifier(table_name)?)
86+
} else {
87+
format!("")
88+
};
89+
Ok(format!(
90+
"{}{}",
91+
table_ref,
92+
templates.quote_identifier(&reference.name())?
93+
))
8594
} else {
8695
Err(CubeError::internal(format!(
8796
"Alias not found for partition_by dimension {}",

0 commit comments

Comments
 (0)