You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"SELECT a.b_id AS b_id FROM a AS a JOIN b AS b ON a.b_id = b.b_id JOIN c AS c ON b.b_id = c.b_id JOIN d AS d ON b.d_id = d.d_id",
517
520
)
518
521
522
+
self.assertEqual(
523
+
optimizer.qualify.qualify(
524
+
parse_one(
525
+
"""
526
+
SELECT
527
+
(SELECT SUM(c.amount)
528
+
FROM UNNEST(credits) AS c
529
+
WHERE type != 'promotion') as total
530
+
FROM billing
531
+
""",
532
+
read="bigquery",
533
+
),
534
+
schema={"billing": {"credits": "ARRAY<STRUCT<amount FLOAT64, type STRING>>"}},
535
+
dialect="bigquery",
536
+
).sql(dialect="bigquery"),
537
+
"SELECT (SELECT SUM(`c`.`amount`) AS `_col_0` FROM UNNEST(`billing`.`credits`) AS `c` WHERE `type` <> 'promotion') AS `total` FROM `billing` AS `billing`",
538
+
)
539
+
540
+
self.assertEqual(
541
+
optimizer.qualify.qualify(
542
+
parse_one(
543
+
"""
544
+
WITH cte AS (SELECT * FROM base_table)
545
+
SELECT
546
+
(SELECT SUM(item.price)
547
+
FROM UNNEST(items) AS item
548
+
WHERE category = 'electronics') as electronics_total
"WITH `cte` AS (SELECT `base_table`.`id` AS `id`, `base_table`.`items` AS `items` FROM `base_table` AS `base_table`) SELECT (SELECT SUM(`item`.`price`) AS `_col_0` FROM UNNEST(`cte`.`items`) AS `item` WHERE `category` = 'electronics') AS `electronics_total` FROM `cte` AS `cte`",
0 commit comments