BigQuery - 从嵌套 table 中取消过滤器

BigQuery - Filter voided from nested table

我嵌套了 table 这样的:

BASKET-LEVEL                  PRODUCT_LEVEL             PAYMENT_LEVEL
id, gross_value,is_voided     gross_value, is_voided    amount, is_voided
                              gross_value, is_voided    amount, is_voided

我需要确保已在每个粒度级别过滤掉 is_voided = true

解决此问题的最佳方法是什么?>

SELECT BL.* FROM BASKET-LEVEL AS BL
LEFT JOIN UNNEST(PRODUCT_LEVEL) AS PROD
LEFT JOIN UNNEST(PAYMENT_LEVEL) AS PAY
WHERE BL.isVoided is false
AND PROD.isVoided is false
AND PAY.isVoided is false

您可以像这样使用 EXISTS,子选择使用 UNNEST 并寻址属性

SELECT
* 
from `table`
  WHERE NOT EXISTS 
      (
       SELECT 1 FROM UNNEST (product_level)  
       WHERE is_voided is true
      )
  AND NOT EXISTS
      (
       SELECT 1 FROM UNNEST (payment_level)  
       WHERE is_voided is true
      )