online_sales and store_salesonline_sales and store_salessources.yml file with source definitions for online_sales and store_sales tables under the schema raw. Use source names online and store respectively.Use the sources key and define two sources named online and store with their respective tables.
stg_online_sales.sql and stg_store_sales.sql. In each, select all columns from their respective sources using the source() function. For example, in stg_online_sales.sql, select all from source('online', 'online_sales').Use the source() function inside your SQL models to select all data from each source table.
final_sales.sql that combines stg_online_sales and stg_store_sales using UNION ALL. Select product_id and sales_amount from both staging models.Use UNION ALL to combine the two staging models. Use ref() to refer to the staging models.
final_sales.sql to aggregate total sales per product_id. Use a SELECT statement that sums sales_amount grouped by product_id from the union of both staging models.Use a subquery to combine both staging models with UNION ALL, then group by product_id and sum sales_amount.
What is the main purpose of a multi-source fan-in pattern in dbt?
Which of the following is the correct syntax to perform a full outer join in dbt's SQL model?
SELECT * FROM source_a a
FULL OUTER JOIN source_b b
ON a.id = b.idFULL OUTER JOIN with the join condition.Given the following dbt model SQL, what will be the output for final_table?
WITH source_a AS (
SELECT 1 AS id, 'A' AS val
UNION ALL
SELECT 2, 'B'
),
source_b AS (
SELECT 2 AS id, 'X' AS val
UNION ALL
SELECT 3, 'Y'
)
SELECT
COALESCE(a.id, b.id) AS id,
COALESCE(a.val, b.val) AS val
FROM source_a a
FULL OUTER JOIN source_b b ON a.id = b.id
ORDER BY id
Identify the error in this dbt model SQL that attempts a multi-source fan-in:
WITH source_a AS (
SELECT id, val FROM table_a
),
source_b AS (
SELECT id, val FROM table_b
)
SELECT
COALESCE(a.id, b.id) AS id,
COALESCE(a.val, b.val) AS val
FROM source_a a
JOIN source_b b ON a.id = b.id
You have three sources: sales_2022, sales_2023, and sales_2024. Each has columns order_id and amount. You want a unified table with all orders and amounts, preferring the latest year's amount if duplicates exist. Which approach best implements this multi-source fan-in pattern?
order_id and COALESCE with order: 2024, 2023, 2022 -> Option Aorder_id and COALESCE with order: 2024, 2023, 2022 [OK]Pass the test and this pattern moves unknown