July 7, 2010.」から引用 応用: ドリルアクロスに対応 2. dbt Semantic Layer 速習 / MetricFlow © and roots, Inc. All rights reserved. 41 Tokyo dbt Meetup #9 Metrics を 2 つ以上含むときの生成された SQL を見ると Fan Traps を起こさないように、 ドリルアクロスしていることがわかる。マルチファクトのクエリも安心して実行できる。 dbt sl query --metrics sum_revenue,sum_kitchen_revenue --group-by user_dimension__name --compile SELECT COALESCE(subq_13.user_dimension__name, subq_23.user_dimension__name) AS user_dimension__name , MAX(subq_13.sum_kitchen_revenue) AS sum_kitchen_revenue , MAX(subq_23.sum_revenue) AS sum_revenue FROM ( SELECT user_dimension__name, SUM(sum_revenue) AS sum_kitchen_revenue FROM ( SELECT product_dimension_src_10000.intermediate_category_name AS product_dimension__intermediate_category_name , user_dimension_src_10000.name AS user_dimension__name , order_fact_src_10000.item_price AS sum_revenue FROM `{{ PROJECT_ID }}`.`{{ DATASET_ID }}`.`fct_order` order_fact_src_10000 LEFT OUTER JOIN `training-bigquery-316203`.`dbt_playground`.`dim_product` product_dimension_src_10000 ON order_fact_src_10000.product_key = product_dimension_src_10000.product_key LEFT OUTER JOIN `{{ PROJECT_ID }}`.`{{ DATASET_ID }}`.`dim_user` user_dimension_src_10000 ON order_fact_src_10000.user_key = user_dimension_src_10000.user_key ) subq_9 WHERE product_dimension__intermediate_category_name = 'キッチン用品 ' GROUP BY user_dimension__name ) subq_13 FULL OUTER JOIN ( SELECT user_dimension_src_10000.name AS user_dimension__name, SUM(order_fact_src_10000.item_price) AS sum_revenue FROM `{{ PROJECT_ID }}`.`{{ DATASET_ID }}`.`fct_order` order_fact_src_10000 LEFT OUTER JOIN `{{ PROJECT_ID }}`.`{{ DATASET_ID }}`.`dim_user` user_dimension_src_10000 ON order_fact_src_10000.user_key = user_dimension_src_10000.user_key GROUP BY user_dimension__name ) subq_23 ON subq_13.user_dimension__name = subq_23.user_dimension__name GROUP BY user_dimension__name LIMIT 100 Phase 1 Phase 1 Phase 2