Skip to main content
InterviewHubPRO
Section Overview
Q48

Question 48 of 50

Part 3: Enterprise Scale, Performance & CI/CD Pipelines (Senior / Staff)

96%
dbt Analytics Engineering (50 Qs)•Part 3: Enterprise Scale, Performance & CI/CD Pipelines (Senior / Staff)

Working with Complex JSON Payloads in dbt: Macro patterns for cross-warehouse unnesting.

senior LevelMost AskedCode ExampleFormsPerformancePipes

In Simple Words: Unnesting JSON arrays differs drastically across warehouses (Snowflake uses FLATTEN(), BigQuery uses CROSS JOIN UNNEST(), Postgres uses json_array_elements()).

  • Cross-Database Macros: Write adapter-aware macros using adapter.dispatch so your model code remains clean and portable:
    sql
    SELECT
      order_id,
      {{ unnest_json_array('items', 'item_id') }}
    FROM {{ ref('stg_orders') }}