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
517
)
518
518
519
+
self.assertEqual(
520
+
optimizer.qualify.qualify(
521
+
parse_one(
522
+
"""
523
+
SELECT
524
+
(SELECT SUM(c.amount)
525
+
FROM UNNEST(credits) AS c
526
+
WHERE type != 'promotion') as total
527
+
FROM billing
528
+
""",
529
+
read="bigquery",
530
+
),
531
+
schema={"billing": {"credits": "ARRAY<STRUCT<amount FLOAT64, type STRING>>"}},
532
+
dialect="bigquery",
533
+
).sql(dialect="bigquery"),
534
+
"SELECT (SELECT SUM(`c`.`amount`) AS `_col_0` FROM UNNEST(`billing`.`credits`) AS `c` WHERE `type` <> 'promotion') AS `total` FROM `billing` AS `billing`",
535
+
)
536
+
537
+
self.assertEqual(
538
+
optimizer.qualify.qualify(
539
+
parse_one(
540
+
"""
541
+
WITH cte AS (SELECT * FROM base_table)
542
+
SELECT
543
+
(SELECT SUM(item.price)
544
+
FROM UNNEST(items) AS item
545
+
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