[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-dbt-labs-adding-dbt-unit-test":3,"mdc--ryw7y9-key":32,"related-org-dbt-labs-adding-dbt-unit-test":3768,"related-repo-dbt-labs-adding-dbt-unit-test":3928},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":21,"repoUrl":22,"updatedAt":23,"license":24,"forks":25,"topics":26,"repo":27,"sourceUrl":30,"mdContent":31},"adding-dbt-unit-test","add dbt unit tests","Creates unit test YAML definitions that mock upstream model inputs and validate expected outputs. Use when adding unit tests for a dbt model or practicing test-driven development (TDD) in dbt.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"dbt-labs","dbt Labs","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fdbt-labs.png",[12,16,18],{"name":13,"slug":14,"type":15},"YAML","yaml","tag",{"name":17,"slug":17,"type":15},"dbt",{"name":19,"slug":20,"type":15},"Testing","testing",623,"https:\u002F\u002Fgithub.com\u002Fdbt-labs\u002Fdbt-agent-skills","2026-04-06T18:09:14.01391",null,52,[],{"repoUrl":22,"stars":21,"forks":25,"topics":28,"description":29},[],"A curated collection of Agent Skills for working with dbt, to help AI agents understand and execute dbt workflows more effectively.","https:\u002F\u002Fgithub.com\u002Fdbt-labs\u002Fdbt-agent-skills\u002Ftree\u002FHEAD\u002Fskills\u002Fdbt\u002Fskills\u002Fadding-dbt-unit-test","---\nname: adding-dbt-unit-test\ndescription: Creates unit test YAML definitions that mock upstream model inputs and validate expected outputs. Use when adding unit tests for a dbt model or practicing test-driven development (TDD) in dbt.\nuser-invocable: false\nmetadata:\n  author: dbt-labs\n---\n\n# Add unit test for a dbt model\n\n## Additional Resources\n\n- [Spec Reference](references\u002Fspec.md) - All required and optional YAML keys for unit tests\n- [Examples](references\u002Fexamples.md) - Unit test examples across formats (dict, csv, sql)\n- [Incremental Models](references\u002Fspecial-cases-incremental-model.md) - Unit testing incremental models\n- [Ephemeral Dependencies](references\u002Fspecial-cases-ephemeral-dependency.md) - Unit testing models depending on ephemeral models\n- [Special Case Overrides](references\u002Fspecial-cases-special-case-overrides.md) - Introspective macros, project variables, environment variables\n- [Versioned Models](references\u002Fspecial-cases-versioned-model.md) - Unit testing versioned SQL models\n- [BigQuery Caveats](references\u002Fwarehouse-bigquery-caveats.md) - BigQuery-specific caveats\n- [BigQuery Data Types](references\u002Fwarehouse-bigquery-data-types.md) - BigQuery data type handling\n- [Postgres Data Types](references\u002Fwarehouse-postgres-data-types.md) - Postgres data type handling\n- [Redshift Caveats](references\u002Fwarehouse-redshift-caveats.md) - Redshift-specific caveats\n- [Redshift Data Types](references\u002Fwarehouse-redshift-data-types.md) - Redshift data type handling\n- [Snowflake Data Types](references\u002Fwarehouse-snowflake-data-types.md) - Snowflake data type handling\n- [Spark Data Types](references\u002Fwarehouse-spark-data-types.md) - Spark data type handling\n\n## What are unit tests in dbt\n\ndbt unit tests validate SQL modeling logic on static inputs before materializing in production. If any unit test for a model fails, dbt will not materialize that model.\n\n## When to use\n\nYou should unit test a model:\n- Adding Model-Input-Output scenarios for the intended functionality of the model as well as edge cases to prevent regressions if the model logic is changed at a later date.\n- Verifying that a bug fix solves a bug report for an existing dbt model.\n\nMore examples:\n- When your SQL contains complex logic:\n    - Regex\n    - Date math\n    - Window functions\n    - `case when` statements when there are many `when`s\n    - Truncation\n    - Complex joins (multiple joins, self-joins, or joins with non-trivial conditions)\n- When you're writing custom logic to process input data, similar to creating a function.\n- Logic for which you had bugs reported before.\n- Edge cases not yet seen in your actual data that you want to be confident you are handling properly.\n- Prior to refactoring the transformation logic (especially if the refactor is significant).\n- Models with high \"criticality\" (public, contracted models or models directly upstream of an exposure).\n\n## When not to use\n\nCases we don't recommend creating unit tests for:\n- Built-in functions that are tested extensively by the warehouse provider. If an unexpected issue arises, it's more likely a result of issues in the underlying data rather than the function itself. Therefore, fixture data in the unit test won't provide valuable information.\n    - common SQL spec functions like `min()`, etc.\n\n## General format\n\ndbt unit test uses a trio of the model, given inputs, and expected outputs (Model-Inputs-Outputs):\n\n1. `model` - when building this model\n2. `given` inputs - given a set of source, seeds, and models as preconditions\n3. `expect` output - then expect this row content of the model as a postcondition\n\n### Workflow\n\n### 1. Choose the model to test\n\nSelf explanatory -- the title says it all!\n\n### 2. Mock the inputs\n\n- Create an input for each of the nodes the model depends on.\n- Specify the mock data it should use.\n- Specify the `format` if different than the default (YAML `dict`).\n  - See the \"Data `format`s for unit tests\" section below to determine which `format` to use.\n- The mock data only needs include the subset of columns used within this test case.\n\n**Tip:** Use `dbt show` to explore existing data from upstream models or sources. This helps you understand realistic input structures. However, always sanitize the sample data to remove any sensitive or PII information before using it in your unit test fixtures.\n\n```shell\n# Preview upstream model data\ndbt show --select upstream_model --limit 5\n```\n\n### 3. Mock the output\n\n- Specify the data that you expect the model to create given those inputs.\n- Specify the `format` if different than the default (YAML `dict`).\n  - See the \"Data `format`s for unit tests\" section below to determine which `format` to use.\n- The mock data only needs include the subset of columns used within this test case.\n\n### 4. Ensure upstream models exist before running\n\n**Unit tests require direct parent models to exist in the warehouse.** Before running unit tests standalone (`dbt test`), verify that upstream models already exist first:\n\n```bash\n# Check if upstream models exist in the warehouse\ndbt list --select +my_model --exclude my_model --resource-type model\n# Then verify the tables\u002Fviews actually exist in the warehouse via dbt show or your SQL client\ndbt show --select upstream_model --limit 1\n```\n\nIf upstream models **do not exist**, or **exist but have been modified and not yet refreshed**, build them using `--empty` to create schema-only versions:\n\n```bash\n# Build upstream models cheaply (schema only, no data read)\ndbt run --select +my_model --exclude my_model --empty\n```\n\n> **Warning:** `--empty` overwrites existing models with schema-only (zero-row) versions. Only use it when models don't exist yet, or when schema changes need to be applied. Do not use it if upstream models contain data you want to preserve — it will wipe that data.\n\nSkip this step if using `dbt build --select my_model` (recommended) — it handles the full pipeline including unit tests.\n\n## Minimal unit test\n\nSuppose you have this model:\n\n```sql\n-- models\u002Fhello_world.sql\n\nselect 'world' as hello\n```\n\nMinimal unit test for that model:\n\n```yaml\n# models\u002F_properties.yml\n\nunit_tests:\n  - name: test_hello_world\n\n    # Always only one transformation to test\n    model: hello_world\n\n    # No inputs needed this time!\n    # Most unit tests will have inputs -- see the \"real world example\" section below\n    given: []\n\n    # Expected output can have zero to many rows\n    expect:\n      rows:\n        - {hello: world}\n```\n\n## Executing unit tests\n\nRun the unit tests, build the model, and run the data tests for the `hello_world` model:\n\n```shell\ndbt build --select hello_world\n```\n\nThis saves on warehouse spend as the model will only be materialized and move on to the data tests if the unit tests pass successfully.\n\nOr only run the unit tests without building the model or running the data tests:\n\n```shell\ndbt test --select \"hello_world,test_type:unit\"\n```\n\nOr choose a specific unit test by name:\n\n```shell\ndbt test --select test_is_valid_email_address\n```\n\n### Excluding unit tests from production builds\n\ndbt Labs strongly recommends only running unit tests in development or CI environments. Since the inputs of the unit tests are static, there's no need to use additional compute cycles running them in production. Use them when doing development for a test-driven approach and CI to ensure changes don't break them.\n\nUse the `--resource-type` flag `--exclude-resource-type` or the `DBT_EXCLUDE_RESOURCE_TYPES` environment variable to exclude unit tests from your production builds and save compute. \n\n## More realistic example\n\n```yaml\nunit_tests:\n\n  - name: test_order_items_count_drink_items_with_zero_drinks\n    description: >\n      Scenario: Order without any drinks\n        When the `order_items_summary` table is built\n        Given an order with nothing but 1 food item\n        Then the count of drink items is 0\n\n    # Model\n    model: order_items_summary\n\n    # Inputs\n    given:\n      - input: ref('order_items')\n        rows:\n          - {\n              order_id: 76,\n              order_item_id: 3,\n              is_drink_item: false,\n            }\n      - input: ref('stg_orders')\n        rows:\n          - { order_id: 76 }\n\n    # Output\n    expect:\n      rows:\n        - {\n            order_id: 76,\n            count_drink_items: 0,\n          }\n```\n\nFor more examples of unit tests, see [references\u002Fexamples.md](references\u002Fexamples.md)\n\n## Supported and unsupported scenarios\n\n- dbt only supports unit testing SQL models.\n    - Unit testing Python models is not supported.\n    - Unit testing non-model nodes like snapshots, seeds, sources, analyses, etc. is not supported.\n- dbt only supports adding unit tests to models in your _current_ project.\n    - Unit testing cross-project models or models imported from a package is not supported.\n- dbt _does not_ support unit testing models that use the `materialized view` materialization.\n- dbt _does not_ support unit testing models that use recursive SQL.\n- dbt _does not_ support unit testing models that use introspective queries.\n- dbt _does not_ support an `expect` output for final state of the database table after inserting\u002Fmerging for incremental models.\n- dbt _does_ support an `expect` output for what will be merged\u002Finserted for incremental models.\n\n## Handy to know\n\n- Unit tests must be defined in a YAML file in your `model-paths` directory (`models\u002F` by default)\n- Fixture files for unit tests must be defined in a SQL or CSV file in your `test-paths` directory (`tests\u002Ffixtures` by default)\n- Include all `ref` or `source` model references in the unit test configuration as `input`s to avoid \"node not found\" errors during compilation.\n- If your model has multiple versions, by default the unit test will run on *all* versions of your model.\n- If you want to unit test a model that depends on an ephemeral model, you must use `format: sql` for the ephemeral model input.\n- Table names within the model must be aliased in order to unit test `join` logic\n\n## YAML for specifying unit tests\n\n- For all the required and optional keys in the YAML definition of unit tests, see [references\u002Fspec.md](references\u002Fspec.md)\n\n# Inputs for unit tests\n\nUse `input`s in your unit tests to reference a specific model or source for the test:\n\n-  For `input:`, use a string that represents a `ref` or `source` call:\n    - `ref('my_model')` or `ref('my_model', v='2')` or `ref('dougs_project', 'users')`\n    - `source('source_schema', 'source_name')`\n- For seed inputs:\n    - If you do not supply an input for a seed, we will use the seed's CSV file _as_ the input.\n    - If you do supply an input for a seed, we will use that input instead.\n- Use “empty” inputs by setting rows to an empty list `rows: []`\n    - This is useful if the model has a `ref` or `source` dependency, but its values are irrelevant to this particular unit test. Just beware if the model has a join on that input that would cause rows to drop out!\n\n`models\u002Fschema.yml`\n\n```yaml\nunit_tests:\n  - name: test_is_valid_email_address  # this is the unique name of the test\n    model: dim_customers  # name of the model I'm unit testing\n    given:  # the mock data for your inputs\n      - input: ref('stg_customers')\n        rows:\n         - {email: cool@example.com,     email_top_level_domain: example.com}\n         - {email: cool@unknown.com,     email_top_level_domain: unknown.com}\n         - {email: badgmail.com,         email_top_level_domain: gmail.com}\n         - {email: missingdot@gmailcom,  email_top_level_domain: gmail.com}\n      - input: ref('top_level_email_domains')\n        rows:\n         - {tld: example.com}\n         - {tld: gmail.com}\n      - input: ref('irrelevant_dependency')  # dependency that we need to acknowlege, but does not need any data\n        rows: []\n...\n\n```\n\n# Data `format`s for unit tests\n\n## **`dict` is the default format** — always start here\n\nUnless you have a specific reason to use another format, use `dict` (inline YAML). It is the default when `format:` is omitted.\n\n```yaml\ngiven:\n  - input: ref('orders')\n    # no format: key needed — dict is the default\n    rows:\n      - {order_id: 1, status: completed, amount: 100}\n      - {order_id: 2, status: pending, amount: 50}\n```\n\n## How to choose the `format`\n\n| Use `dict` (default) | Use `sql` | Use `csv` |\n|---------------------|-----------|-----------|\n| Everything else — this is the starting point | Model depends on an **ephemeral** model | Using an external fixture file |\n| | Column data type not supported by dict\u002Fcsv | Column data type not supported by dict |\n| | External fixture file with unsupported types | |\n\n**Critical `sql` note**: `sql` format requires specifying **ALL columns** in the mock data. `dict` and `csv` only require the columns relevant to the test — much more concise.\n\n**Critical `sql` requirement**: If any of your model's `ref()` or `source()` inputs are ephemeral models, you **must** use `sql` format for those inputs. `dict` and `csv` will fail.\n\ndbt supports three formats for mock data within unit tests:\n\n1. `dict` (default): Inline YAML dictionary values.\n2. `csv`: Inline CSV values or a CSV file.\n3. `sql`: Inline SQL query or a SQL file.\n\nTo see examples of each of the formats, see [references\u002Fexamples.md](references\u002Fexamples.md)\n\nNotes:\n- For the `sql` format you must supply mock data for _all columns_ whereas `dict` and `csv` may supply only a subset.\n- Only the `sql` format allows you to unit test a model that depends on an ephemeral model -- `dict` and `csv` can't be used in that case.\n- There are no formats that support Jinja.\n\n### Fixture files\n\nThe `dict` format only supports inline YAML mock data, but you can also use `csv` or `sql` either inline or in a separate fixture file. Store your fixture files in a `fixtures` subdirectory in any of your `test-paths`. For example, `tests\u002Ffixtures\u002Fmy_unit_test_fixture.sql`.\n\nWhen using the `dict` or `csv` format, you only have to define the mock data for the columns relevant to you. This enables you to write succinct and _specific_ unit tests. For the `sql` format _all_ columns need to be defined.\n\n## Special cases\n\n- Unit testing incremental models. See [references\u002Fspecial-cases-incremental-model.md](references\u002Fspecial-cases-incremental-model.md).\n- Unit testing a model that depends on ephemeral model(s). See [references\u002Fspecial-cases-ephemeral-dependency.md](references\u002Fspecial-cases-ephemeral-dependency.md).\n- Unit test a model that depends on any introspective macros, project variables, or environment variables. See [references\u002Fspecial-cases-special-case-overrides.md](references\u002Fspecial-cases-special-case-overrides.md).\n- Unit testing versioned SQL models. See [references\u002Fspecial-cases-versioned-model.md](references\u002Fspecial-cases-versioned-model.md).\n\n### Platform\u002Fadapter-specific caveats\n\nThere are platform-specific details required if implementing on (Redshift, BigQuery, etc). Read the caveats file for your database (if it exists):\n\n- [references\u002Fwarehouse-bigquery-caveats.md](references\u002Fwarehouse-bigquery-caveats.md)\n- [references\u002Fwarehouse-redshift-caveats.md](references\u002Fwarehouse-redshift-caveats.md)\n\n# Platform\u002Fadapter-specific data types\n\nUnit tests are designed to test for the expected _values_, not for the data types themselves. dbt takes the value you provide and attempts to cast it to the data type as inferred from the input and output models.\n\nHow you specify input and expected values in your unit test YAML definitions are largely consistent across data warehouses, with some variation for more complex data types.\n\nRead the data types file for your database:\n\n- [references\u002Fwarehouse-bigquery-data-types.md](references\u002Fwarehouse-bigquery-data-types.md)\n- [references\u002Fwarehouse-postgres-data-types.md](references\u002Fwarehouse-postgres-data-types.md)\n- [references\u002Fwarehouse-redshift-data-types.md](references\u002Fwarehouse-redshift-data-types.md)\n- [references\u002Fwarehouse-snowflake-data-types.md](references\u002Fwarehouse-snowflake-data-types.md)\n- [references\u002Fwarehouse-spark-data-types.md](references\u002Fwarehouse-spark-data-types.md)\n\n# Disabling a unit test\n\nBy default, all specified unit tests are enabled and will be included according to the `--select` flag.\n\nTo disable a unit test from being executed, set:\n```yaml\n    config: \n      enabled: false\n```\n\nThis is helpful if a unit test is incorrectly failing and it needs to be disabled until it is fixed.\n\n### When a unit test fails \n\nWhen a unit test fails, there will be a log message of \"actual differs from expected\", and it will show a \"data diff\" between the two:\n\n```\nactual differs from expected:\n\n@@ ,email           ,is_valid_email_address\n→  ,cool@example.com,True→False\n   ,cool@unknown.com,False\n```\n\nThere are two main possibilities when a unit test fails:\n\n1. There was an error in the way the unit test was constructed (false positive)\n2. There is an bug is the model (true positive)\n\nIt takes expert judgement to determine one from the other.\n\n### The `--empty` flag\n\nThe direct parents of the model that you’re unit testing need to exist in the warehouse before you can execute the unit test. The `run` and `build` commands supports the `--empty` flag for building schema-only dry runs. The `--empty` flag limits the `ref`s and `sources` to zero rows. dbt will still execute the model SQL against the target data warehouse but will avoid expensive reads of input data. This validates dependencies and ensures your models will build properly.\n\nUse the `--empty` flag to build an empty version of the models to save warehouse spend. \n\n```bash\n\ndbt run --select \"stg_customers top_level_email_domains\" --empty\n\n```\n\n## Common Mistakes\n\n| Mistake | Fix |\n|---------|-----|\n| Testing simple SQL using built-in functions | Only unit test complex logic: regex, date math, window functions, multi-condition case statements |\n| Mocking all columns in input data | Only include columns relevant to the test case |\n| Using `sql` format when `dict` works | Prefer `dict` (most readable), fall back to `csv` or `sql` only when needed |\n| Missing `input` for a `ref` or `source` | Include all model dependencies to avoid \"node not found\" errors |\n| Testing Python models or snapshots | Unit tests only support SQL models |\n\n",{"data":33,"body":36},{"name":4,"description":6,"user-invocable":34,"metadata":35},false,{"author":8},{"type":37,"children":38},"root",[39,48,55,204,210,216,222,227,240,245,326,332,337,361,367,372,409,416,422,427,433,494,513,572,578,625,631,649,745,772,820,841,854,860,865,899,904,1120,1126,1139,1166,1171,1176,1214,1219,1246,1252,1257,1286,1292,1737,1746,1752,1868,1874,1984,1990,2002,2008,2020,2141,2150,2580,2593,2609,2629,2814,2825,2928,2973,3031,3036,3069,3078,3083,3148,3154,3202,3240,3246,3289,3295,3300,3317,3323,3335,3340,3345,3383,3389,3402,3407,3449,3454,3460,3465,3475,3480,3493,3498,3510,3559,3570,3617,3623,3762],{"type":40,"tag":41,"props":42,"children":44},"element","h1",{"id":43},"add-unit-test-for-a-dbt-model",[45],{"type":46,"value":47},"text","Add unit test for a dbt model",{"type":40,"tag":49,"props":50,"children":52},"h2",{"id":51},"additional-resources",[53],{"type":46,"value":54},"Additional Resources",{"type":40,"tag":56,"props":57,"children":58},"ul",{},[59,72,83,94,105,116,127,138,149,160,171,182,193],{"type":40,"tag":60,"props":61,"children":62},"li",{},[63,70],{"type":40,"tag":64,"props":65,"children":67},"a",{"href":66},"references\u002Fspec.md",[68],{"type":46,"value":69},"Spec Reference",{"type":46,"value":71}," - All required and optional YAML keys for unit tests",{"type":40,"tag":60,"props":73,"children":74},{},[75,81],{"type":40,"tag":64,"props":76,"children":78},{"href":77},"references\u002Fexamples.md",[79],{"type":46,"value":80},"Examples",{"type":46,"value":82}," - Unit test examples across formats (dict, csv, sql)",{"type":40,"tag":60,"props":84,"children":85},{},[86,92],{"type":40,"tag":64,"props":87,"children":89},{"href":88},"references\u002Fspecial-cases-incremental-model.md",[90],{"type":46,"value":91},"Incremental Models",{"type":46,"value":93}," - Unit testing incremental models",{"type":40,"tag":60,"props":95,"children":96},{},[97,103],{"type":40,"tag":64,"props":98,"children":100},{"href":99},"references\u002Fspecial-cases-ephemeral-dependency.md",[101],{"type":46,"value":102},"Ephemeral Dependencies",{"type":46,"value":104}," - Unit testing models depending on ephemeral models",{"type":40,"tag":60,"props":106,"children":107},{},[108,114],{"type":40,"tag":64,"props":109,"children":111},{"href":110},"references\u002Fspecial-cases-special-case-overrides.md",[112],{"type":46,"value":113},"Special Case Overrides",{"type":46,"value":115}," - Introspective macros, project variables, environment variables",{"type":40,"tag":60,"props":117,"children":118},{},[119,125],{"type":40,"tag":64,"props":120,"children":122},{"href":121},"references\u002Fspecial-cases-versioned-model.md",[123],{"type":46,"value":124},"Versioned Models",{"type":46,"value":126}," - Unit testing versioned SQL models",{"type":40,"tag":60,"props":128,"children":129},{},[130,136],{"type":40,"tag":64,"props":131,"children":133},{"href":132},"references\u002Fwarehouse-bigquery-caveats.md",[134],{"type":46,"value":135},"BigQuery Caveats",{"type":46,"value":137}," - BigQuery-specific caveats",{"type":40,"tag":60,"props":139,"children":140},{},[141,147],{"type":40,"tag":64,"props":142,"children":144},{"href":143},"references\u002Fwarehouse-bigquery-data-types.md",[145],{"type":46,"value":146},"BigQuery Data Types",{"type":46,"value":148}," - BigQuery data type handling",{"type":40,"tag":60,"props":150,"children":151},{},[152,158],{"type":40,"tag":64,"props":153,"children":155},{"href":154},"references\u002Fwarehouse-postgres-data-types.md",[156],{"type":46,"value":157},"Postgres Data Types",{"type":46,"value":159}," - Postgres data type handling",{"type":40,"tag":60,"props":161,"children":162},{},[163,169],{"type":40,"tag":64,"props":164,"children":166},{"href":165},"references\u002Fwarehouse-redshift-caveats.md",[167],{"type":46,"value":168},"Redshift Caveats",{"type":46,"value":170}," - Redshift-specific caveats",{"type":40,"tag":60,"props":172,"children":173},{},[174,180],{"type":40,"tag":64,"props":175,"children":177},{"href":176},"references\u002Fwarehouse-redshift-data-types.md",[178],{"type":46,"value":179},"Redshift Data Types",{"type":46,"value":181}," - Redshift data type handling",{"type":40,"tag":60,"props":183,"children":184},{},[185,191],{"type":40,"tag":64,"props":186,"children":188},{"href":187},"references\u002Fwarehouse-snowflake-data-types.md",[189],{"type":46,"value":190},"Snowflake Data Types",{"type":46,"value":192}," - Snowflake data type handling",{"type":40,"tag":60,"props":194,"children":195},{},[196,202],{"type":40,"tag":64,"props":197,"children":199},{"href":198},"references\u002Fwarehouse-spark-data-types.md",[200],{"type":46,"value":201},"Spark Data Types",{"type":46,"value":203}," - Spark data type handling",{"type":40,"tag":49,"props":205,"children":207},{"id":206},"what-are-unit-tests-in-dbt",[208],{"type":46,"value":209},"What are unit tests in dbt",{"type":40,"tag":211,"props":212,"children":213},"p",{},[214],{"type":46,"value":215},"dbt unit tests validate SQL modeling logic on static inputs before materializing in production. If any unit test for a model fails, dbt will not materialize that model.",{"type":40,"tag":49,"props":217,"children":219},{"id":218},"when-to-use",[220],{"type":46,"value":221},"When to use",{"type":40,"tag":211,"props":223,"children":224},{},[225],{"type":46,"value":226},"You should unit test a model:",{"type":40,"tag":56,"props":228,"children":229},{},[230,235],{"type":40,"tag":60,"props":231,"children":232},{},[233],{"type":46,"value":234},"Adding Model-Input-Output scenarios for the intended functionality of the model as well as edge cases to prevent regressions if the model logic is changed at a later date.",{"type":40,"tag":60,"props":236,"children":237},{},[238],{"type":46,"value":239},"Verifying that a bug fix solves a bug report for an existing dbt model.",{"type":40,"tag":211,"props":241,"children":242},{},[243],{"type":46,"value":244},"More examples:",{"type":40,"tag":56,"props":246,"children":247},{},[248,301,306,311,316,321],{"type":40,"tag":60,"props":249,"children":250},{},[251,253],{"type":46,"value":252},"When your SQL contains complex logic:\n",{"type":40,"tag":56,"props":254,"children":255},{},[256,261,266,271,291,296],{"type":40,"tag":60,"props":257,"children":258},{},[259],{"type":46,"value":260},"Regex",{"type":40,"tag":60,"props":262,"children":263},{},[264],{"type":46,"value":265},"Date math",{"type":40,"tag":60,"props":267,"children":268},{},[269],{"type":46,"value":270},"Window functions",{"type":40,"tag":60,"props":272,"children":273},{},[274,281,283,289],{"type":40,"tag":275,"props":276,"children":278},"code",{"className":277},[],[279],{"type":46,"value":280},"case when",{"type":46,"value":282}," statements when there are many ",{"type":40,"tag":275,"props":284,"children":286},{"className":285},[],[287],{"type":46,"value":288},"when",{"type":46,"value":290},"s",{"type":40,"tag":60,"props":292,"children":293},{},[294],{"type":46,"value":295},"Truncation",{"type":40,"tag":60,"props":297,"children":298},{},[299],{"type":46,"value":300},"Complex joins (multiple joins, self-joins, or joins with non-trivial conditions)",{"type":40,"tag":60,"props":302,"children":303},{},[304],{"type":46,"value":305},"When you're writing custom logic to process input data, similar to creating a function.",{"type":40,"tag":60,"props":307,"children":308},{},[309],{"type":46,"value":310},"Logic for which you had bugs reported before.",{"type":40,"tag":60,"props":312,"children":313},{},[314],{"type":46,"value":315},"Edge cases not yet seen in your actual data that you want to be confident you are handling properly.",{"type":40,"tag":60,"props":317,"children":318},{},[319],{"type":46,"value":320},"Prior to refactoring the transformation logic (especially if the refactor is significant).",{"type":40,"tag":60,"props":322,"children":323},{},[324],{"type":46,"value":325},"Models with high \"criticality\" (public, contracted models or models directly upstream of an exposure).",{"type":40,"tag":49,"props":327,"children":329},{"id":328},"when-not-to-use",[330],{"type":46,"value":331},"When not to use",{"type":40,"tag":211,"props":333,"children":334},{},[335],{"type":46,"value":336},"Cases we don't recommend creating unit tests for:",{"type":40,"tag":56,"props":338,"children":339},{},[340],{"type":40,"tag":60,"props":341,"children":342},{},[343,345],{"type":46,"value":344},"Built-in functions that are tested extensively by the warehouse provider. If an unexpected issue arises, it's more likely a result of issues in the underlying data rather than the function itself. Therefore, fixture data in the unit test won't provide valuable information.\n",{"type":40,"tag":56,"props":346,"children":347},{},[348],{"type":40,"tag":60,"props":349,"children":350},{},[351,353,359],{"type":46,"value":352},"common SQL spec functions like ",{"type":40,"tag":275,"props":354,"children":356},{"className":355},[],[357],{"type":46,"value":358},"min()",{"type":46,"value":360},", etc.",{"type":40,"tag":49,"props":362,"children":364},{"id":363},"general-format",[365],{"type":46,"value":366},"General format",{"type":40,"tag":211,"props":368,"children":369},{},[370],{"type":46,"value":371},"dbt unit test uses a trio of the model, given inputs, and expected outputs (Model-Inputs-Outputs):",{"type":40,"tag":373,"props":374,"children":375},"ol",{},[376,387,398],{"type":40,"tag":60,"props":377,"children":378},{},[379,385],{"type":40,"tag":275,"props":380,"children":382},{"className":381},[],[383],{"type":46,"value":384},"model",{"type":46,"value":386}," - when building this model",{"type":40,"tag":60,"props":388,"children":389},{},[390,396],{"type":40,"tag":275,"props":391,"children":393},{"className":392},[],[394],{"type":46,"value":395},"given",{"type":46,"value":397}," inputs - given a set of source, seeds, and models as preconditions",{"type":40,"tag":60,"props":399,"children":400},{},[401,407],{"type":40,"tag":275,"props":402,"children":404},{"className":403},[],[405],{"type":46,"value":406},"expect",{"type":46,"value":408}," output - then expect this row content of the model as a postcondition",{"type":40,"tag":410,"props":411,"children":413},"h3",{"id":412},"workflow",[414],{"type":46,"value":415},"Workflow",{"type":40,"tag":410,"props":417,"children":419},{"id":418},"_1-choose-the-model-to-test",[420],{"type":46,"value":421},"1. Choose the model to test",{"type":40,"tag":211,"props":423,"children":424},{},[425],{"type":46,"value":426},"Self explanatory -- the title says it all!",{"type":40,"tag":410,"props":428,"children":430},{"id":429},"_2-mock-the-inputs",[431],{"type":46,"value":432},"2. Mock the inputs",{"type":40,"tag":56,"props":434,"children":435},{},[436,441,446,489],{"type":40,"tag":60,"props":437,"children":438},{},[439],{"type":46,"value":440},"Create an input for each of the nodes the model depends on.",{"type":40,"tag":60,"props":442,"children":443},{},[444],{"type":46,"value":445},"Specify the mock data it should use.",{"type":40,"tag":60,"props":447,"children":448},{},[449,451,457,459,465,467],{"type":46,"value":450},"Specify the ",{"type":40,"tag":275,"props":452,"children":454},{"className":453},[],[455],{"type":46,"value":456},"format",{"type":46,"value":458}," if different than the default (YAML ",{"type":40,"tag":275,"props":460,"children":462},{"className":461},[],[463],{"type":46,"value":464},"dict",{"type":46,"value":466},").\n",{"type":40,"tag":56,"props":468,"children":469},{},[470],{"type":40,"tag":60,"props":471,"children":472},{},[473,475,480,482,487],{"type":46,"value":474},"See the \"Data ",{"type":40,"tag":275,"props":476,"children":478},{"className":477},[],[479],{"type":46,"value":456},{"type":46,"value":481},"s for unit tests\" section below to determine which ",{"type":40,"tag":275,"props":483,"children":485},{"className":484},[],[486],{"type":46,"value":456},{"type":46,"value":488}," to use.",{"type":40,"tag":60,"props":490,"children":491},{},[492],{"type":46,"value":493},"The mock data only needs include the subset of columns used within this test case.",{"type":40,"tag":211,"props":495,"children":496},{},[497,503,505,511],{"type":40,"tag":498,"props":499,"children":500},"strong",{},[501],{"type":46,"value":502},"Tip:",{"type":46,"value":504}," Use ",{"type":40,"tag":275,"props":506,"children":508},{"className":507},[],[509],{"type":46,"value":510},"dbt show",{"type":46,"value":512}," to explore existing data from upstream models or sources. This helps you understand realistic input structures. However, always sanitize the sample data to remove any sensitive or PII information before using it in your unit test fixtures.",{"type":40,"tag":514,"props":515,"children":520},"pre",{"className":516,"code":517,"language":518,"meta":519,"style":519},"language-shell shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Preview upstream model data\ndbt show --select upstream_model --limit 5\n","shell","",[521],{"type":40,"tag":275,"props":522,"children":523},{"__ignoreMap":519},[524,536],{"type":40,"tag":525,"props":526,"children":529},"span",{"class":527,"line":528},"line",1,[530],{"type":40,"tag":525,"props":531,"children":533},{"style":532},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[534],{"type":46,"value":535},"# Preview upstream model data\n",{"type":40,"tag":525,"props":537,"children":539},{"class":527,"line":538},2,[540,545,551,556,561,566],{"type":40,"tag":525,"props":541,"children":543},{"style":542},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[544],{"type":46,"value":17},{"type":40,"tag":525,"props":546,"children":548},{"style":547},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[549],{"type":46,"value":550}," show",{"type":40,"tag":525,"props":552,"children":553},{"style":547},[554],{"type":46,"value":555}," --select",{"type":40,"tag":525,"props":557,"children":558},{"style":547},[559],{"type":46,"value":560}," upstream_model",{"type":40,"tag":525,"props":562,"children":563},{"style":547},[564],{"type":46,"value":565}," --limit",{"type":40,"tag":525,"props":567,"children":569},{"style":568},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[570],{"type":46,"value":571}," 5\n",{"type":40,"tag":410,"props":573,"children":575},{"id":574},"_3-mock-the-output",[576],{"type":46,"value":577},"3. Mock the output",{"type":40,"tag":56,"props":579,"children":580},{},[581,586,621],{"type":40,"tag":60,"props":582,"children":583},{},[584],{"type":46,"value":585},"Specify the data that you expect the model to create given those inputs.",{"type":40,"tag":60,"props":587,"children":588},{},[589,590,595,596,601,602],{"type":46,"value":450},{"type":40,"tag":275,"props":591,"children":593},{"className":592},[],[594],{"type":46,"value":456},{"type":46,"value":458},{"type":40,"tag":275,"props":597,"children":599},{"className":598},[],[600],{"type":46,"value":464},{"type":46,"value":466},{"type":40,"tag":56,"props":603,"children":604},{},[605],{"type":40,"tag":60,"props":606,"children":607},{},[608,609,614,615,620],{"type":46,"value":474},{"type":40,"tag":275,"props":610,"children":612},{"className":611},[],[613],{"type":46,"value":456},{"type":46,"value":481},{"type":40,"tag":275,"props":616,"children":618},{"className":617},[],[619],{"type":46,"value":456},{"type":46,"value":488},{"type":40,"tag":60,"props":622,"children":623},{},[624],{"type":46,"value":493},{"type":40,"tag":410,"props":626,"children":628},{"id":627},"_4-ensure-upstream-models-exist-before-running",[629],{"type":46,"value":630},"4. Ensure upstream models exist before running",{"type":40,"tag":211,"props":632,"children":633},{},[634,639,641,647],{"type":40,"tag":498,"props":635,"children":636},{},[637],{"type":46,"value":638},"Unit tests require direct parent models to exist in the warehouse.",{"type":46,"value":640}," Before running unit tests standalone (",{"type":40,"tag":275,"props":642,"children":644},{"className":643},[],[645],{"type":46,"value":646},"dbt test",{"type":46,"value":648},"), verify that upstream models already exist first:",{"type":40,"tag":514,"props":650,"children":654},{"className":651,"code":652,"language":653,"meta":519,"style":519},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Check if upstream models exist in the warehouse\ndbt list --select +my_model --exclude my_model --resource-type model\n# Then verify the tables\u002Fviews actually exist in the warehouse via dbt show or your SQL client\ndbt show --select upstream_model --limit 1\n","bash",[655],{"type":40,"tag":275,"props":656,"children":657},{"__ignoreMap":519},[658,666,707,716],{"type":40,"tag":525,"props":659,"children":660},{"class":527,"line":528},[661],{"type":40,"tag":525,"props":662,"children":663},{"style":532},[664],{"type":46,"value":665},"# Check if upstream models exist in the warehouse\n",{"type":40,"tag":525,"props":667,"children":668},{"class":527,"line":538},[669,673,678,682,687,692,697,702],{"type":40,"tag":525,"props":670,"children":671},{"style":542},[672],{"type":46,"value":17},{"type":40,"tag":525,"props":674,"children":675},{"style":547},[676],{"type":46,"value":677}," list",{"type":40,"tag":525,"props":679,"children":680},{"style":547},[681],{"type":46,"value":555},{"type":40,"tag":525,"props":683,"children":684},{"style":547},[685],{"type":46,"value":686}," +my_model",{"type":40,"tag":525,"props":688,"children":689},{"style":547},[690],{"type":46,"value":691}," --exclude",{"type":40,"tag":525,"props":693,"children":694},{"style":547},[695],{"type":46,"value":696}," my_model",{"type":40,"tag":525,"props":698,"children":699},{"style":547},[700],{"type":46,"value":701}," --resource-type",{"type":40,"tag":525,"props":703,"children":704},{"style":547},[705],{"type":46,"value":706}," model\n",{"type":40,"tag":525,"props":708,"children":710},{"class":527,"line":709},3,[711],{"type":40,"tag":525,"props":712,"children":713},{"style":532},[714],{"type":46,"value":715},"# Then verify the tables\u002Fviews actually exist in the warehouse via dbt show or your SQL client\n",{"type":40,"tag":525,"props":717,"children":719},{"class":527,"line":718},4,[720,724,728,732,736,740],{"type":40,"tag":525,"props":721,"children":722},{"style":542},[723],{"type":46,"value":17},{"type":40,"tag":525,"props":725,"children":726},{"style":547},[727],{"type":46,"value":550},{"type":40,"tag":525,"props":729,"children":730},{"style":547},[731],{"type":46,"value":555},{"type":40,"tag":525,"props":733,"children":734},{"style":547},[735],{"type":46,"value":560},{"type":40,"tag":525,"props":737,"children":738},{"style":547},[739],{"type":46,"value":565},{"type":40,"tag":525,"props":741,"children":742},{"style":568},[743],{"type":46,"value":744}," 1\n",{"type":40,"tag":211,"props":746,"children":747},{},[748,750,755,757,762,764,770],{"type":46,"value":749},"If upstream models ",{"type":40,"tag":498,"props":751,"children":752},{},[753],{"type":46,"value":754},"do not exist",{"type":46,"value":756},", or ",{"type":40,"tag":498,"props":758,"children":759},{},[760],{"type":46,"value":761},"exist but have been modified and not yet refreshed",{"type":46,"value":763},", build them using ",{"type":40,"tag":275,"props":765,"children":767},{"className":766},[],[768],{"type":46,"value":769},"--empty",{"type":46,"value":771}," to create schema-only versions:",{"type":40,"tag":514,"props":773,"children":775},{"className":651,"code":774,"language":653,"meta":519,"style":519},"# Build upstream models cheaply (schema only, no data read)\ndbt run --select +my_model --exclude my_model --empty\n",[776],{"type":40,"tag":275,"props":777,"children":778},{"__ignoreMap":519},[779,787],{"type":40,"tag":525,"props":780,"children":781},{"class":527,"line":528},[782],{"type":40,"tag":525,"props":783,"children":784},{"style":532},[785],{"type":46,"value":786},"# Build upstream models cheaply (schema only, no data read)\n",{"type":40,"tag":525,"props":788,"children":789},{"class":527,"line":538},[790,794,799,803,807,811,815],{"type":40,"tag":525,"props":791,"children":792},{"style":542},[793],{"type":46,"value":17},{"type":40,"tag":525,"props":795,"children":796},{"style":547},[797],{"type":46,"value":798}," run",{"type":40,"tag":525,"props":800,"children":801},{"style":547},[802],{"type":46,"value":555},{"type":40,"tag":525,"props":804,"children":805},{"style":547},[806],{"type":46,"value":686},{"type":40,"tag":525,"props":808,"children":809},{"style":547},[810],{"type":46,"value":691},{"type":40,"tag":525,"props":812,"children":813},{"style":547},[814],{"type":46,"value":696},{"type":40,"tag":525,"props":816,"children":817},{"style":547},[818],{"type":46,"value":819}," --empty\n",{"type":40,"tag":821,"props":822,"children":823},"blockquote",{},[824],{"type":40,"tag":211,"props":825,"children":826},{},[827,832,834,839],{"type":40,"tag":498,"props":828,"children":829},{},[830],{"type":46,"value":831},"Warning:",{"type":46,"value":833}," ",{"type":40,"tag":275,"props":835,"children":837},{"className":836},[],[838],{"type":46,"value":769},{"type":46,"value":840}," overwrites existing models with schema-only (zero-row) versions. Only use it when models don't exist yet, or when schema changes need to be applied. Do not use it if upstream models contain data you want to preserve — it will wipe that data.",{"type":40,"tag":211,"props":842,"children":843},{},[844,846,852],{"type":46,"value":845},"Skip this step if using ",{"type":40,"tag":275,"props":847,"children":849},{"className":848},[],[850],{"type":46,"value":851},"dbt build --select my_model",{"type":46,"value":853}," (recommended) — it handles the full pipeline including unit tests.",{"type":40,"tag":49,"props":855,"children":857},{"id":856},"minimal-unit-test",[858],{"type":46,"value":859},"Minimal unit test",{"type":40,"tag":211,"props":861,"children":862},{},[863],{"type":46,"value":864},"Suppose you have this model:",{"type":40,"tag":514,"props":866,"children":870},{"className":867,"code":868,"language":869,"meta":519,"style":519},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","-- models\u002Fhello_world.sql\n\nselect 'world' as hello\n","sql",[871],{"type":40,"tag":275,"props":872,"children":873},{"__ignoreMap":519},[874,882,891],{"type":40,"tag":525,"props":875,"children":876},{"class":527,"line":528},[877],{"type":40,"tag":525,"props":878,"children":879},{},[880],{"type":46,"value":881},"-- models\u002Fhello_world.sql\n",{"type":40,"tag":525,"props":883,"children":884},{"class":527,"line":538},[885],{"type":40,"tag":525,"props":886,"children":888},{"emptyLinePlaceholder":887},true,[889],{"type":46,"value":890},"\n",{"type":40,"tag":525,"props":892,"children":893},{"class":527,"line":709},[894],{"type":40,"tag":525,"props":895,"children":896},{},[897],{"type":46,"value":898},"select 'world' as hello\n",{"type":40,"tag":211,"props":900,"children":901},{},[902],{"type":46,"value":903},"Minimal unit test for that model:",{"type":40,"tag":514,"props":905,"children":908},{"className":906,"code":907,"language":14,"meta":519,"style":519},"language-yaml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# models\u002F_properties.yml\n\nunit_tests:\n  - name: test_hello_world\n\n    # Always only one transformation to test\n    model: hello_world\n\n    # No inputs needed this time!\n    # Most unit tests will have inputs -- see the \"real world example\" section below\n    given: []\n\n    # Expected output can have zero to many rows\n    expect:\n      rows:\n        - {hello: world}\n",[909],{"type":40,"tag":275,"props":910,"children":911},{"__ignoreMap":519},[912,920,927,942,965,973,982,1000,1008,1017,1026,1044,1052,1061,1074,1087],{"type":40,"tag":525,"props":913,"children":914},{"class":527,"line":528},[915],{"type":40,"tag":525,"props":916,"children":917},{"style":532},[918],{"type":46,"value":919},"# models\u002F_properties.yml\n",{"type":40,"tag":525,"props":921,"children":922},{"class":527,"line":538},[923],{"type":40,"tag":525,"props":924,"children":925},{"emptyLinePlaceholder":887},[926],{"type":46,"value":890},{"type":40,"tag":525,"props":928,"children":929},{"class":527,"line":709},[930,936],{"type":40,"tag":525,"props":931,"children":933},{"style":932},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[934],{"type":46,"value":935},"unit_tests",{"type":40,"tag":525,"props":937,"children":939},{"style":938},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[940],{"type":46,"value":941},":\n",{"type":40,"tag":525,"props":943,"children":944},{"class":527,"line":718},[945,950,955,960],{"type":40,"tag":525,"props":946,"children":947},{"style":938},[948],{"type":46,"value":949},"  -",{"type":40,"tag":525,"props":951,"children":952},{"style":932},[953],{"type":46,"value":954}," name",{"type":40,"tag":525,"props":956,"children":957},{"style":938},[958],{"type":46,"value":959},":",{"type":40,"tag":525,"props":961,"children":962},{"style":547},[963],{"type":46,"value":964}," test_hello_world\n",{"type":40,"tag":525,"props":966,"children":968},{"class":527,"line":967},5,[969],{"type":40,"tag":525,"props":970,"children":971},{"emptyLinePlaceholder":887},[972],{"type":46,"value":890},{"type":40,"tag":525,"props":974,"children":976},{"class":527,"line":975},6,[977],{"type":40,"tag":525,"props":978,"children":979},{"style":532},[980],{"type":46,"value":981},"    # Always only one transformation to test\n",{"type":40,"tag":525,"props":983,"children":985},{"class":527,"line":984},7,[986,991,995],{"type":40,"tag":525,"props":987,"children":988},{"style":932},[989],{"type":46,"value":990},"    model",{"type":40,"tag":525,"props":992,"children":993},{"style":938},[994],{"type":46,"value":959},{"type":40,"tag":525,"props":996,"children":997},{"style":547},[998],{"type":46,"value":999}," hello_world\n",{"type":40,"tag":525,"props":1001,"children":1003},{"class":527,"line":1002},8,[1004],{"type":40,"tag":525,"props":1005,"children":1006},{"emptyLinePlaceholder":887},[1007],{"type":46,"value":890},{"type":40,"tag":525,"props":1009,"children":1011},{"class":527,"line":1010},9,[1012],{"type":40,"tag":525,"props":1013,"children":1014},{"style":532},[1015],{"type":46,"value":1016},"    # No inputs needed this time!\n",{"type":40,"tag":525,"props":1018,"children":1020},{"class":527,"line":1019},10,[1021],{"type":40,"tag":525,"props":1022,"children":1023},{"style":532},[1024],{"type":46,"value":1025},"    # Most unit tests will have inputs -- see the \"real world example\" section below\n",{"type":40,"tag":525,"props":1027,"children":1029},{"class":527,"line":1028},11,[1030,1035,1039],{"type":40,"tag":525,"props":1031,"children":1032},{"style":932},[1033],{"type":46,"value":1034},"    given",{"type":40,"tag":525,"props":1036,"children":1037},{"style":938},[1038],{"type":46,"value":959},{"type":40,"tag":525,"props":1040,"children":1041},{"style":938},[1042],{"type":46,"value":1043}," []\n",{"type":40,"tag":525,"props":1045,"children":1047},{"class":527,"line":1046},12,[1048],{"type":40,"tag":525,"props":1049,"children":1050},{"emptyLinePlaceholder":887},[1051],{"type":46,"value":890},{"type":40,"tag":525,"props":1053,"children":1055},{"class":527,"line":1054},13,[1056],{"type":40,"tag":525,"props":1057,"children":1058},{"style":532},[1059],{"type":46,"value":1060},"    # Expected output can have zero to many rows\n",{"type":40,"tag":525,"props":1062,"children":1064},{"class":527,"line":1063},14,[1065,1070],{"type":40,"tag":525,"props":1066,"children":1067},{"style":932},[1068],{"type":46,"value":1069},"    expect",{"type":40,"tag":525,"props":1071,"children":1072},{"style":938},[1073],{"type":46,"value":941},{"type":40,"tag":525,"props":1075,"children":1077},{"class":527,"line":1076},15,[1078,1083],{"type":40,"tag":525,"props":1079,"children":1080},{"style":932},[1081],{"type":46,"value":1082},"      rows",{"type":40,"tag":525,"props":1084,"children":1085},{"style":938},[1086],{"type":46,"value":941},{"type":40,"tag":525,"props":1088,"children":1090},{"class":527,"line":1089},16,[1091,1096,1101,1106,1110,1115],{"type":40,"tag":525,"props":1092,"children":1093},{"style":938},[1094],{"type":46,"value":1095},"        -",{"type":40,"tag":525,"props":1097,"children":1098},{"style":938},[1099],{"type":46,"value":1100}," {",{"type":40,"tag":525,"props":1102,"children":1103},{"style":932},[1104],{"type":46,"value":1105},"hello",{"type":40,"tag":525,"props":1107,"children":1108},{"style":938},[1109],{"type":46,"value":959},{"type":40,"tag":525,"props":1111,"children":1112},{"style":547},[1113],{"type":46,"value":1114}," world",{"type":40,"tag":525,"props":1116,"children":1117},{"style":938},[1118],{"type":46,"value":1119},"}\n",{"type":40,"tag":49,"props":1121,"children":1123},{"id":1122},"executing-unit-tests",[1124],{"type":46,"value":1125},"Executing unit tests",{"type":40,"tag":211,"props":1127,"children":1128},{},[1129,1131,1137],{"type":46,"value":1130},"Run the unit tests, build the model, and run the data tests for the ",{"type":40,"tag":275,"props":1132,"children":1134},{"className":1133},[],[1135],{"type":46,"value":1136},"hello_world",{"type":46,"value":1138}," model:",{"type":40,"tag":514,"props":1140,"children":1142},{"className":516,"code":1141,"language":518,"meta":519,"style":519},"dbt build --select hello_world\n",[1143],{"type":40,"tag":275,"props":1144,"children":1145},{"__ignoreMap":519},[1146],{"type":40,"tag":525,"props":1147,"children":1148},{"class":527,"line":528},[1149,1153,1158,1162],{"type":40,"tag":525,"props":1150,"children":1151},{"style":542},[1152],{"type":46,"value":17},{"type":40,"tag":525,"props":1154,"children":1155},{"style":547},[1156],{"type":46,"value":1157}," build",{"type":40,"tag":525,"props":1159,"children":1160},{"style":547},[1161],{"type":46,"value":555},{"type":40,"tag":525,"props":1163,"children":1164},{"style":547},[1165],{"type":46,"value":999},{"type":40,"tag":211,"props":1167,"children":1168},{},[1169],{"type":46,"value":1170},"This saves on warehouse spend as the model will only be materialized and move on to the data tests if the unit tests pass successfully.",{"type":40,"tag":211,"props":1172,"children":1173},{},[1174],{"type":46,"value":1175},"Or only run the unit tests without building the model or running the data tests:",{"type":40,"tag":514,"props":1177,"children":1179},{"className":516,"code":1178,"language":518,"meta":519,"style":519},"dbt test --select \"hello_world,test_type:unit\"\n",[1180],{"type":40,"tag":275,"props":1181,"children":1182},{"__ignoreMap":519},[1183],{"type":40,"tag":525,"props":1184,"children":1185},{"class":527,"line":528},[1186,1190,1195,1199,1204,1209],{"type":40,"tag":525,"props":1187,"children":1188},{"style":542},[1189],{"type":46,"value":17},{"type":40,"tag":525,"props":1191,"children":1192},{"style":547},[1193],{"type":46,"value":1194}," test",{"type":40,"tag":525,"props":1196,"children":1197},{"style":547},[1198],{"type":46,"value":555},{"type":40,"tag":525,"props":1200,"children":1201},{"style":938},[1202],{"type":46,"value":1203}," \"",{"type":40,"tag":525,"props":1205,"children":1206},{"style":547},[1207],{"type":46,"value":1208},"hello_world,test_type:unit",{"type":40,"tag":525,"props":1210,"children":1211},{"style":938},[1212],{"type":46,"value":1213},"\"\n",{"type":40,"tag":211,"props":1215,"children":1216},{},[1217],{"type":46,"value":1218},"Or choose a specific unit test by name:",{"type":40,"tag":514,"props":1220,"children":1222},{"className":516,"code":1221,"language":518,"meta":519,"style":519},"dbt test --select test_is_valid_email_address\n",[1223],{"type":40,"tag":275,"props":1224,"children":1225},{"__ignoreMap":519},[1226],{"type":40,"tag":525,"props":1227,"children":1228},{"class":527,"line":528},[1229,1233,1237,1241],{"type":40,"tag":525,"props":1230,"children":1231},{"style":542},[1232],{"type":46,"value":17},{"type":40,"tag":525,"props":1234,"children":1235},{"style":547},[1236],{"type":46,"value":1194},{"type":40,"tag":525,"props":1238,"children":1239},{"style":547},[1240],{"type":46,"value":555},{"type":40,"tag":525,"props":1242,"children":1243},{"style":547},[1244],{"type":46,"value":1245}," test_is_valid_email_address\n",{"type":40,"tag":410,"props":1247,"children":1249},{"id":1248},"excluding-unit-tests-from-production-builds",[1250],{"type":46,"value":1251},"Excluding unit tests from production builds",{"type":40,"tag":211,"props":1253,"children":1254},{},[1255],{"type":46,"value":1256},"dbt Labs strongly recommends only running unit tests in development or CI environments. Since the inputs of the unit tests are static, there's no need to use additional compute cycles running them in production. Use them when doing development for a test-driven approach and CI to ensure changes don't break them.",{"type":40,"tag":211,"props":1258,"children":1259},{},[1260,1262,1268,1270,1276,1278,1284],{"type":46,"value":1261},"Use the ",{"type":40,"tag":275,"props":1263,"children":1265},{"className":1264},[],[1266],{"type":46,"value":1267},"--resource-type",{"type":46,"value":1269}," flag ",{"type":40,"tag":275,"props":1271,"children":1273},{"className":1272},[],[1274],{"type":46,"value":1275},"--exclude-resource-type",{"type":46,"value":1277}," or the ",{"type":40,"tag":275,"props":1279,"children":1281},{"className":1280},[],[1282],{"type":46,"value":1283},"DBT_EXCLUDE_RESOURCE_TYPES",{"type":46,"value":1285}," environment variable to exclude unit tests from your production builds and save compute.",{"type":40,"tag":49,"props":1287,"children":1289},{"id":1288},"more-realistic-example",[1290],{"type":46,"value":1291},"More realistic example",{"type":40,"tag":514,"props":1293,"children":1295},{"className":906,"code":1294,"language":14,"meta":519,"style":519},"unit_tests:\n\n  - name: test_order_items_count_drink_items_with_zero_drinks\n    description: >\n      Scenario: Order without any drinks\n        When the `order_items_summary` table is built\n        Given an order with nothing but 1 food item\n        Then the count of drink items is 0\n\n    # Model\n    model: order_items_summary\n\n    # Inputs\n    given:\n      - input: ref('order_items')\n        rows:\n          - {\n              order_id: 76,\n              order_item_id: 3,\n              is_drink_item: false,\n            }\n      - input: ref('stg_orders')\n        rows:\n          - { order_id: 76 }\n\n    # Output\n    expect:\n      rows:\n        - {\n            order_id: 76,\n            count_drink_items: 0,\n          }\n",[1296],{"type":40,"tag":275,"props":1297,"children":1298},{"__ignoreMap":519},[1299,1310,1317,1337,1355,1363,1371,1379,1387,1394,1402,1418,1425,1433,1444,1466,1478,1492,1515,1537,1560,1569,1590,1602,1632,1640,1649,1661,1673,1685,1706,1728],{"type":40,"tag":525,"props":1300,"children":1301},{"class":527,"line":528},[1302,1306],{"type":40,"tag":525,"props":1303,"children":1304},{"style":932},[1305],{"type":46,"value":935},{"type":40,"tag":525,"props":1307,"children":1308},{"style":938},[1309],{"type":46,"value":941},{"type":40,"tag":525,"props":1311,"children":1312},{"class":527,"line":538},[1313],{"type":40,"tag":525,"props":1314,"children":1315},{"emptyLinePlaceholder":887},[1316],{"type":46,"value":890},{"type":40,"tag":525,"props":1318,"children":1319},{"class":527,"line":709},[1320,1324,1328,1332],{"type":40,"tag":525,"props":1321,"children":1322},{"style":938},[1323],{"type":46,"value":949},{"type":40,"tag":525,"props":1325,"children":1326},{"style":932},[1327],{"type":46,"value":954},{"type":40,"tag":525,"props":1329,"children":1330},{"style":938},[1331],{"type":46,"value":959},{"type":40,"tag":525,"props":1333,"children":1334},{"style":547},[1335],{"type":46,"value":1336}," test_order_items_count_drink_items_with_zero_drinks\n",{"type":40,"tag":525,"props":1338,"children":1339},{"class":527,"line":718},[1340,1345,1349],{"type":40,"tag":525,"props":1341,"children":1342},{"style":932},[1343],{"type":46,"value":1344},"    description",{"type":40,"tag":525,"props":1346,"children":1347},{"style":938},[1348],{"type":46,"value":959},{"type":40,"tag":525,"props":1350,"children":1352},{"style":1351},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[1353],{"type":46,"value":1354}," >\n",{"type":40,"tag":525,"props":1356,"children":1357},{"class":527,"line":967},[1358],{"type":40,"tag":525,"props":1359,"children":1360},{"style":547},[1361],{"type":46,"value":1362},"      Scenario: Order without any drinks\n",{"type":40,"tag":525,"props":1364,"children":1365},{"class":527,"line":975},[1366],{"type":40,"tag":525,"props":1367,"children":1368},{"style":547},[1369],{"type":46,"value":1370},"        When the `order_items_summary` table is built\n",{"type":40,"tag":525,"props":1372,"children":1373},{"class":527,"line":984},[1374],{"type":40,"tag":525,"props":1375,"children":1376},{"style":547},[1377],{"type":46,"value":1378},"        Given an order with nothing but 1 food item\n",{"type":40,"tag":525,"props":1380,"children":1381},{"class":527,"line":1002},[1382],{"type":40,"tag":525,"props":1383,"children":1384},{"style":547},[1385],{"type":46,"value":1386},"        Then the count of drink items is 0\n",{"type":40,"tag":525,"props":1388,"children":1389},{"class":527,"line":1010},[1390],{"type":40,"tag":525,"props":1391,"children":1392},{"emptyLinePlaceholder":887},[1393],{"type":46,"value":890},{"type":40,"tag":525,"props":1395,"children":1396},{"class":527,"line":1019},[1397],{"type":40,"tag":525,"props":1398,"children":1399},{"style":532},[1400],{"type":46,"value":1401},"    # Model\n",{"type":40,"tag":525,"props":1403,"children":1404},{"class":527,"line":1028},[1405,1409,1413],{"type":40,"tag":525,"props":1406,"children":1407},{"style":932},[1408],{"type":46,"value":990},{"type":40,"tag":525,"props":1410,"children":1411},{"style":938},[1412],{"type":46,"value":959},{"type":40,"tag":525,"props":1414,"children":1415},{"style":547},[1416],{"type":46,"value":1417}," order_items_summary\n",{"type":40,"tag":525,"props":1419,"children":1420},{"class":527,"line":1046},[1421],{"type":40,"tag":525,"props":1422,"children":1423},{"emptyLinePlaceholder":887},[1424],{"type":46,"value":890},{"type":40,"tag":525,"props":1426,"children":1427},{"class":527,"line":1054},[1428],{"type":40,"tag":525,"props":1429,"children":1430},{"style":532},[1431],{"type":46,"value":1432},"    # Inputs\n",{"type":40,"tag":525,"props":1434,"children":1435},{"class":527,"line":1063},[1436,1440],{"type":40,"tag":525,"props":1437,"children":1438},{"style":932},[1439],{"type":46,"value":1034},{"type":40,"tag":525,"props":1441,"children":1442},{"style":938},[1443],{"type":46,"value":941},{"type":40,"tag":525,"props":1445,"children":1446},{"class":527,"line":1076},[1447,1452,1457,1461],{"type":40,"tag":525,"props":1448,"children":1449},{"style":938},[1450],{"type":46,"value":1451},"      -",{"type":40,"tag":525,"props":1453,"children":1454},{"style":932},[1455],{"type":46,"value":1456}," input",{"type":40,"tag":525,"props":1458,"children":1459},{"style":938},[1460],{"type":46,"value":959},{"type":40,"tag":525,"props":1462,"children":1463},{"style":547},[1464],{"type":46,"value":1465}," ref('order_items')\n",{"type":40,"tag":525,"props":1467,"children":1468},{"class":527,"line":1089},[1469,1474],{"type":40,"tag":525,"props":1470,"children":1471},{"style":932},[1472],{"type":46,"value":1473},"        rows",{"type":40,"tag":525,"props":1475,"children":1476},{"style":938},[1477],{"type":46,"value":941},{"type":40,"tag":525,"props":1479,"children":1481},{"class":527,"line":1480},17,[1482,1487],{"type":40,"tag":525,"props":1483,"children":1484},{"style":938},[1485],{"type":46,"value":1486},"          -",{"type":40,"tag":525,"props":1488,"children":1489},{"style":938},[1490],{"type":46,"value":1491}," {\n",{"type":40,"tag":525,"props":1493,"children":1495},{"class":527,"line":1494},18,[1496,1501,1505,1510],{"type":40,"tag":525,"props":1497,"children":1498},{"style":932},[1499],{"type":46,"value":1500},"              order_id",{"type":40,"tag":525,"props":1502,"children":1503},{"style":938},[1504],{"type":46,"value":959},{"type":40,"tag":525,"props":1506,"children":1507},{"style":568},[1508],{"type":46,"value":1509}," 76",{"type":40,"tag":525,"props":1511,"children":1512},{"style":938},[1513],{"type":46,"value":1514},",\n",{"type":40,"tag":525,"props":1516,"children":1518},{"class":527,"line":1517},19,[1519,1524,1528,1533],{"type":40,"tag":525,"props":1520,"children":1521},{"style":932},[1522],{"type":46,"value":1523},"              order_item_id",{"type":40,"tag":525,"props":1525,"children":1526},{"style":938},[1527],{"type":46,"value":959},{"type":40,"tag":525,"props":1529,"children":1530},{"style":568},[1531],{"type":46,"value":1532}," 3",{"type":40,"tag":525,"props":1534,"children":1535},{"style":938},[1536],{"type":46,"value":1514},{"type":40,"tag":525,"props":1538,"children":1540},{"class":527,"line":1539},20,[1541,1546,1550,1556],{"type":40,"tag":525,"props":1542,"children":1543},{"style":932},[1544],{"type":46,"value":1545},"              is_drink_item",{"type":40,"tag":525,"props":1547,"children":1548},{"style":938},[1549],{"type":46,"value":959},{"type":40,"tag":525,"props":1551,"children":1553},{"style":1552},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[1554],{"type":46,"value":1555}," false",{"type":40,"tag":525,"props":1557,"children":1558},{"style":938},[1559],{"type":46,"value":1514},{"type":40,"tag":525,"props":1561,"children":1563},{"class":527,"line":1562},21,[1564],{"type":40,"tag":525,"props":1565,"children":1566},{"style":938},[1567],{"type":46,"value":1568},"            }\n",{"type":40,"tag":525,"props":1570,"children":1572},{"class":527,"line":1571},22,[1573,1577,1581,1585],{"type":40,"tag":525,"props":1574,"children":1575},{"style":938},[1576],{"type":46,"value":1451},{"type":40,"tag":525,"props":1578,"children":1579},{"style":932},[1580],{"type":46,"value":1456},{"type":40,"tag":525,"props":1582,"children":1583},{"style":938},[1584],{"type":46,"value":959},{"type":40,"tag":525,"props":1586,"children":1587},{"style":547},[1588],{"type":46,"value":1589}," ref('stg_orders')\n",{"type":40,"tag":525,"props":1591,"children":1593},{"class":527,"line":1592},23,[1594,1598],{"type":40,"tag":525,"props":1595,"children":1596},{"style":932},[1597],{"type":46,"value":1473},{"type":40,"tag":525,"props":1599,"children":1600},{"style":938},[1601],{"type":46,"value":941},{"type":40,"tag":525,"props":1603,"children":1605},{"class":527,"line":1604},24,[1606,1610,1614,1619,1623,1627],{"type":40,"tag":525,"props":1607,"children":1608},{"style":938},[1609],{"type":46,"value":1486},{"type":40,"tag":525,"props":1611,"children":1612},{"style":938},[1613],{"type":46,"value":1100},{"type":40,"tag":525,"props":1615,"children":1616},{"style":932},[1617],{"type":46,"value":1618}," order_id",{"type":40,"tag":525,"props":1620,"children":1621},{"style":938},[1622],{"type":46,"value":959},{"type":40,"tag":525,"props":1624,"children":1625},{"style":568},[1626],{"type":46,"value":1509},{"type":40,"tag":525,"props":1628,"children":1629},{"style":938},[1630],{"type":46,"value":1631}," }\n",{"type":40,"tag":525,"props":1633,"children":1635},{"class":527,"line":1634},25,[1636],{"type":40,"tag":525,"props":1637,"children":1638},{"emptyLinePlaceholder":887},[1639],{"type":46,"value":890},{"type":40,"tag":525,"props":1641,"children":1643},{"class":527,"line":1642},26,[1644],{"type":40,"tag":525,"props":1645,"children":1646},{"style":532},[1647],{"type":46,"value":1648},"    # Output\n",{"type":40,"tag":525,"props":1650,"children":1652},{"class":527,"line":1651},27,[1653,1657],{"type":40,"tag":525,"props":1654,"children":1655},{"style":932},[1656],{"type":46,"value":1069},{"type":40,"tag":525,"props":1658,"children":1659},{"style":938},[1660],{"type":46,"value":941},{"type":40,"tag":525,"props":1662,"children":1664},{"class":527,"line":1663},28,[1665,1669],{"type":40,"tag":525,"props":1666,"children":1667},{"style":932},[1668],{"type":46,"value":1082},{"type":40,"tag":525,"props":1670,"children":1671},{"style":938},[1672],{"type":46,"value":941},{"type":40,"tag":525,"props":1674,"children":1676},{"class":527,"line":1675},29,[1677,1681],{"type":40,"tag":525,"props":1678,"children":1679},{"style":938},[1680],{"type":46,"value":1095},{"type":40,"tag":525,"props":1682,"children":1683},{"style":938},[1684],{"type":46,"value":1491},{"type":40,"tag":525,"props":1686,"children":1688},{"class":527,"line":1687},30,[1689,1694,1698,1702],{"type":40,"tag":525,"props":1690,"children":1691},{"style":932},[1692],{"type":46,"value":1693},"            order_id",{"type":40,"tag":525,"props":1695,"children":1696},{"style":938},[1697],{"type":46,"value":959},{"type":40,"tag":525,"props":1699,"children":1700},{"style":568},[1701],{"type":46,"value":1509},{"type":40,"tag":525,"props":1703,"children":1704},{"style":938},[1705],{"type":46,"value":1514},{"type":40,"tag":525,"props":1707,"children":1709},{"class":527,"line":1708},31,[1710,1715,1719,1724],{"type":40,"tag":525,"props":1711,"children":1712},{"style":932},[1713],{"type":46,"value":1714},"            count_drink_items",{"type":40,"tag":525,"props":1716,"children":1717},{"style":938},[1718],{"type":46,"value":959},{"type":40,"tag":525,"props":1720,"children":1721},{"style":568},[1722],{"type":46,"value":1723}," 0",{"type":40,"tag":525,"props":1725,"children":1726},{"style":938},[1727],{"type":46,"value":1514},{"type":40,"tag":525,"props":1729,"children":1731},{"class":527,"line":1730},32,[1732],{"type":40,"tag":525,"props":1733,"children":1734},{"style":938},[1735],{"type":46,"value":1736},"          }\n",{"type":40,"tag":211,"props":1738,"children":1739},{},[1740,1742],{"type":46,"value":1741},"For more examples of unit tests, see ",{"type":40,"tag":64,"props":1743,"children":1744},{"href":77},[1745],{"type":46,"value":77},{"type":40,"tag":49,"props":1747,"children":1749},{"id":1748},"supported-and-unsupported-scenarios",[1750],{"type":46,"value":1751},"Supported and unsupported scenarios",{"type":40,"tag":56,"props":1753,"children":1754},{},[1755,1773,1794,1814,1824,1834,1851],{"type":40,"tag":60,"props":1756,"children":1757},{},[1758,1760],{"type":46,"value":1759},"dbt only supports unit testing SQL models.\n",{"type":40,"tag":56,"props":1761,"children":1762},{},[1763,1768],{"type":40,"tag":60,"props":1764,"children":1765},{},[1766],{"type":46,"value":1767},"Unit testing Python models is not supported.",{"type":40,"tag":60,"props":1769,"children":1770},{},[1771],{"type":46,"value":1772},"Unit testing non-model nodes like snapshots, seeds, sources, analyses, etc. is not supported.",{"type":40,"tag":60,"props":1774,"children":1775},{},[1776,1778,1784,1786],{"type":46,"value":1777},"dbt only supports adding unit tests to models in your ",{"type":40,"tag":1779,"props":1780,"children":1781},"em",{},[1782],{"type":46,"value":1783},"current",{"type":46,"value":1785}," project.\n",{"type":40,"tag":56,"props":1787,"children":1788},{},[1789],{"type":40,"tag":60,"props":1790,"children":1791},{},[1792],{"type":46,"value":1793},"Unit testing cross-project models or models imported from a package is not supported.",{"type":40,"tag":60,"props":1795,"children":1796},{},[1797,1799,1804,1806,1812],{"type":46,"value":1798},"dbt ",{"type":40,"tag":1779,"props":1800,"children":1801},{},[1802],{"type":46,"value":1803},"does not",{"type":46,"value":1805}," support unit testing models that use the ",{"type":40,"tag":275,"props":1807,"children":1809},{"className":1808},[],[1810],{"type":46,"value":1811},"materialized view",{"type":46,"value":1813}," materialization.",{"type":40,"tag":60,"props":1815,"children":1816},{},[1817,1818,1822],{"type":46,"value":1798},{"type":40,"tag":1779,"props":1819,"children":1820},{},[1821],{"type":46,"value":1803},{"type":46,"value":1823}," support unit testing models that use recursive SQL.",{"type":40,"tag":60,"props":1825,"children":1826},{},[1827,1828,1832],{"type":46,"value":1798},{"type":40,"tag":1779,"props":1829,"children":1830},{},[1831],{"type":46,"value":1803},{"type":46,"value":1833}," support unit testing models that use introspective queries.",{"type":40,"tag":60,"props":1835,"children":1836},{},[1837,1838,1842,1844,1849],{"type":46,"value":1798},{"type":40,"tag":1779,"props":1839,"children":1840},{},[1841],{"type":46,"value":1803},{"type":46,"value":1843}," support an ",{"type":40,"tag":275,"props":1845,"children":1847},{"className":1846},[],[1848],{"type":46,"value":406},{"type":46,"value":1850}," output for final state of the database table after inserting\u002Fmerging for incremental models.",{"type":40,"tag":60,"props":1852,"children":1853},{},[1854,1855,1860,1861,1866],{"type":46,"value":1798},{"type":40,"tag":1779,"props":1856,"children":1857},{},[1858],{"type":46,"value":1859},"does",{"type":46,"value":1843},{"type":40,"tag":275,"props":1862,"children":1864},{"className":1863},[],[1865],{"type":46,"value":406},{"type":46,"value":1867}," output for what will be merged\u002Finserted for incremental models.",{"type":40,"tag":49,"props":1869,"children":1871},{"id":1870},"handy-to-know",[1872],{"type":46,"value":1873},"Handy to know",{"type":40,"tag":56,"props":1875,"children":1876},{},[1877,1898,1917,1946,1958,1971],{"type":40,"tag":60,"props":1878,"children":1879},{},[1880,1882,1888,1890,1896],{"type":46,"value":1881},"Unit tests must be defined in a YAML file in your ",{"type":40,"tag":275,"props":1883,"children":1885},{"className":1884},[],[1886],{"type":46,"value":1887},"model-paths",{"type":46,"value":1889}," directory (",{"type":40,"tag":275,"props":1891,"children":1893},{"className":1892},[],[1894],{"type":46,"value":1895},"models\u002F",{"type":46,"value":1897}," by default)",{"type":40,"tag":60,"props":1899,"children":1900},{},[1901,1903,1909,1910,1916],{"type":46,"value":1902},"Fixture files for unit tests must be defined in a SQL or CSV file in your ",{"type":40,"tag":275,"props":1904,"children":1906},{"className":1905},[],[1907],{"type":46,"value":1908},"test-paths",{"type":46,"value":1889},{"type":40,"tag":275,"props":1911,"children":1913},{"className":1912},[],[1914],{"type":46,"value":1915},"tests\u002Ffixtures",{"type":46,"value":1897},{"type":40,"tag":60,"props":1918,"children":1919},{},[1920,1922,1928,1930,1936,1938,1944],{"type":46,"value":1921},"Include all ",{"type":40,"tag":275,"props":1923,"children":1925},{"className":1924},[],[1926],{"type":46,"value":1927},"ref",{"type":46,"value":1929}," or ",{"type":40,"tag":275,"props":1931,"children":1933},{"className":1932},[],[1934],{"type":46,"value":1935},"source",{"type":46,"value":1937}," model references in the unit test configuration as ",{"type":40,"tag":275,"props":1939,"children":1941},{"className":1940},[],[1942],{"type":46,"value":1943},"input",{"type":46,"value":1945},"s to avoid \"node not found\" errors during compilation.",{"type":40,"tag":60,"props":1947,"children":1948},{},[1949,1951,1956],{"type":46,"value":1950},"If your model has multiple versions, by default the unit test will run on ",{"type":40,"tag":1779,"props":1952,"children":1953},{},[1954],{"type":46,"value":1955},"all",{"type":46,"value":1957}," versions of your model.",{"type":40,"tag":60,"props":1959,"children":1960},{},[1961,1963,1969],{"type":46,"value":1962},"If you want to unit test a model that depends on an ephemeral model, you must use ",{"type":40,"tag":275,"props":1964,"children":1966},{"className":1965},[],[1967],{"type":46,"value":1968},"format: sql",{"type":46,"value":1970}," for the ephemeral model input.",{"type":40,"tag":60,"props":1972,"children":1973},{},[1974,1976,1982],{"type":46,"value":1975},"Table names within the model must be aliased in order to unit test ",{"type":40,"tag":275,"props":1977,"children":1979},{"className":1978},[],[1980],{"type":46,"value":1981},"join",{"type":46,"value":1983}," logic",{"type":40,"tag":49,"props":1985,"children":1987},{"id":1986},"yaml-for-specifying-unit-tests",[1988],{"type":46,"value":1989},"YAML for specifying unit tests",{"type":40,"tag":56,"props":1991,"children":1992},{},[1993],{"type":40,"tag":60,"props":1994,"children":1995},{},[1996,1998],{"type":46,"value":1997},"For all the required and optional keys in the YAML definition of unit tests, see ",{"type":40,"tag":64,"props":1999,"children":2000},{"href":66},[2001],{"type":46,"value":66},{"type":40,"tag":41,"props":2003,"children":2005},{"id":2004},"inputs-for-unit-tests",[2006],{"type":46,"value":2007},"Inputs for unit tests",{"type":40,"tag":211,"props":2009,"children":2010},{},[2011,2013,2018],{"type":46,"value":2012},"Use ",{"type":40,"tag":275,"props":2014,"children":2016},{"className":2015},[],[2017],{"type":46,"value":1943},{"type":46,"value":2019},"s in your unit tests to reference a specific model or source for the test:",{"type":40,"tag":56,"props":2021,"children":2022},{},[2023,2084,2109],{"type":40,"tag":60,"props":2024,"children":2025},{},[2026,2028,2034,2036,2041,2042,2047,2049],{"type":46,"value":2027},"For ",{"type":40,"tag":275,"props":2029,"children":2031},{"className":2030},[],[2032],{"type":46,"value":2033},"input:",{"type":46,"value":2035},", use a string that represents a ",{"type":40,"tag":275,"props":2037,"children":2039},{"className":2038},[],[2040],{"type":46,"value":1927},{"type":46,"value":1929},{"type":40,"tag":275,"props":2043,"children":2045},{"className":2044},[],[2046],{"type":46,"value":1935},{"type":46,"value":2048}," call:\n",{"type":40,"tag":56,"props":2050,"children":2051},{},[2052,2075],{"type":40,"tag":60,"props":2053,"children":2054},{},[2055,2061,2062,2068,2069],{"type":40,"tag":275,"props":2056,"children":2058},{"className":2057},[],[2059],{"type":46,"value":2060},"ref('my_model')",{"type":46,"value":1929},{"type":40,"tag":275,"props":2063,"children":2065},{"className":2064},[],[2066],{"type":46,"value":2067},"ref('my_model', v='2')",{"type":46,"value":1929},{"type":40,"tag":275,"props":2070,"children":2072},{"className":2071},[],[2073],{"type":46,"value":2074},"ref('dougs_project', 'users')",{"type":40,"tag":60,"props":2076,"children":2077},{},[2078],{"type":40,"tag":275,"props":2079,"children":2081},{"className":2080},[],[2082],{"type":46,"value":2083},"source('source_schema', 'source_name')",{"type":40,"tag":60,"props":2085,"children":2086},{},[2087,2089],{"type":46,"value":2088},"For seed inputs:\n",{"type":40,"tag":56,"props":2090,"children":2091},{},[2092,2104],{"type":40,"tag":60,"props":2093,"children":2094},{},[2095,2097,2102],{"type":46,"value":2096},"If you do not supply an input for a seed, we will use the seed's CSV file ",{"type":40,"tag":1779,"props":2098,"children":2099},{},[2100],{"type":46,"value":2101},"as",{"type":46,"value":2103}," the input.",{"type":40,"tag":60,"props":2105,"children":2106},{},[2107],{"type":46,"value":2108},"If you do supply an input for a seed, we will use that input instead.",{"type":40,"tag":60,"props":2110,"children":2111},{},[2112,2114,2120],{"type":46,"value":2113},"Use “empty” inputs by setting rows to an empty list ",{"type":40,"tag":275,"props":2115,"children":2117},{"className":2116},[],[2118],{"type":46,"value":2119},"rows: []",{"type":40,"tag":56,"props":2121,"children":2122},{},[2123],{"type":40,"tag":60,"props":2124,"children":2125},{},[2126,2128,2133,2134,2139],{"type":46,"value":2127},"This is useful if the model has a ",{"type":40,"tag":275,"props":2129,"children":2131},{"className":2130},[],[2132],{"type":46,"value":1927},{"type":46,"value":1929},{"type":40,"tag":275,"props":2135,"children":2137},{"className":2136},[],[2138],{"type":46,"value":1935},{"type":46,"value":2140}," dependency, but its values are irrelevant to this particular unit test. Just beware if the model has a join on that input that would cause rows to drop out!",{"type":40,"tag":211,"props":2142,"children":2143},{},[2144],{"type":40,"tag":275,"props":2145,"children":2147},{"className":2146},[],[2148],{"type":46,"value":2149},"models\u002Fschema.yml",{"type":40,"tag":514,"props":2151,"children":2153},{"className":906,"code":2152,"language":14,"meta":519,"style":519},"unit_tests:\n  - name: test_is_valid_email_address  # this is the unique name of the test\n    model: dim_customers  # name of the model I'm unit testing\n    given:  # the mock data for your inputs\n      - input: ref('stg_customers')\n        rows:\n         - {email: cool@example.com,     email_top_level_domain: example.com}\n         - {email: cool@unknown.com,     email_top_level_domain: unknown.com}\n         - {email: badgmail.com,         email_top_level_domain: gmail.com}\n         - {email: missingdot@gmailcom,  email_top_level_domain: gmail.com}\n      - input: ref('top_level_email_domains')\n        rows:\n         - {tld: example.com}\n         - {tld: gmail.com}\n      - input: ref('irrelevant_dependency')  # dependency that we need to acknowlege, but does not need any data\n        rows: []\n...\n\n",[2154],{"type":40,"tag":275,"props":2155,"children":2156},{"__ignoreMap":519},[2157,2168,2193,2214,2230,2250,2261,2310,2355,2401,2446,2466,2477,2505,2532,2557,2572],{"type":40,"tag":525,"props":2158,"children":2159},{"class":527,"line":528},[2160,2164],{"type":40,"tag":525,"props":2161,"children":2162},{"style":932},[2163],{"type":46,"value":935},{"type":40,"tag":525,"props":2165,"children":2166},{"style":938},[2167],{"type":46,"value":941},{"type":40,"tag":525,"props":2169,"children":2170},{"class":527,"line":538},[2171,2175,2179,2183,2188],{"type":40,"tag":525,"props":2172,"children":2173},{"style":938},[2174],{"type":46,"value":949},{"type":40,"tag":525,"props":2176,"children":2177},{"style":932},[2178],{"type":46,"value":954},{"type":40,"tag":525,"props":2180,"children":2181},{"style":938},[2182],{"type":46,"value":959},{"type":40,"tag":525,"props":2184,"children":2185},{"style":547},[2186],{"type":46,"value":2187}," test_is_valid_email_address",{"type":40,"tag":525,"props":2189,"children":2190},{"style":532},[2191],{"type":46,"value":2192},"  # this is the unique name of the test\n",{"type":40,"tag":525,"props":2194,"children":2195},{"class":527,"line":709},[2196,2200,2204,2209],{"type":40,"tag":525,"props":2197,"children":2198},{"style":932},[2199],{"type":46,"value":990},{"type":40,"tag":525,"props":2201,"children":2202},{"style":938},[2203],{"type":46,"value":959},{"type":40,"tag":525,"props":2205,"children":2206},{"style":547},[2207],{"type":46,"value":2208}," dim_customers",{"type":40,"tag":525,"props":2210,"children":2211},{"style":532},[2212],{"type":46,"value":2213},"  # name of the model I'm unit testing\n",{"type":40,"tag":525,"props":2215,"children":2216},{"class":527,"line":718},[2217,2221,2225],{"type":40,"tag":525,"props":2218,"children":2219},{"style":932},[2220],{"type":46,"value":1034},{"type":40,"tag":525,"props":2222,"children":2223},{"style":938},[2224],{"type":46,"value":959},{"type":40,"tag":525,"props":2226,"children":2227},{"style":532},[2228],{"type":46,"value":2229},"  # the mock data for your inputs\n",{"type":40,"tag":525,"props":2231,"children":2232},{"class":527,"line":967},[2233,2237,2241,2245],{"type":40,"tag":525,"props":2234,"children":2235},{"style":938},[2236],{"type":46,"value":1451},{"type":40,"tag":525,"props":2238,"children":2239},{"style":932},[2240],{"type":46,"value":1456},{"type":40,"tag":525,"props":2242,"children":2243},{"style":938},[2244],{"type":46,"value":959},{"type":40,"tag":525,"props":2246,"children":2247},{"style":547},[2248],{"type":46,"value":2249}," ref('stg_customers')\n",{"type":40,"tag":525,"props":2251,"children":2252},{"class":527,"line":975},[2253,2257],{"type":40,"tag":525,"props":2254,"children":2255},{"style":932},[2256],{"type":46,"value":1473},{"type":40,"tag":525,"props":2258,"children":2259},{"style":938},[2260],{"type":46,"value":941},{"type":40,"tag":525,"props":2262,"children":2263},{"class":527,"line":984},[2264,2269,2273,2278,2282,2287,2292,2297,2301,2306],{"type":40,"tag":525,"props":2265,"children":2266},{"style":938},[2267],{"type":46,"value":2268},"         -",{"type":40,"tag":525,"props":2270,"children":2271},{"style":938},[2272],{"type":46,"value":1100},{"type":40,"tag":525,"props":2274,"children":2275},{"style":932},[2276],{"type":46,"value":2277},"email",{"type":40,"tag":525,"props":2279,"children":2280},{"style":938},[2281],{"type":46,"value":959},{"type":40,"tag":525,"props":2283,"children":2284},{"style":547},[2285],{"type":46,"value":2286}," cool@example.com",{"type":40,"tag":525,"props":2288,"children":2289},{"style":938},[2290],{"type":46,"value":2291},",",{"type":40,"tag":525,"props":2293,"children":2294},{"style":932},[2295],{"type":46,"value":2296},"     email_top_level_domain",{"type":40,"tag":525,"props":2298,"children":2299},{"style":938},[2300],{"type":46,"value":959},{"type":40,"tag":525,"props":2302,"children":2303},{"style":547},[2304],{"type":46,"value":2305}," example.com",{"type":40,"tag":525,"props":2307,"children":2308},{"style":938},[2309],{"type":46,"value":1119},{"type":40,"tag":525,"props":2311,"children":2312},{"class":527,"line":1002},[2313,2317,2321,2325,2329,2334,2338,2342,2346,2351],{"type":40,"tag":525,"props":2314,"children":2315},{"style":938},[2316],{"type":46,"value":2268},{"type":40,"tag":525,"props":2318,"children":2319},{"style":938},[2320],{"type":46,"value":1100},{"type":40,"tag":525,"props":2322,"children":2323},{"style":932},[2324],{"type":46,"value":2277},{"type":40,"tag":525,"props":2326,"children":2327},{"style":938},[2328],{"type":46,"value":959},{"type":40,"tag":525,"props":2330,"children":2331},{"style":547},[2332],{"type":46,"value":2333}," cool@unknown.com",{"type":40,"tag":525,"props":2335,"children":2336},{"style":938},[2337],{"type":46,"value":2291},{"type":40,"tag":525,"props":2339,"children":2340},{"style":932},[2341],{"type":46,"value":2296},{"type":40,"tag":525,"props":2343,"children":2344},{"style":938},[2345],{"type":46,"value":959},{"type":40,"tag":525,"props":2347,"children":2348},{"style":547},[2349],{"type":46,"value":2350}," unknown.com",{"type":40,"tag":525,"props":2352,"children":2353},{"style":938},[2354],{"type":46,"value":1119},{"type":40,"tag":525,"props":2356,"children":2357},{"class":527,"line":1010},[2358,2362,2366,2370,2374,2379,2383,2388,2392,2397],{"type":40,"tag":525,"props":2359,"children":2360},{"style":938},[2361],{"type":46,"value":2268},{"type":40,"tag":525,"props":2363,"children":2364},{"style":938},[2365],{"type":46,"value":1100},{"type":40,"tag":525,"props":2367,"children":2368},{"style":932},[2369],{"type":46,"value":2277},{"type":40,"tag":525,"props":2371,"children":2372},{"style":938},[2373],{"type":46,"value":959},{"type":40,"tag":525,"props":2375,"children":2376},{"style":547},[2377],{"type":46,"value":2378}," badgmail.com",{"type":40,"tag":525,"props":2380,"children":2381},{"style":938},[2382],{"type":46,"value":2291},{"type":40,"tag":525,"props":2384,"children":2385},{"style":932},[2386],{"type":46,"value":2387},"         email_top_level_domain",{"type":40,"tag":525,"props":2389,"children":2390},{"style":938},[2391],{"type":46,"value":959},{"type":40,"tag":525,"props":2393,"children":2394},{"style":547},[2395],{"type":46,"value":2396}," gmail.com",{"type":40,"tag":525,"props":2398,"children":2399},{"style":938},[2400],{"type":46,"value":1119},{"type":40,"tag":525,"props":2402,"children":2403},{"class":527,"line":1019},[2404,2408,2412,2416,2420,2425,2429,2434,2438,2442],{"type":40,"tag":525,"props":2405,"children":2406},{"style":938},[2407],{"type":46,"value":2268},{"type":40,"tag":525,"props":2409,"children":2410},{"style":938},[2411],{"type":46,"value":1100},{"type":40,"tag":525,"props":2413,"children":2414},{"style":932},[2415],{"type":46,"value":2277},{"type":40,"tag":525,"props":2417,"children":2418},{"style":938},[2419],{"type":46,"value":959},{"type":40,"tag":525,"props":2421,"children":2422},{"style":547},[2423],{"type":46,"value":2424}," missingdot@gmailcom",{"type":40,"tag":525,"props":2426,"children":2427},{"style":938},[2428],{"type":46,"value":2291},{"type":40,"tag":525,"props":2430,"children":2431},{"style":932},[2432],{"type":46,"value":2433},"  email_top_level_domain",{"type":40,"tag":525,"props":2435,"children":2436},{"style":938},[2437],{"type":46,"value":959},{"type":40,"tag":525,"props":2439,"children":2440},{"style":547},[2441],{"type":46,"value":2396},{"type":40,"tag":525,"props":2443,"children":2444},{"style":938},[2445],{"type":46,"value":1119},{"type":40,"tag":525,"props":2447,"children":2448},{"class":527,"line":1028},[2449,2453,2457,2461],{"type":40,"tag":525,"props":2450,"children":2451},{"style":938},[2452],{"type":46,"value":1451},{"type":40,"tag":525,"props":2454,"children":2455},{"style":932},[2456],{"type":46,"value":1456},{"type":40,"tag":525,"props":2458,"children":2459},{"style":938},[2460],{"type":46,"value":959},{"type":40,"tag":525,"props":2462,"children":2463},{"style":547},[2464],{"type":46,"value":2465}," ref('top_level_email_domains')\n",{"type":40,"tag":525,"props":2467,"children":2468},{"class":527,"line":1046},[2469,2473],{"type":40,"tag":525,"props":2470,"children":2471},{"style":932},[2472],{"type":46,"value":1473},{"type":40,"tag":525,"props":2474,"children":2475},{"style":938},[2476],{"type":46,"value":941},{"type":40,"tag":525,"props":2478,"children":2479},{"class":527,"line":1054},[2480,2484,2488,2493,2497,2501],{"type":40,"tag":525,"props":2481,"children":2482},{"style":938},[2483],{"type":46,"value":2268},{"type":40,"tag":525,"props":2485,"children":2486},{"style":938},[2487],{"type":46,"value":1100},{"type":40,"tag":525,"props":2489,"children":2490},{"style":932},[2491],{"type":46,"value":2492},"tld",{"type":40,"tag":525,"props":2494,"children":2495},{"style":938},[2496],{"type":46,"value":959},{"type":40,"tag":525,"props":2498,"children":2499},{"style":547},[2500],{"type":46,"value":2305},{"type":40,"tag":525,"props":2502,"children":2503},{"style":938},[2504],{"type":46,"value":1119},{"type":40,"tag":525,"props":2506,"children":2507},{"class":527,"line":1063},[2508,2512,2516,2520,2524,2528],{"type":40,"tag":525,"props":2509,"children":2510},{"style":938},[2511],{"type":46,"value":2268},{"type":40,"tag":525,"props":2513,"children":2514},{"style":938},[2515],{"type":46,"value":1100},{"type":40,"tag":525,"props":2517,"children":2518},{"style":932},[2519],{"type":46,"value":2492},{"type":40,"tag":525,"props":2521,"children":2522},{"style":938},[2523],{"type":46,"value":959},{"type":40,"tag":525,"props":2525,"children":2526},{"style":547},[2527],{"type":46,"value":2396},{"type":40,"tag":525,"props":2529,"children":2530},{"style":938},[2531],{"type":46,"value":1119},{"type":40,"tag":525,"props":2533,"children":2534},{"class":527,"line":1076},[2535,2539,2543,2547,2552],{"type":40,"tag":525,"props":2536,"children":2537},{"style":938},[2538],{"type":46,"value":1451},{"type":40,"tag":525,"props":2540,"children":2541},{"style":932},[2542],{"type":46,"value":1456},{"type":40,"tag":525,"props":2544,"children":2545},{"style":938},[2546],{"type":46,"value":959},{"type":40,"tag":525,"props":2548,"children":2549},{"style":547},[2550],{"type":46,"value":2551}," ref('irrelevant_dependency')",{"type":40,"tag":525,"props":2553,"children":2554},{"style":532},[2555],{"type":46,"value":2556},"  # dependency that we need to acknowlege, but does not need any data\n",{"type":40,"tag":525,"props":2558,"children":2559},{"class":527,"line":1089},[2560,2564,2568],{"type":40,"tag":525,"props":2561,"children":2562},{"style":932},[2563],{"type":46,"value":1473},{"type":40,"tag":525,"props":2565,"children":2566},{"style":938},[2567],{"type":46,"value":959},{"type":40,"tag":525,"props":2569,"children":2570},{"style":938},[2571],{"type":46,"value":1043},{"type":40,"tag":525,"props":2573,"children":2574},{"class":527,"line":1480},[2575],{"type":40,"tag":525,"props":2576,"children":2577},{"style":542},[2578],{"type":46,"value":2579},"...\n",{"type":40,"tag":41,"props":2581,"children":2583},{"id":2582},"data-formats-for-unit-tests",[2584,2586,2591],{"type":46,"value":2585},"Data ",{"type":40,"tag":275,"props":2587,"children":2589},{"className":2588},[],[2590],{"type":46,"value":456},{"type":46,"value":2592},"s for unit tests",{"type":40,"tag":49,"props":2594,"children":2596},{"id":2595},"dict-is-the-default-format-always-start-here",[2597,2607],{"type":40,"tag":498,"props":2598,"children":2599},{},[2600,2605],{"type":40,"tag":275,"props":2601,"children":2603},{"className":2602},[],[2604],{"type":46,"value":464},{"type":46,"value":2606}," is the default format",{"type":46,"value":2608}," — always start here",{"type":40,"tag":211,"props":2610,"children":2611},{},[2612,2614,2619,2621,2627],{"type":46,"value":2613},"Unless you have a specific reason to use another format, use ",{"type":40,"tag":275,"props":2615,"children":2617},{"className":2616},[],[2618],{"type":46,"value":464},{"type":46,"value":2620}," (inline YAML). It is the default when ",{"type":40,"tag":275,"props":2622,"children":2624},{"className":2623},[],[2625],{"type":46,"value":2626},"format:",{"type":46,"value":2628}," is omitted.",{"type":40,"tag":514,"props":2630,"children":2632},{"className":906,"code":2631,"language":14,"meta":519,"style":519},"given:\n  - input: ref('orders')\n    # no format: key needed — dict is the default\n    rows:\n      - {order_id: 1, status: completed, amount: 100}\n      - {order_id: 2, status: pending, amount: 50}\n",[2633],{"type":40,"tag":275,"props":2634,"children":2635},{"__ignoreMap":519},[2636,2647,2667,2675,2687,2752],{"type":40,"tag":525,"props":2637,"children":2638},{"class":527,"line":528},[2639,2643],{"type":40,"tag":525,"props":2640,"children":2641},{"style":932},[2642],{"type":46,"value":395},{"type":40,"tag":525,"props":2644,"children":2645},{"style":938},[2646],{"type":46,"value":941},{"type":40,"tag":525,"props":2648,"children":2649},{"class":527,"line":538},[2650,2654,2658,2662],{"type":40,"tag":525,"props":2651,"children":2652},{"style":938},[2653],{"type":46,"value":949},{"type":40,"tag":525,"props":2655,"children":2656},{"style":932},[2657],{"type":46,"value":1456},{"type":40,"tag":525,"props":2659,"children":2660},{"style":938},[2661],{"type":46,"value":959},{"type":40,"tag":525,"props":2663,"children":2664},{"style":547},[2665],{"type":46,"value":2666}," ref('orders')\n",{"type":40,"tag":525,"props":2668,"children":2669},{"class":527,"line":709},[2670],{"type":40,"tag":525,"props":2671,"children":2672},{"style":532},[2673],{"type":46,"value":2674},"    # no format: key needed — dict is the default\n",{"type":40,"tag":525,"props":2676,"children":2677},{"class":527,"line":718},[2678,2683],{"type":40,"tag":525,"props":2679,"children":2680},{"style":932},[2681],{"type":46,"value":2682},"    rows",{"type":40,"tag":525,"props":2684,"children":2685},{"style":938},[2686],{"type":46,"value":941},{"type":40,"tag":525,"props":2688,"children":2689},{"class":527,"line":967},[2690,2694,2698,2703,2707,2712,2716,2721,2725,2730,2734,2739,2743,2748],{"type":40,"tag":525,"props":2691,"children":2692},{"style":938},[2693],{"type":46,"value":1451},{"type":40,"tag":525,"props":2695,"children":2696},{"style":938},[2697],{"type":46,"value":1100},{"type":40,"tag":525,"props":2699,"children":2700},{"style":932},[2701],{"type":46,"value":2702},"order_id",{"type":40,"tag":525,"props":2704,"children":2705},{"style":938},[2706],{"type":46,"value":959},{"type":40,"tag":525,"props":2708,"children":2709},{"style":568},[2710],{"type":46,"value":2711}," 1",{"type":40,"tag":525,"props":2713,"children":2714},{"style":938},[2715],{"type":46,"value":2291},{"type":40,"tag":525,"props":2717,"children":2718},{"style":932},[2719],{"type":46,"value":2720}," status",{"type":40,"tag":525,"props":2722,"children":2723},{"style":938},[2724],{"type":46,"value":959},{"type":40,"tag":525,"props":2726,"children":2727},{"style":547},[2728],{"type":46,"value":2729}," completed",{"type":40,"tag":525,"props":2731,"children":2732},{"style":938},[2733],{"type":46,"value":2291},{"type":40,"tag":525,"props":2735,"children":2736},{"style":932},[2737],{"type":46,"value":2738}," amount",{"type":40,"tag":525,"props":2740,"children":2741},{"style":938},[2742],{"type":46,"value":959},{"type":40,"tag":525,"props":2744,"children":2745},{"style":568},[2746],{"type":46,"value":2747}," 100",{"type":40,"tag":525,"props":2749,"children":2750},{"style":938},[2751],{"type":46,"value":1119},{"type":40,"tag":525,"props":2753,"children":2754},{"class":527,"line":975},[2755,2759,2763,2767,2771,2776,2780,2784,2788,2793,2797,2801,2805,2810],{"type":40,"tag":525,"props":2756,"children":2757},{"style":938},[2758],{"type":46,"value":1451},{"type":40,"tag":525,"props":2760,"children":2761},{"style":938},[2762],{"type":46,"value":1100},{"type":40,"tag":525,"props":2764,"children":2765},{"style":932},[2766],{"type":46,"value":2702},{"type":40,"tag":525,"props":2768,"children":2769},{"style":938},[2770],{"type":46,"value":959},{"type":40,"tag":525,"props":2772,"children":2773},{"style":568},[2774],{"type":46,"value":2775}," 2",{"type":40,"tag":525,"props":2777,"children":2778},{"style":938},[2779],{"type":46,"value":2291},{"type":40,"tag":525,"props":2781,"children":2782},{"style":932},[2783],{"type":46,"value":2720},{"type":40,"tag":525,"props":2785,"children":2786},{"style":938},[2787],{"type":46,"value":959},{"type":40,"tag":525,"props":2789,"children":2790},{"style":547},[2791],{"type":46,"value":2792}," pending",{"type":40,"tag":525,"props":2794,"children":2795},{"style":938},[2796],{"type":46,"value":2291},{"type":40,"tag":525,"props":2798,"children":2799},{"style":932},[2800],{"type":46,"value":2738},{"type":40,"tag":525,"props":2802,"children":2803},{"style":938},[2804],{"type":46,"value":959},{"type":40,"tag":525,"props":2806,"children":2807},{"style":568},[2808],{"type":46,"value":2809}," 50",{"type":40,"tag":525,"props":2811,"children":2812},{"style":938},[2813],{"type":46,"value":1119},{"type":40,"tag":49,"props":2815,"children":2817},{"id":2816},"how-to-choose-the-format",[2818,2820],{"type":46,"value":2819},"How to choose the ",{"type":40,"tag":275,"props":2821,"children":2823},{"className":2822},[],[2824],{"type":46,"value":456},{"type":40,"tag":2826,"props":2827,"children":2828},"table",{},[2829,2868],{"type":40,"tag":2830,"props":2831,"children":2832},"thead",{},[2833],{"type":40,"tag":2834,"props":2835,"children":2836},"tr",{},[2837,2849,2858],{"type":40,"tag":2838,"props":2839,"children":2840},"th",{},[2841,2842,2847],{"type":46,"value":2012},{"type":40,"tag":275,"props":2843,"children":2845},{"className":2844},[],[2846],{"type":46,"value":464},{"type":46,"value":2848}," (default)",{"type":40,"tag":2838,"props":2850,"children":2851},{},[2852,2853],{"type":46,"value":2012},{"type":40,"tag":275,"props":2854,"children":2856},{"className":2855},[],[2857],{"type":46,"value":869},{"type":40,"tag":2838,"props":2859,"children":2860},{},[2861,2862],{"type":46,"value":2012},{"type":40,"tag":275,"props":2863,"children":2865},{"className":2864},[],[2866],{"type":46,"value":2867},"csv",{"type":40,"tag":2869,"props":2870,"children":2871},"tbody",{},[2872,2898,2914],{"type":40,"tag":2834,"props":2873,"children":2874},{},[2875,2881,2893],{"type":40,"tag":2876,"props":2877,"children":2878},"td",{},[2879],{"type":46,"value":2880},"Everything else — this is the starting point",{"type":40,"tag":2876,"props":2882,"children":2883},{},[2884,2886,2891],{"type":46,"value":2885},"Model depends on an ",{"type":40,"tag":498,"props":2887,"children":2888},{},[2889],{"type":46,"value":2890},"ephemeral",{"type":46,"value":2892}," model",{"type":40,"tag":2876,"props":2894,"children":2895},{},[2896],{"type":46,"value":2897},"Using an external fixture file",{"type":40,"tag":2834,"props":2899,"children":2900},{},[2901,2904,2909],{"type":40,"tag":2876,"props":2902,"children":2903},{},[],{"type":40,"tag":2876,"props":2905,"children":2906},{},[2907],{"type":46,"value":2908},"Column data type not supported by dict\u002Fcsv",{"type":40,"tag":2876,"props":2910,"children":2911},{},[2912],{"type":46,"value":2913},"Column data type not supported by dict",{"type":40,"tag":2834,"props":2915,"children":2916},{},[2917,2920,2925],{"type":40,"tag":2876,"props":2918,"children":2919},{},[],{"type":40,"tag":2876,"props":2921,"children":2922},{},[2923],{"type":46,"value":2924},"External fixture file with unsupported types",{"type":40,"tag":2876,"props":2926,"children":2927},{},[],{"type":40,"tag":211,"props":2929,"children":2930},{},[2931,2943,2945,2950,2952,2957,2959,2964,2966,2971],{"type":40,"tag":498,"props":2932,"children":2933},{},[2934,2936,2941],{"type":46,"value":2935},"Critical ",{"type":40,"tag":275,"props":2937,"children":2939},{"className":2938},[],[2940],{"type":46,"value":869},{"type":46,"value":2942}," note",{"type":46,"value":2944},": ",{"type":40,"tag":275,"props":2946,"children":2948},{"className":2947},[],[2949],{"type":46,"value":869},{"type":46,"value":2951}," format requires specifying ",{"type":40,"tag":498,"props":2953,"children":2954},{},[2955],{"type":46,"value":2956},"ALL columns",{"type":46,"value":2958}," in the mock data. ",{"type":40,"tag":275,"props":2960,"children":2962},{"className":2961},[],[2963],{"type":46,"value":464},{"type":46,"value":2965}," and ",{"type":40,"tag":275,"props":2967,"children":2969},{"className":2968},[],[2970],{"type":46,"value":2867},{"type":46,"value":2972}," only require the columns relevant to the test — much more concise.",{"type":40,"tag":211,"props":2974,"children":2975},{},[2976,2987,2989,2995,2996,3002,3004,3009,3011,3016,3018,3023,3024,3029],{"type":40,"tag":498,"props":2977,"children":2978},{},[2979,2980,2985],{"type":46,"value":2935},{"type":40,"tag":275,"props":2981,"children":2983},{"className":2982},[],[2984],{"type":46,"value":869},{"type":46,"value":2986}," requirement",{"type":46,"value":2988},": If any of your model's ",{"type":40,"tag":275,"props":2990,"children":2992},{"className":2991},[],[2993],{"type":46,"value":2994},"ref()",{"type":46,"value":1929},{"type":40,"tag":275,"props":2997,"children":2999},{"className":2998},[],[3000],{"type":46,"value":3001},"source()",{"type":46,"value":3003}," inputs are ephemeral models, you ",{"type":40,"tag":498,"props":3005,"children":3006},{},[3007],{"type":46,"value":3008},"must",{"type":46,"value":3010}," use ",{"type":40,"tag":275,"props":3012,"children":3014},{"className":3013},[],[3015],{"type":46,"value":869},{"type":46,"value":3017}," format for those inputs. ",{"type":40,"tag":275,"props":3019,"children":3021},{"className":3020},[],[3022],{"type":46,"value":464},{"type":46,"value":2965},{"type":40,"tag":275,"props":3025,"children":3027},{"className":3026},[],[3028],{"type":46,"value":2867},{"type":46,"value":3030}," will fail.",{"type":40,"tag":211,"props":3032,"children":3033},{},[3034],{"type":46,"value":3035},"dbt supports three formats for mock data within unit tests:",{"type":40,"tag":373,"props":3037,"children":3038},{},[3039,3049,3059],{"type":40,"tag":60,"props":3040,"children":3041},{},[3042,3047],{"type":40,"tag":275,"props":3043,"children":3045},{"className":3044},[],[3046],{"type":46,"value":464},{"type":46,"value":3048}," (default): Inline YAML dictionary values.",{"type":40,"tag":60,"props":3050,"children":3051},{},[3052,3057],{"type":40,"tag":275,"props":3053,"children":3055},{"className":3054},[],[3056],{"type":46,"value":2867},{"type":46,"value":3058},": Inline CSV values or a CSV file.",{"type":40,"tag":60,"props":3060,"children":3061},{},[3062,3067],{"type":40,"tag":275,"props":3063,"children":3065},{"className":3064},[],[3066],{"type":46,"value":869},{"type":46,"value":3068},": Inline SQL query or a SQL file.",{"type":40,"tag":211,"props":3070,"children":3071},{},[3072,3074],{"type":46,"value":3073},"To see examples of each of the formats, see ",{"type":40,"tag":64,"props":3075,"children":3076},{"href":77},[3077],{"type":46,"value":77},{"type":40,"tag":211,"props":3079,"children":3080},{},[3081],{"type":46,"value":3082},"Notes:",{"type":40,"tag":56,"props":3084,"children":3085},{},[3086,3118,3143],{"type":40,"tag":60,"props":3087,"children":3088},{},[3089,3091,3096,3098,3103,3105,3110,3111,3116],{"type":46,"value":3090},"For the ",{"type":40,"tag":275,"props":3092,"children":3094},{"className":3093},[],[3095],{"type":46,"value":869},{"type":46,"value":3097}," format you must supply mock data for ",{"type":40,"tag":1779,"props":3099,"children":3100},{},[3101],{"type":46,"value":3102},"all columns",{"type":46,"value":3104}," whereas ",{"type":40,"tag":275,"props":3106,"children":3108},{"className":3107},[],[3109],{"type":46,"value":464},{"type":46,"value":2965},{"type":40,"tag":275,"props":3112,"children":3114},{"className":3113},[],[3115],{"type":46,"value":2867},{"type":46,"value":3117}," may supply only a subset.",{"type":40,"tag":60,"props":3119,"children":3120},{},[3121,3123,3128,3130,3135,3136,3141],{"type":46,"value":3122},"Only the ",{"type":40,"tag":275,"props":3124,"children":3126},{"className":3125},[],[3127],{"type":46,"value":869},{"type":46,"value":3129}," format allows you to unit test a model that depends on an ephemeral model -- ",{"type":40,"tag":275,"props":3131,"children":3133},{"className":3132},[],[3134],{"type":46,"value":464},{"type":46,"value":2965},{"type":40,"tag":275,"props":3137,"children":3139},{"className":3138},[],[3140],{"type":46,"value":2867},{"type":46,"value":3142}," can't be used in that case.",{"type":40,"tag":60,"props":3144,"children":3145},{},[3146],{"type":46,"value":3147},"There are no formats that support Jinja.",{"type":40,"tag":410,"props":3149,"children":3151},{"id":3150},"fixture-files",[3152],{"type":46,"value":3153},"Fixture files",{"type":40,"tag":211,"props":3155,"children":3156},{},[3157,3159,3164,3166,3171,3172,3177,3179,3185,3187,3192,3194,3200],{"type":46,"value":3158},"The ",{"type":40,"tag":275,"props":3160,"children":3162},{"className":3161},[],[3163],{"type":46,"value":464},{"type":46,"value":3165}," format only supports inline YAML mock data, but you can also use ",{"type":40,"tag":275,"props":3167,"children":3169},{"className":3168},[],[3170],{"type":46,"value":2867},{"type":46,"value":1929},{"type":40,"tag":275,"props":3173,"children":3175},{"className":3174},[],[3176],{"type":46,"value":869},{"type":46,"value":3178}," either inline or in a separate fixture file. Store your fixture files in a ",{"type":40,"tag":275,"props":3180,"children":3182},{"className":3181},[],[3183],{"type":46,"value":3184},"fixtures",{"type":46,"value":3186}," subdirectory in any of your ",{"type":40,"tag":275,"props":3188,"children":3190},{"className":3189},[],[3191],{"type":46,"value":1908},{"type":46,"value":3193},". For example, ",{"type":40,"tag":275,"props":3195,"children":3197},{"className":3196},[],[3198],{"type":46,"value":3199},"tests\u002Ffixtures\u002Fmy_unit_test_fixture.sql",{"type":46,"value":3201},".",{"type":40,"tag":211,"props":3203,"children":3204},{},[3205,3207,3212,3213,3218,3220,3225,3227,3232,3234,3238],{"type":46,"value":3206},"When using the ",{"type":40,"tag":275,"props":3208,"children":3210},{"className":3209},[],[3211],{"type":46,"value":464},{"type":46,"value":1929},{"type":40,"tag":275,"props":3214,"children":3216},{"className":3215},[],[3217],{"type":46,"value":2867},{"type":46,"value":3219}," format, you only have to define the mock data for the columns relevant to you. This enables you to write succinct and ",{"type":40,"tag":1779,"props":3221,"children":3222},{},[3223],{"type":46,"value":3224},"specific",{"type":46,"value":3226}," unit tests. For the ",{"type":40,"tag":275,"props":3228,"children":3230},{"className":3229},[],[3231],{"type":46,"value":869},{"type":46,"value":3233}," format ",{"type":40,"tag":1779,"props":3235,"children":3236},{},[3237],{"type":46,"value":1955},{"type":46,"value":3239}," columns need to be defined.",{"type":40,"tag":49,"props":3241,"children":3243},{"id":3242},"special-cases",[3244],{"type":46,"value":3245},"Special cases",{"type":40,"tag":56,"props":3247,"children":3248},{},[3249,3259,3269,3279],{"type":40,"tag":60,"props":3250,"children":3251},{},[3252,3254,3258],{"type":46,"value":3253},"Unit testing incremental models. See ",{"type":40,"tag":64,"props":3255,"children":3256},{"href":88},[3257],{"type":46,"value":88},{"type":46,"value":3201},{"type":40,"tag":60,"props":3260,"children":3261},{},[3262,3264,3268],{"type":46,"value":3263},"Unit testing a model that depends on ephemeral model(s). See ",{"type":40,"tag":64,"props":3265,"children":3266},{"href":99},[3267],{"type":46,"value":99},{"type":46,"value":3201},{"type":40,"tag":60,"props":3270,"children":3271},{},[3272,3274,3278],{"type":46,"value":3273},"Unit test a model that depends on any introspective macros, project variables, or environment variables. See ",{"type":40,"tag":64,"props":3275,"children":3276},{"href":110},[3277],{"type":46,"value":110},{"type":46,"value":3201},{"type":40,"tag":60,"props":3280,"children":3281},{},[3282,3284,3288],{"type":46,"value":3283},"Unit testing versioned SQL models. See ",{"type":40,"tag":64,"props":3285,"children":3286},{"href":121},[3287],{"type":46,"value":121},{"type":46,"value":3201},{"type":40,"tag":410,"props":3290,"children":3292},{"id":3291},"platformadapter-specific-caveats",[3293],{"type":46,"value":3294},"Platform\u002Fadapter-specific caveats",{"type":40,"tag":211,"props":3296,"children":3297},{},[3298],{"type":46,"value":3299},"There are platform-specific details required if implementing on (Redshift, BigQuery, etc). Read the caveats file for your database (if it exists):",{"type":40,"tag":56,"props":3301,"children":3302},{},[3303,3310],{"type":40,"tag":60,"props":3304,"children":3305},{},[3306],{"type":40,"tag":64,"props":3307,"children":3308},{"href":132},[3309],{"type":46,"value":132},{"type":40,"tag":60,"props":3311,"children":3312},{},[3313],{"type":40,"tag":64,"props":3314,"children":3315},{"href":165},[3316],{"type":46,"value":165},{"type":40,"tag":41,"props":3318,"children":3320},{"id":3319},"platformadapter-specific-data-types",[3321],{"type":46,"value":3322},"Platform\u002Fadapter-specific data types",{"type":40,"tag":211,"props":3324,"children":3325},{},[3326,3328,3333],{"type":46,"value":3327},"Unit tests are designed to test for the expected ",{"type":40,"tag":1779,"props":3329,"children":3330},{},[3331],{"type":46,"value":3332},"values",{"type":46,"value":3334},", not for the data types themselves. dbt takes the value you provide and attempts to cast it to the data type as inferred from the input and output models.",{"type":40,"tag":211,"props":3336,"children":3337},{},[3338],{"type":46,"value":3339},"How you specify input and expected values in your unit test YAML definitions are largely consistent across data warehouses, with some variation for more complex data types.",{"type":40,"tag":211,"props":3341,"children":3342},{},[3343],{"type":46,"value":3344},"Read the data types file for your database:",{"type":40,"tag":56,"props":3346,"children":3347},{},[3348,3355,3362,3369,3376],{"type":40,"tag":60,"props":3349,"children":3350},{},[3351],{"type":40,"tag":64,"props":3352,"children":3353},{"href":143},[3354],{"type":46,"value":143},{"type":40,"tag":60,"props":3356,"children":3357},{},[3358],{"type":40,"tag":64,"props":3359,"children":3360},{"href":154},[3361],{"type":46,"value":154},{"type":40,"tag":60,"props":3363,"children":3364},{},[3365],{"type":40,"tag":64,"props":3366,"children":3367},{"href":176},[3368],{"type":46,"value":176},{"type":40,"tag":60,"props":3370,"children":3371},{},[3372],{"type":40,"tag":64,"props":3373,"children":3374},{"href":187},[3375],{"type":46,"value":187},{"type":40,"tag":60,"props":3377,"children":3378},{},[3379],{"type":40,"tag":64,"props":3380,"children":3381},{"href":198},[3382],{"type":46,"value":198},{"type":40,"tag":41,"props":3384,"children":3386},{"id":3385},"disabling-a-unit-test",[3387],{"type":46,"value":3388},"Disabling a unit test",{"type":40,"tag":211,"props":3390,"children":3391},{},[3392,3394,3400],{"type":46,"value":3393},"By default, all specified unit tests are enabled and will be included according to the ",{"type":40,"tag":275,"props":3395,"children":3397},{"className":3396},[],[3398],{"type":46,"value":3399},"--select",{"type":46,"value":3401}," flag.",{"type":40,"tag":211,"props":3403,"children":3404},{},[3405],{"type":46,"value":3406},"To disable a unit test from being executed, set:",{"type":40,"tag":514,"props":3408,"children":3410},{"className":906,"code":3409,"language":14,"meta":519,"style":519},"    config: \n      enabled: false\n",[3411],{"type":40,"tag":275,"props":3412,"children":3413},{"__ignoreMap":519},[3414,3432],{"type":40,"tag":525,"props":3415,"children":3416},{"class":527,"line":528},[3417,3422,3426],{"type":40,"tag":525,"props":3418,"children":3419},{"style":932},[3420],{"type":46,"value":3421},"    config",{"type":40,"tag":525,"props":3423,"children":3424},{"style":938},[3425],{"type":46,"value":959},{"type":40,"tag":525,"props":3427,"children":3429},{"style":3428},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[3430],{"type":46,"value":3431}," \n",{"type":40,"tag":525,"props":3433,"children":3434},{"class":527,"line":538},[3435,3440,3444],{"type":40,"tag":525,"props":3436,"children":3437},{"style":932},[3438],{"type":46,"value":3439},"      enabled",{"type":40,"tag":525,"props":3441,"children":3442},{"style":938},[3443],{"type":46,"value":959},{"type":40,"tag":525,"props":3445,"children":3446},{"style":1552},[3447],{"type":46,"value":3448}," false\n",{"type":40,"tag":211,"props":3450,"children":3451},{},[3452],{"type":46,"value":3453},"This is helpful if a unit test is incorrectly failing and it needs to be disabled until it is fixed.",{"type":40,"tag":410,"props":3455,"children":3457},{"id":3456},"when-a-unit-test-fails",[3458],{"type":46,"value":3459},"When a unit test fails",{"type":40,"tag":211,"props":3461,"children":3462},{},[3463],{"type":46,"value":3464},"When a unit test fails, there will be a log message of \"actual differs from expected\", and it will show a \"data diff\" between the two:",{"type":40,"tag":514,"props":3466,"children":3470},{"className":3467,"code":3469,"language":46},[3468],"language-text","actual differs from expected:\n\n@@ ,email           ,is_valid_email_address\n→  ,cool@example.com,True→False\n   ,cool@unknown.com,False\n",[3471],{"type":40,"tag":275,"props":3472,"children":3473},{"__ignoreMap":519},[3474],{"type":46,"value":3469},{"type":40,"tag":211,"props":3476,"children":3477},{},[3478],{"type":46,"value":3479},"There are two main possibilities when a unit test fails:",{"type":40,"tag":373,"props":3481,"children":3482},{},[3483,3488],{"type":40,"tag":60,"props":3484,"children":3485},{},[3486],{"type":46,"value":3487},"There was an error in the way the unit test was constructed (false positive)",{"type":40,"tag":60,"props":3489,"children":3490},{},[3491],{"type":46,"value":3492},"There is an bug is the model (true positive)",{"type":40,"tag":211,"props":3494,"children":3495},{},[3496],{"type":46,"value":3497},"It takes expert judgement to determine one from the other.",{"type":40,"tag":410,"props":3499,"children":3501},{"id":3500},"the-empty-flag",[3502,3503,3508],{"type":46,"value":3158},{"type":40,"tag":275,"props":3504,"children":3506},{"className":3505},[],[3507],{"type":46,"value":769},{"type":46,"value":3509}," flag",{"type":40,"tag":211,"props":3511,"children":3512},{},[3513,3515,3521,3522,3528,3530,3535,3537,3542,3544,3549,3551,3557],{"type":46,"value":3514},"The direct parents of the model that you’re unit testing need to exist in the warehouse before you can execute the unit test. The ",{"type":40,"tag":275,"props":3516,"children":3518},{"className":3517},[],[3519],{"type":46,"value":3520},"run",{"type":46,"value":2965},{"type":40,"tag":275,"props":3523,"children":3525},{"className":3524},[],[3526],{"type":46,"value":3527},"build",{"type":46,"value":3529}," commands supports the ",{"type":40,"tag":275,"props":3531,"children":3533},{"className":3532},[],[3534],{"type":46,"value":769},{"type":46,"value":3536}," flag for building schema-only dry runs. The ",{"type":40,"tag":275,"props":3538,"children":3540},{"className":3539},[],[3541],{"type":46,"value":769},{"type":46,"value":3543}," flag limits the ",{"type":40,"tag":275,"props":3545,"children":3547},{"className":3546},[],[3548],{"type":46,"value":1927},{"type":46,"value":3550},"s and ",{"type":40,"tag":275,"props":3552,"children":3554},{"className":3553},[],[3555],{"type":46,"value":3556},"sources",{"type":46,"value":3558}," to zero rows. dbt will still execute the model SQL against the target data warehouse but will avoid expensive reads of input data. This validates dependencies and ensures your models will build properly.",{"type":40,"tag":211,"props":3560,"children":3561},{},[3562,3563,3568],{"type":46,"value":1261},{"type":40,"tag":275,"props":3564,"children":3566},{"className":3565},[],[3567],{"type":46,"value":769},{"type":46,"value":3569}," flag to build an empty version of the models to save warehouse spend.",{"type":40,"tag":514,"props":3571,"children":3573},{"className":651,"code":3572,"language":653,"meta":519,"style":519},"\ndbt run --select \"stg_customers top_level_email_domains\" --empty\n\n",[3574],{"type":40,"tag":275,"props":3575,"children":3576},{"__ignoreMap":519},[3577,3584],{"type":40,"tag":525,"props":3578,"children":3579},{"class":527,"line":528},[3580],{"type":40,"tag":525,"props":3581,"children":3582},{"emptyLinePlaceholder":887},[3583],{"type":46,"value":890},{"type":40,"tag":525,"props":3585,"children":3586},{"class":527,"line":538},[3587,3591,3595,3599,3603,3608,3613],{"type":40,"tag":525,"props":3588,"children":3589},{"style":542},[3590],{"type":46,"value":17},{"type":40,"tag":525,"props":3592,"children":3593},{"style":547},[3594],{"type":46,"value":798},{"type":40,"tag":525,"props":3596,"children":3597},{"style":547},[3598],{"type":46,"value":555},{"type":40,"tag":525,"props":3600,"children":3601},{"style":938},[3602],{"type":46,"value":1203},{"type":40,"tag":525,"props":3604,"children":3605},{"style":547},[3606],{"type":46,"value":3607},"stg_customers top_level_email_domains",{"type":40,"tag":525,"props":3609,"children":3610},{"style":938},[3611],{"type":46,"value":3612},"\"",{"type":40,"tag":525,"props":3614,"children":3615},{"style":547},[3616],{"type":46,"value":819},{"type":40,"tag":49,"props":3618,"children":3620},{"id":3619},"common-mistakes",[3621],{"type":46,"value":3622},"Common Mistakes",{"type":40,"tag":2826,"props":3624,"children":3625},{},[3626,3642],{"type":40,"tag":2830,"props":3627,"children":3628},{},[3629],{"type":40,"tag":2834,"props":3630,"children":3631},{},[3632,3637],{"type":40,"tag":2838,"props":3633,"children":3634},{},[3635],{"type":46,"value":3636},"Mistake",{"type":40,"tag":2838,"props":3638,"children":3639},{},[3640],{"type":46,"value":3641},"Fix",{"type":40,"tag":2869,"props":3643,"children":3644},{},[3645,3658,3671,3718,3749],{"type":40,"tag":2834,"props":3646,"children":3647},{},[3648,3653],{"type":40,"tag":2876,"props":3649,"children":3650},{},[3651],{"type":46,"value":3652},"Testing simple SQL using built-in functions",{"type":40,"tag":2876,"props":3654,"children":3655},{},[3656],{"type":46,"value":3657},"Only unit test complex logic: regex, date math, window functions, multi-condition case statements",{"type":40,"tag":2834,"props":3659,"children":3660},{},[3661,3666],{"type":40,"tag":2876,"props":3662,"children":3663},{},[3664],{"type":46,"value":3665},"Mocking all columns in input data",{"type":40,"tag":2876,"props":3667,"children":3668},{},[3669],{"type":46,"value":3670},"Only include columns relevant to the test case",{"type":40,"tag":2834,"props":3672,"children":3673},{},[3674,3693],{"type":40,"tag":2876,"props":3675,"children":3676},{},[3677,3679,3684,3686,3691],{"type":46,"value":3678},"Using ",{"type":40,"tag":275,"props":3680,"children":3682},{"className":3681},[],[3683],{"type":46,"value":869},{"type":46,"value":3685}," format when ",{"type":40,"tag":275,"props":3687,"children":3689},{"className":3688},[],[3690],{"type":46,"value":464},{"type":46,"value":3692}," works",{"type":40,"tag":2876,"props":3694,"children":3695},{},[3696,3698,3703,3705,3710,3711,3716],{"type":46,"value":3697},"Prefer ",{"type":40,"tag":275,"props":3699,"children":3701},{"className":3700},[],[3702],{"type":46,"value":464},{"type":46,"value":3704}," (most readable), fall back to ",{"type":40,"tag":275,"props":3706,"children":3708},{"className":3707},[],[3709],{"type":46,"value":2867},{"type":46,"value":1929},{"type":40,"tag":275,"props":3712,"children":3714},{"className":3713},[],[3715],{"type":46,"value":869},{"type":46,"value":3717}," only when needed",{"type":40,"tag":2834,"props":3719,"children":3720},{},[3721,3744],{"type":40,"tag":2876,"props":3722,"children":3723},{},[3724,3726,3731,3733,3738,3739],{"type":46,"value":3725},"Missing ",{"type":40,"tag":275,"props":3727,"children":3729},{"className":3728},[],[3730],{"type":46,"value":1943},{"type":46,"value":3732}," for a ",{"type":40,"tag":275,"props":3734,"children":3736},{"className":3735},[],[3737],{"type":46,"value":1927},{"type":46,"value":1929},{"type":40,"tag":275,"props":3740,"children":3742},{"className":3741},[],[3743],{"type":46,"value":1935},{"type":40,"tag":2876,"props":3745,"children":3746},{},[3747],{"type":46,"value":3748},"Include all model dependencies to avoid \"node not found\" errors",{"type":40,"tag":2834,"props":3750,"children":3751},{},[3752,3757],{"type":40,"tag":2876,"props":3753,"children":3754},{},[3755],{"type":46,"value":3756},"Testing Python models or snapshots",{"type":40,"tag":2876,"props":3758,"children":3759},{},[3760],{"type":46,"value":3761},"Unit tests only support SQL models",{"type":40,"tag":3763,"props":3764,"children":3765},"style",{},[3766],{"type":46,"value":3767},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3769,"total":1089},[3770,3776,3795,3808,3822,3839,3851,3866,3880,3892,3904,3915],{"slug":4,"name":4,"fn":5,"description":6,"org":3771,"tags":3772,"stars":21,"repoUrl":22,"updatedAt":23},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3773,3774,3775],{"name":17,"slug":17,"type":15},{"name":19,"slug":20,"type":15},{"name":13,"slug":14,"type":15},{"slug":3777,"name":3777,"fn":3778,"description":3779,"org":3780,"tags":3781,"stars":21,"repoUrl":22,"updatedAt":3794},"answering-natural-language-questions-with-dbt","answer business questions using dbt Semantic Layer","Writes and executes SQL queries against the data warehouse using dbt's Semantic Layer or ad-hoc SQL to answer business questions. Use when a user asks about analytics, metrics, KPIs, or data (e.g., \"What were total sales last quarter?\", \"Show me top customers by revenue\"). NOT for validating, testing, or building dbt models during development.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3782,3785,3788,3789,3792],{"name":3783,"slug":3784,"type":15},"Analytics","analytics",{"name":3786,"slug":3787,"type":15},"Data Analysis","data-analysis",{"name":17,"slug":17,"type":15},{"name":3790,"slug":3791,"type":15},"Metrics","metrics",{"name":3793,"slug":869,"type":15},"SQL","2026-04-06T18:09:07.651959",{"slug":3796,"name":3796,"fn":3797,"description":3798,"org":3799,"tags":3800,"stars":21,"repoUrl":22,"updatedAt":3807},"building-dbt-semantic-layer","build dbt Semantic Layer components","Use when creating or modifying dbt Semantic Layer components — semantic models, metrics, dimensions, entities, measures, or time spines. Covers MetricFlow configuration, metric types (simple, derived, cumulative, ratio, conversion), and validation for both latest and legacy YAML specs.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3801,3802,3805,3806],{"name":3783,"slug":3784,"type":15},{"name":3803,"slug":3804,"type":15},"Data Engineering","data-engineering",{"name":17,"slug":17,"type":15},{"name":3790,"slug":3791,"type":15},"2026-07-18T05:12:20.387564",{"slug":3809,"name":3809,"fn":3810,"description":3811,"org":3812,"tags":3813,"stars":21,"repoUrl":22,"updatedAt":3821},"configuring-dbt-mcp-server","configure dbt MCP server","Generates MCP server configuration JSON, resolves authentication setup, and validates server connectivity for dbt. Use when setting up, configuring, or troubleshooting the dbt MCP server for AI tools like Claude Desktop, Claude Code, Cursor, or VS Code.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3814,3817,3818],{"name":3815,"slug":3816,"type":15},"Agent Context","agent-context",{"name":17,"slug":17,"type":15},{"name":3819,"slug":3820,"type":15},"MCP","mcp","2026-04-06T18:09:12.757804",{"slug":3823,"name":3823,"fn":3824,"description":3825,"org":3826,"tags":3827,"stars":21,"repoUrl":22,"updatedAt":3838},"creating-mermaid-dbt-dag","generate Mermaid diagrams of dbt model lineage","Generates a Mermaid flowchart diagram of dbt model lineage using MCP tools, manifest.json, or direct code parsing as fallbacks. Use when visualizing dbt model lineage and dependencies as a Mermaid diagram in markdown format.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3828,3831,3832,3835],{"name":3829,"slug":3830,"type":15},"Data Pipeline","data-pipeline",{"name":17,"slug":17,"type":15},{"name":3833,"slug":3834,"type":15},"Diagrams","diagrams",{"name":3836,"slug":3837,"type":15},"Documentation","documentation","2026-04-06T18:09:15.270247",{"slug":3840,"name":3840,"fn":3841,"description":3842,"org":3843,"tags":3844,"stars":21,"repoUrl":22,"updatedAt":3850},"fetching-dbt-docs","search dbt documentation","Retrieves and searches dbt documentation pages in LLM-friendly markdown format. Use when fetching dbt documentation, looking up dbt features, or answering questions about dbt Cloud, dbt Core, or the dbt Semantic Layer.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3845,3846,3847],{"name":17,"slug":17,"type":15},{"name":3836,"slug":3837,"type":15},{"name":3848,"slug":3849,"type":15},"Reference","reference","2026-04-06T18:09:06.36975",{"slug":3852,"name":3852,"fn":3853,"description":3854,"org":3855,"tags":3856,"stars":21,"repoUrl":22,"updatedAt":3865},"migrating-dbt-core-to-fusion","triage dbt-core to Fusion migration errors","Use when a user needs help triaging dbt-core to Fusion migration errors. Runs dbt-autofix first, then classifies remaining errors into actionable categories (auto-fixable, guided fixes, needs input, blocked).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3857,3858,3859,3862],{"name":3803,"slug":3804,"type":15},{"name":17,"slug":17,"type":15},{"name":3860,"slug":3861,"type":15},"Migration","migration",{"name":3863,"slug":3864,"type":15},"Triage","triage","2026-04-06T18:09:01.250175",{"slug":3867,"name":3867,"fn":3868,"description":3869,"org":3870,"tags":3871,"stars":21,"repoUrl":22,"updatedAt":3879},"migrating-dbt-project-across-platforms","migrate dbt projects across data platforms","Use when migrating a dbt project from one data platform or data warehouse to another (e.g., Snowflake to Databricks, Databricks to Snowflake) using dbt Fusion's real-time compilation to identify and fix SQL dialect differences.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3872,3873,3876,3877,3878],{"name":3803,"slug":3804,"type":15},{"name":3874,"slug":3875,"type":15},"Database","database",{"name":17,"slug":17,"type":15},{"name":3860,"slug":3861,"type":15},{"name":3793,"slug":869,"type":15},"2026-04-06T18:09:02.513828",{"slug":3881,"name":3881,"fn":3882,"description":3883,"org":3884,"tags":3885,"stars":21,"repoUrl":22,"updatedAt":3891},"running-dbt-commands","run dbt CLI commands","Formats and executes dbt CLI commands, selects the correct dbt executable, and structures command parameters. Use when running models, tests, builds, compiles, or show queries via dbt CLI. Use when unsure which dbt executable to use or how to format command parameters.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3886,3889,3890],{"name":3887,"slug":3888,"type":15},"CLI","cli",{"name":3803,"slug":3804,"type":15},{"name":17,"slug":17,"type":15},"2026-04-06T18:09:03.791122",{"slug":3893,"name":3893,"fn":3894,"description":3895,"org":3896,"tags":3897,"stars":21,"repoUrl":22,"updatedAt":3903},"troubleshooting-dbt-job-errors","troubleshoot dbt job errors","Diagnoses dbt Cloud\u002Fplatform job failures by analyzing run logs, querying the Admin API, reviewing git history, and investigating data issues. Use when a dbt Cloud\u002Fplatform job fails and you need to diagnose the root cause, especially when error messages are unclear or when intermittent failures occur. Do not use for local dbt development errors.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3898,3899,3900],{"name":3829,"slug":3830,"type":15},{"name":17,"slug":17,"type":15},{"name":3901,"slug":3902,"type":15},"Debugging","debugging","2026-04-06T18:09:05.065669",{"slug":3905,"name":3905,"fn":3906,"description":3907,"org":3908,"tags":3909,"stars":21,"repoUrl":22,"updatedAt":3914},"using-dbt-for-analytics-engineering","build dbt models and tests","Builds and modifies dbt models, writes SQL transformations using ref() and source(), creates tests, and validates results with dbt show. Use when doing any dbt work - building or modifying models, debugging errors, exploring unfamiliar data sources, writing tests, or evaluating impact of changes.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3910,3911,3912,3913],{"name":3783,"slug":3784,"type":15},{"name":3803,"slug":3804,"type":15},{"name":17,"slug":17,"type":15},{"name":3793,"slug":869,"type":15},"2026-04-06T18:09:11.455851",{"slug":3916,"name":3916,"fn":3917,"description":3918,"org":3919,"tags":3920,"stars":21,"repoUrl":22,"updatedAt":3927},"using-dbt-state","configure and optimize dbt state","Use when a user is enabling, configuring, optimizing, or debugging dbt State (the server-backed reuse mechanism that clones or skips nodes instead of rebuilding them). Use when they conflate dbt State with the `state:modified` selector or `--state` deferral. Use when asked about models rebuilding unexpectedly, views with `select *` rebuilding, volatile SQL (`current_timestamp()`, `random()`) rebuilding or not, cross-developer cloning, lag_tolerance.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3921,3922,3923,3924],{"name":3803,"slug":3804,"type":15},{"name":3829,"slug":3830,"type":15},{"name":17,"slug":17,"type":15},{"name":3925,"slug":3926,"type":15},"Performance","performance","2026-06-25T07:12:16.623154",{"items":3929,"total":1054},[3930,3936,3944,3951,3957,3964,3970],{"slug":4,"name":4,"fn":5,"description":6,"org":3931,"tags":3932,"stars":21,"repoUrl":22,"updatedAt":23},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3933,3934,3935],{"name":17,"slug":17,"type":15},{"name":19,"slug":20,"type":15},{"name":13,"slug":14,"type":15},{"slug":3777,"name":3777,"fn":3778,"description":3779,"org":3937,"tags":3938,"stars":21,"repoUrl":22,"updatedAt":3794},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3939,3940,3941,3942,3943],{"name":3783,"slug":3784,"type":15},{"name":3786,"slug":3787,"type":15},{"name":17,"slug":17,"type":15},{"name":3790,"slug":3791,"type":15},{"name":3793,"slug":869,"type":15},{"slug":3796,"name":3796,"fn":3797,"description":3798,"org":3945,"tags":3946,"stars":21,"repoUrl":22,"updatedAt":3807},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3947,3948,3949,3950],{"name":3783,"slug":3784,"type":15},{"name":3803,"slug":3804,"type":15},{"name":17,"slug":17,"type":15},{"name":3790,"slug":3791,"type":15},{"slug":3809,"name":3809,"fn":3810,"description":3811,"org":3952,"tags":3953,"stars":21,"repoUrl":22,"updatedAt":3821},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3954,3955,3956],{"name":3815,"slug":3816,"type":15},{"name":17,"slug":17,"type":15},{"name":3819,"slug":3820,"type":15},{"slug":3823,"name":3823,"fn":3824,"description":3825,"org":3958,"tags":3959,"stars":21,"repoUrl":22,"updatedAt":3838},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3960,3961,3962,3963],{"name":3829,"slug":3830,"type":15},{"name":17,"slug":17,"type":15},{"name":3833,"slug":3834,"type":15},{"name":3836,"slug":3837,"type":15},{"slug":3840,"name":3840,"fn":3841,"description":3842,"org":3965,"tags":3966,"stars":21,"repoUrl":22,"updatedAt":3850},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3967,3968,3969],{"name":17,"slug":17,"type":15},{"name":3836,"slug":3837,"type":15},{"name":3848,"slug":3849,"type":15},{"slug":3852,"name":3852,"fn":3853,"description":3854,"org":3971,"tags":3972,"stars":21,"repoUrl":22,"updatedAt":3865},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3973,3974,3975,3976],{"name":3803,"slug":3804,"type":15},{"name":17,"slug":17,"type":15},{"name":3860,"slug":3861,"type":15},{"name":3863,"slug":3864,"type":15}]