Skip to content

Commit 89b00cf

Browse files
MazterQyouKSDaemon
andauthored
fix(cubesql): Quote subquery joins alias in SQL push down to cube (#9629)
Co-authored-by: Konstantin Burkalev <KSDaemon@gmail.com>
1 parent 2b36aae commit 89b00cf

25 files changed

+195
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209
"SQL API: Nested Rollup over asterisk",
210210
"SQL API: Rollup over exprs",
211211
"SQL API: Rollup with aliases",
212-
"SQL API: Simple Rollup"
212+
"SQL API: Simple Rollup",
213+
"SQL API: SQL push down push to cube quoted alias"
213214
]
214215
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
"SQL API: Nested Rollup over asterisk",
161161
"SQL API: Extended nested Rollup over asterisk",
162162
"SQL API: ungrouped pre-agg",
163-
"SQL API: NULLS FIRST/LAST SQL push down"
163+
"SQL API: NULLS FIRST/LAST SQL push down",
164+
"SQL API: SQL push down push to cube quoted alias"
164165
]
165166
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
"SQL API: Rollup over exprs",
157157
"SQL API: Nested Rollup with aliases",
158158
"SQL API: Nested Rollup over asterisk",
159-
"SQL API: Extended nested Rollup over asterisk"
159+
"SQL API: Extended nested Rollup over asterisk",
160+
"SQL API: SQL push down push to cube quoted alias"
160161
]
161162
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@
173173
"querying BigECommerce: rolling window by 2 day without date range",
174174
"querying BigECommerce: rolling window by 2 month without date range",
175175
"querying BigECommerce: rolling window YTD",
176-
"querying BigECommerce: rolling window YTD without date range"
176+
"querying BigECommerce: rolling window YTD without date range",
177+
178+
"---------------------------------------",
179+
"SKIPPED SQL API (Need work) ",
180+
"---------------------------------------",
181+
"SQL API: SQL push down push to cube quoted alias"
177182
]
178183
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,5 +2092,31 @@ from
20922092
`);
20932093
expect(res.rows).toMatchSnapshot();
20942094
});
2095+
2096+
executePg('SQL API: SQL push down push to cube quoted alias', async (connection) => {
2097+
const res = await connection.query(`
2098+
SELECT
2099+
(NOT ("t0"."$temp1_output" IS NULL)) AS "result"
2100+
FROM
2101+
"public"."ECommerce" "ECommerce"
2102+
LEFT JOIN (
2103+
SELECT
2104+
CAST("ECommerce"."customerName" AS TEXT) AS "customerName",
2105+
1 AS "$temp1_output",
2106+
MEASURE("ECommerce"."totalQuantity") AS "$__alias__0"
2107+
FROM "public"."ECommerce" "ECommerce"
2108+
GROUP BY 1
2109+
ORDER BY
2110+
3 DESC NULLS LAST,
2111+
1 ASC NULLS FIRST
2112+
LIMIT 3
2113+
) "t0" ON (
2114+
CAST("ECommerce"."customerName" AS TEXT) IS NOT DISTINCT
2115+
FROM "t0"."customerName"
2116+
)
2117+
GROUP BY 1
2118+
`);
2119+
expect(res.rows).toMatchSnapshot();
2120+
});
20952121
});
20962122
}

packages/cubejs-testing-drivers/test/__snapshots__/athena-export-bucket-s3-full.test.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ Array [
1414
]
1515
`;
1616

17+
exports[`Queries with the @cubejs-backend/athena-driver SQL API: SQL push down push to cube quoted alias 1`] = `
18+
Array [
19+
Object {
20+
"result": true,
21+
},
22+
]
23+
`;
24+
1725
exports[`Queries with the @cubejs-backend/athena-driver SQL API: Timeshift measure from cube 1`] = `
1826
Array [
1927
Object {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,14 @@ Array [
24232423
]
24242424
`;
24252425

2426+
exports[`Queries with the @cubejs-backend/bigquery-driver SQL API: SQL push down push to cube quoted alias 1`] = `
2427+
Array [
2428+
Object {
2429+
"result": true,
2430+
},
2431+
]
2432+
`;
2433+
24262434
exports[`Queries with the @cubejs-backend/bigquery-driver SQL API: Simple Rollup: simple_rollup 1`] = `
24272435
Array [
24282436
Object {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,6 +5214,14 @@ Array [
52145214
]
52155215
`;
52165216

5217+
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure SQL API: SQL push down push to cube quoted alias 1`] = `
5218+
Array [
5219+
Object {
5220+
"result": true,
5221+
},
5222+
]
5223+
`;
5224+
52175225
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure SQL API: Simple Rollup: simple_rollup 1`] = `
52185226
Array [
52195227
Object {

packages/cubejs-testing-drivers/test/__snapshots__/databricks-jdbc-export-bucket-azure-prefix-full.test.ts.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,6 +5214,14 @@ Array [
52145214
]
52155215
`;
52165216

5217+
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure-prefix SQL API: SQL push down push to cube quoted alias 1`] = `
5218+
Array [
5219+
Object {
5220+
"result": true,
5221+
},
5222+
]
5223+
`;
5224+
52175225
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-azure-prefix SQL API: Simple Rollup: simple_rollup 1`] = `
52185226
Array [
52195227
Object {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,6 +5214,14 @@ Array [
52145214
]
52155215
`;
52165216

5217+
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-gcs SQL API: SQL push down push to cube quoted alias 1`] = `
5218+
Array [
5219+
Object {
5220+
"result": true,
5221+
},
5222+
]
5223+
`;
5224+
52175225
exports[`Queries with the @cubejs-backend/databricks-jdbc-driver export-bucket-gcs SQL API: Simple Rollup: simple_rollup 1`] = `
52185226
Array [
52195227
Object {

0 commit comments

Comments
 (0)