DataLane
← All stacks

dbt

Staging, marts, tests, and CI that does not rebuild the warehouse

10 questions with solutions

  1. Q1dbt LabsShopifyGitLab

    What belongs in staging versus a mart?

    Solution

    Staging is 1:1 with a source: rename, type, light clean. Marts are the business grain a dashboard or feature job can trust. Logic piled into staging is how projects rot. If two marts need the same join, that is an intermediate — not a copy-paste.

  2. Q2NotionFigmaHubSpot

    How do you keep CI from rebuilding the warehouse?

    Solution

    Slim CI: state:modified+ with --defer against production artifacts. Full dbt build in CI on a 400-model project is a junior tell. Also isolate CI schemas, never write to prod from a PR.

  3. Q3StripeSnowflakeDatabricks

    ref() vs source() — why does the distinction matter in an incident?

    Solution

    source() is the raw relation you do not own; ref() is a model in the project DAG. Breaking a source contract is a producer problem. Breaking a ref is your DAG. Tests on sources catch upstream silence; tests on marts catch your grain. Mixing them hides who pages whom.

  4. Q4AirbnbBooking.comExpedia

    Incremental model: merge vs delete+insert vs insert_overwrite. Pick one and defend it.

    Solution

    merge when you have a unique key and late-arriving updates. delete+insert (or insert_overwrite) for partition-sized days you can safely replace. insert_overwrite needs a reliable partition column. “incremental” without a unique key or a partition is just append — and append is how you get duplicates.

  5. Q5Capital OneBlockAffirm

    A unique test failed on fct_orders. What is your first query?

    Solution

    Select the key, count(*), min/max loaded_at grouped by the key having count > 1. Decide: source duplicate, fan-out join, or a timezone that split one order into two days. Do not --full-refresh and hope. Fix the grain, then re-run the test.

  6. Q6dbt LabsEtsyWayfair

    Snapshots versus a Type-2 dimension you build yourself.

    Solution

    dbt snapshots are a convenient Type-2 of a source when you do not control the producer. A first-class Type-2 dim you own (valid_from / valid_to, is_current) is better when facts must join “as of event time.” Do not snapshot every table “for lineage.”

  7. Q7dbt LabsGitLabHubSpot

    unit tests vs warehouse tests. What does each catch?

    Solution

    Unit tests catch macro/SQL mistakes on fixtures. Warehouse unique/not_null catch grain on real data. You need both; fixtures will not invent yesterday’s duplicate key.

  8. Q8ShopifyNotionFigma

    A model is ephemeral and 20 joins. Why is CI sad?

    Solution

    The CTE is inlined into every downstream compile. Materialize it as a view/table or split it. Ephemeral is for tiny reusable logic.

  9. Q9SnowflakeDatabricksdbt Labs

    Who owns grants after dbt build?

    Solution

    The warehouse role dbt uses must be able to GRANT. Configure grants on the model so BI is not broken every rebuild. “We click in the UI” does not survive CI.

  10. Q10dbt LabsTransformAirbnb

    Semantic Layer vs copy-pasted Looker measures.

    Solution

    One metric definition, many consumers. Four definitions of revenue is how finance pages you. dbt metrics or your metrics tool — pick one owner.

↑↓ navigate openesc close