Skip to content

Commit 2808e66

Browse files
authored
chore: add nested cte to sushi for testing (#4540)
1 parent 9dbb7b8 commit 2808e66

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

examples/sushi/models/customers.sql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CREATE VIEW raw.demographics AS (
1717
SELECT 1 AS customer_id, '00000' AS zip
1818
);
1919

20-
WITH current_marketing AS (
20+
WITH current_marketing_outer AS (
2121
SELECT
2222
customer_id,
2323
status
@@ -29,7 +29,15 @@ SELECT DISTINCT
2929
m.status,
3030
d.zip
3131
FROM sushi.orders AS o
32-
LEFT JOIN current_marketing AS m
32+
LEFT JOIN (
33+
WITH current_marketing AS (
34+
SELECT
35+
customer_id,
36+
status
37+
FROM current_marketing_outer
38+
)
39+
SELECT * FROM current_marketing
40+
) AS m
3341
ON o.customer_id = m.customer_id
3442
LEFT JOIN raw.demographics AS d
3543
ON o.customer_id = d.customer_id

tests/integrations/github/cicd/test_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,8 +1695,8 @@ def test_overlapping_changes_models(
16951695
+ d.zip,
16961696
+ 1 AS new_col
16971697
FROM sushi.orders AS o
1698-
LEFT JOIN current_marketing AS m
1699-
ON o.customer_id = m.customer_id
1698+
LEFT JOIN (
1699+
WITH current_marketing AS (
17001700
```
17011701
- `sushi.waiter_names`
17021702
```diff

tests/test_forking.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_parallel_load(assert_exp_eq, mocker):
2929
assert_exp_eq(
3030
context.render("sushi.customers"),
3131
"""
32-
WITH "current_marketing" AS (
32+
WITH "current_marketing_outer" AS (
3333
SELECT
3434
"marketing"."customer_id" AS "customer_id",
3535
"marketing"."status" AS "status"
@@ -42,7 +42,18 @@ def test_parallel_load(assert_exp_eq, mocker):
4242
"m"."status" AS "status",
4343
"d"."zip" AS "zip"
4444
FROM "memory"."sushi"."orders" AS "o"
45-
LEFT JOIN "current_marketing" AS "m"
45+
LEFT JOIN (
46+
WITH "current_marketing" AS (
47+
SELECT
48+
"current_marketing_outer"."customer_id" AS "customer_id",
49+
"current_marketing_outer"."status" AS "status"
50+
FROM "current_marketing_outer" AS "current_marketing_outer"
51+
)
52+
SELECT
53+
"current_marketing"."customer_id" AS "customer_id",
54+
"current_marketing"."status" AS "status"
55+
FROM "current_marketing" AS "current_marketing"
56+
) AS "m"
4657
ON "m"."customer_id" = "o"."customer_id"
4758
LEFT JOIN "memory"."raw"."demographics" AS "d"
4859
ON "d"."customer_id" = "o"."customer_id"

tests/web/test_lineage.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_get_lineage(client: TestClient, web_sushi_context: Context) -> None:
4747
"customer_id": {
4848
"expression": 'CAST("o"."customer_id" AS INT) AS "customer_id" /* this comment should not be registered */',
4949
"models": {'"memory"."sushi"."orders"': ["customer_id"]},
50-
"source": '''WITH "current_marketing" AS (
50+
"source": '''WITH "current_marketing_outer" AS (
5151
SELECT
5252
"marketing"."customer_id" AS "customer_id",
5353
"marketing"."status" AS "status"
@@ -58,7 +58,18 @@ def test_get_lineage(client: TestClient, web_sushi_context: Context) -> None:
5858
SELECT DISTINCT
5959
CAST("o"."customer_id" AS INT) AS "customer_id" /* this comment should not be registered */
6060
FROM "memory"."sushi"."orders" AS "o"
61-
LEFT JOIN "current_marketing" AS "m"
61+
LEFT JOIN (
62+
WITH "current_marketing" AS (
63+
SELECT
64+
"current_marketing_outer"."customer_id" AS "customer_id",
65+
"current_marketing_outer"."status" AS "status"
66+
FROM "current_marketing_outer" AS "current_marketing_outer"
67+
)
68+
SELECT
69+
"current_marketing"."customer_id" AS "customer_id",
70+
"current_marketing"."status" AS "status"
71+
FROM "current_marketing" AS "current_marketing"
72+
) AS "m"
6273
ON "m"."customer_id" = "o"."customer_id"
6374
LEFT JOIN "memory"."raw"."demographics" AS "d"
6475
ON "d"."customer_id" = "o"."customer_id"''',

0 commit comments

Comments
 (0)