Skip to content

Commit

Permalink
test: Add COALESCE + IS NOT NULL join pushdown smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Jan 31, 2025
1 parent da2c747 commit db43682
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ Array [
]
`;

exports[`SQL API Postgres (Data) join with grouped query on coalesce: join grouped on coalesce 1`] = `
Array [
Object {
"count": "2",
"status": "processed",
},
Object {
"count": "1",
"status": "shipped",
},
]
`;

exports[`SQL API Postgres (Data) join with grouped query: join grouped 1`] = `
Array [
Object {
Expand Down
30 changes: 30 additions & 0 deletions packages/cubejs-testing/test/smoke-cubesql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,36 @@ filter_subq AS (
expect(res.rows).toMatchSnapshot('join grouped with filter');
});

test('join with grouped query on coalesce', async () => {
const query = `
SELECT
"Orders".status AS status,
COUNT(*) AS count
FROM
"Orders"
INNER JOIN
(
SELECT
status,
SUM(totalAmount)
FROM
"Orders"
GROUP BY 1
ORDER BY 2 DESC
LIMIT 2
) top_orders
ON
(COALESCE("Orders".status, '') = COALESCE(top_orders.status, '')) AND
(("Orders".status IS NOT NULL) = (top_orders.status IS NOT NULL))
GROUP BY 1
ORDER BY 1
`;

const res = await connection.query(query);
// Expect only top statuses 2 by total amount: processed and shipped
expect(res.rows).toMatchSnapshot('join grouped on coalesce');
});

test('where segment is false', async () => {
const query =
'SELECT value AS val, * FROM "SegmentTest" WHERE segment_eq_1 IS FALSE ORDER BY value;';
Expand Down

0 comments on commit db43682

Please sign in to comment.