CertSafari
    DBT Analytics Engineering· Lessons

    Domain 1 · Lesson 4/31

    dbt show and dbt docs: previewing results and generating documentation

    Using commands such as build, run, test, docs, show, snapshot, and seed

    7 min read
    3.23% of exam
    2 sources
    Published 12 Oct 2026
    Docs as of 12 Oct 2026

    What you will be able to do

    • Preview a model, a failing test or an inline query with dbt show, and explain what it does and doesn't read
    • Use --limit, --inline and --output json appropriately
    • Tell apart dbt docs generate, dbt docs serve and the --write-catalog flag

    1.dbt show compiles and previews a single node

    Sometimes you need to see what a query returns without rebuilding anything. dbt show compiles the dbt-SQL of one model, test or analysis, or an ad-hoc query passed with --inline. It runs the query against the warehouse and prints the result in the terminal. Only one node can be selected: selector methods and graph operators that would pick several nodes are not used. Python models are not supported.

    Previewing the staging model stg_orderstext
    dbt show --select "stg_orders"
    21:17:38 Running with dbt=1.5.0-b5
    21:17:38 Found 5 models, 20 tests, 0 snapshots, 0 analyses, 425 macros, 0 operations, 3 seed files, 0 sources, 0 exposures, 0 metrics, 0 groups
    21:17:38
    21:17:38 Concurrency: 24 threads (target='dev')
    21:17:38
    21:17:38 Previewing node 'stg_orders' :
    | order_id | customer_id | order_date | status    |
    |----------+-------------+------------+--------   |
    | 1        |           1 | 2023-01-01 | returned  |
    | 2        |           3 | 2023-01-02 | completed |
    | 3        |          94 | 2023-01-03 | completed |
    | 4        |          50 | 2023-01-04 | completed |
    | 5        |          64 | 2023-01-05 | completed |

    Two behaviours surprise people. First, previewing a model always compiles its query from source and runs that. It never selects from the table already built in the warehouse, even right after dbt run. The preview therefore shows what your current code returns, which may differ from the table in the warehouse.

    Second, five rows is only the default, and --limit n does more than trim the display. dbt wraps the model's query in a subquery or CTE and adds a SQL limit n, so the warehouse only processes and returns that many rows. That is what keeps previews of large models fast.

    Checkpoint 1 of 4· Check yourself

    You ran dbt run on fct_orders yesterday and edited its SQL this morning without rerunning it. What does dbt show --select "fct_orders" preview?

    Sources1

    2.Debugging test failures and ad-hoc queries with dbt show

    dbt show is also the quickest way to see why a test failed. After a dbt build reports a failing unique test, select that test by name. The preview shows the offending rows: here, the duplicated value and how many times it appears.

    Previewing the rows behind a failing unique testtext
    $ dbt show -s "unique_my_model_with_duplicates_id"
    13:22:53 Running with dbt=1.5.0
    13:22:53 Found 4 models, 2 tests, 0 snapshots, 0 analyses, 309 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics, 0 groups
    13:22:53
    13:22:53 Concurrency: 5 threads (target='dev')
    13:22:53
    13:22:53 Previewing node 'unique_my_model_with_duplicates_id':
    | unique_field | n_records |
    | ------------ | --------- |
    |            1 |         2 |

    --inline runs any SQL you pass it, Jinja such as ref() included. That freedom has a cost: dbt can't guarantee the query won't modify the warehouse. To rule out changes, run it under a profile or role with read-only permissions, which are managed in the warehouse itself, for example --profile my-read-only-profile. Previews of a selected node only appear in dbt's logs and the terminal. They aren't built in the warehouse or stored in any dbt file.

    For scripts and automation, --output json returns the preview as JSON instead of the human-readable table. Add --log-format json as well to make the whole terminal output, logs included, machine-readable.

    Checkpoint 2 of 4· Check yourself

    An analyst wants to run ad-hoc queries through dbt show --inline and must not be able to change any data. What guarantees that?

    Checkpoint 3 of 4· Exam question

    Within a single `dbt build` invocation, a `not_null` test with default severity fails on `stg_orders`. Which of the following statements correctly describe what happens next in that run? (Select all that apply.)(Select 3)

    Sources1

    3.dbt docs generate builds the site; dbt docs serve previews it

    Documentation has its own pair of commands. dbt docs generate compiles the project, writes the index and exports a documentation site in one step. dbt docs serve previews that site locally, and generates it first if it is missing or older than the index. By default the site goes into target/, with index.html and an assets/ folder. --output-dir writes a self-contained copy somewhere else. Because the site is just static files, any static file host can serve it, such as S3, GitHub Pages or Netlify.

    Building the browsable site is a different job from producing metadata. The --write-catalog flag, accepted by dbt build, dbt run, dbt parse and dbt compile, writes catalog.json. That file holds metadata about the tables and views your models produce. The flag doesn't build a documentation site.

    --write-catalog versus dbt docs generate
    Aspect--write-catalog flagdbt docs generate command
    What it producescatalog.json, plus the artifacts the command already generatesindex.html, assets/, and the index files
    What it's forMetadata for Catalog and the metadata APIsA static site you can preview with dbt docs serve or host anywhere

    In the dbt platform, the self-hosted site is replaced by Catalog, which job runs keep up to date. If a job includes dbt docs generate as a step, dbt runs dbt compile --write-catalog instead and points you to Catalog. No index.html is produced.

    Checkpoint 4 of 4· Match them up

    Match each docs command or flag to what it does.

    Tap a term, then the definition that fits it.

    Sources2

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.dbt show reads the table that dbt run last built, so it is a cheap way to inspect warehouse contents.Why is that wrong?

      dbt show compiles the model from source and runs that query every time. It never selects from the existing table.

      Covered in dbt show compiles and previews a single node

    2. 2.--limit only changes how many rows dbt prints; the warehouse still processes the full query.Why is that wrong?

      --limit adds a SQL limit to the query itself, so the warehouse only processes and returns that many rows.

      Covered in dbt show compiles and previews a single node

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Only selecting a single node is supported.”
      ↩︎ dbt show compiles and previews a single node
      “dbt show does not support Python (dbt-py) models.”
      ↩︎ dbt show compiles and previews a single node
      “By default, dbt show will display the first 5 rows from the query result.”
      ↩︎ dbt show compiles and previews a single node
      “The --limit flag modifies the underlying SQL and not just the number of rows displayed.”
      ↩︎ dbt show compiles and previews a single node
      “you can quickly preview the test failures right in the terminal, to find values of id that are duplicated”
      ↩︎ Debugging test failures and ad-hoc queries with dbt show
      “The --inline flags enables you to run ad-hoc SQL, which means dbt can't ensure the query doesn't modify the data warehouse.”
      ↩︎ Debugging test failures and ad-hoc queries with dbt show
      “The --output json flag returns dbt show results in JSON format instead of the default human-readable output”
      ↩︎ Debugging test failures and ad-hoc queries with dbt show
      “If previewing a model, dbt will always compile and run the compiled query from source.”
      ↩︎ Exam trap 1
      “The --limit flag modifies the underlying SQL and not just the number of rows displayed.”
      ↩︎ Exam trap 2
      “It will not select from the already-materialized database relation, even if you've just run the model.”
      ↩︎ Checkpoint
      “To ensure no changes are made, use a profile or role with read-only permissions”
      ↩︎ Checkpoint
    2. 2.
      “Run dbt docs generate to build the site, then dbt docs serve to preview it.”
      ↩︎ dbt docs generate builds the site; dbt docs serve previews it
      “Use --output-dir to write a self-contained copy of the site to a different directory”
      ↩︎ dbt docs generate builds the site; dbt docs serve previews it
      “It focuses solely on metadata hydration and does not build the documentation site”
      ↩︎ dbt docs generate builds the site; dbt docs serve previews it
      “If you add dbt docs generate as a job step, dbt automatically runs dbt compile --write-catalog instead and directs you to Catalog.”
      ↩︎ dbt docs generate builds the site; dbt docs serve previews it
      “Both write artifacts, but only dbt docs generate builds a documentation site you can view in a browser.”
      ↩︎ Checkpoint

    Spotted a mistake, or was something unclear? Tell us.