Skip to content

Commit 98e7529

Browse files
authored
fix(cubesql): Rollup doesn't work over aliased columns (#8334)
1 parent c506040 commit 98e7529

File tree

11 files changed

+3905
-395
lines changed

11 files changed

+3905
-395
lines changed

packages/cubejs-backend-native/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
"---------------------------------------",
153153
"SQL API: Simple Rollup",
154154
"SQL API: Complex Rollup",
155-
"SQL API: Nested Rollup"
155+
"SQL API: Nested Rollup",
156+
"SQL API: Rollup with aliases",
157+
"SQL API: Rollup over exprs",
158+
"SQL API: Nested Rollup with aliases"
156159
]
157160
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
"SKIPPED SQL API (Need work)",
160160
"---------------------------------------",
161161
"SQL API: reuse params",
162-
"SQL API: Complex Rollup"
162+
"SQL API: Complex Rollup",
163+
"SQL API: Rollup with aliases"
163164
]
164165
}

packages/cubejs-testing-drivers/fixtures/databricks-jdbc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160

161161
"SKIPPED SQL API (Need work)",
162162
"---------------------------------------",
163-
"SQL API: Nested Rollup"
163+
"SQL API: Nested Rollup",
164+
"SQL API: Nested Rollup with aliases"
164165
]
165166
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
"SQL API: powerbi min max push down",
142142
"SQL API: Simple Rollup",
143143
"SQL API: Complex Rollup",
144-
"SQL API: Nested Rollup"
144+
"SQL API: Nested Rollup",
145+
"SQL API: Rollup with aliases",
146+
"SQL API: Rollup over exprs",
147+
"SQL API: Nested Rollup with aliases"
145148
]
146149
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
"SQL API: reuse params",
134134
"SQL API: Simple Rollup",
135135
"SQL API: Complex Rollup",
136-
"SQL API: Nested Rollup"
136+
"SQL API: Nested Rollup",
137+
"SQL API: Rollup with aliases",
138+
"SQL API: Rollup over exprs",
139+
"SQL API: Nested Rollup with aliases"
137140
]
138141
}

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,34 @@ from
17061706
expect(res.rows).toMatchSnapshot('complex_rollup');
17071707
});
17081708

1709+
executePg('SQL API: Rollup with aliases', async (connection) => {
1710+
const res = await connection.query(`
1711+
select
1712+
rowId as "row", orderId as "order", orderDate as "orderData", city as "city", sum(count)
1713+
from
1714+
"ECommerce" as "ECommerce"
1715+
group by
1716+
ROLLUP(rowId, 2), 3, ROLLUP(4)
1717+
order by 1, 2, 3, 4
1718+
1719+
`);
1720+
expect(res.rows).toMatchSnapshot('rollup_with_aliases');
1721+
});
1722+
1723+
executePg('SQL API: Rollup over exprs', async (connection) => {
1724+
const res = await connection.query(`
1725+
select
1726+
rowId + sales * 2 as "order", orderDate as "orderData", city as "city", sum(count)
1727+
from
1728+
"ECommerce" as "ECommerce"
1729+
group by
1730+
ROLLUP(1, 2, 3)
1731+
order by 1, 2, 3
1732+
1733+
`);
1734+
expect(res.rows).toMatchSnapshot('rollup_over_exprs');
1735+
});
1736+
17091737
executePg('SQL API: Nested Rollup', async (connection) => {
17101738
const res = await connection.query(`
17111739
select rowId, orderId, orderDate, sum(cnt)
@@ -1724,5 +1752,24 @@ from
17241752
`);
17251753
expect(res.rows).toMatchSnapshot('nested_rollup');
17261754
});
1755+
1756+
executePg('SQL API: Nested Rollup with aliases', async (connection) => {
1757+
const res = await connection.query(`
1758+
select rowId as "row", orderId as "order", orderDate as "date", sum(cnt)
1759+
from (
1760+
select
1761+
rowId, orderId, orderDate, sum(count) as cnt
1762+
from
1763+
"ECommerce" as "ECommerce"
1764+
group by 1, 2, 3
1765+
1766+
) a
1767+
group by
1768+
ROLLUP(1, 2, 3)
1769+
order by 1, 2, 3
1770+
1771+
`);
1772+
expect(res.rows).toMatchSnapshot('nested_rollup_with_aliases');
1773+
});
17271774
});
17281775
}

0 commit comments

Comments
 (0)