Skip to content

Sampling a model run before a full build

The --sample flag puts a dbt invocation into 'sample mode,' filtering input data to a limited, relative time window so developers can build or test models faster during local development and CI without processing full production volumes. It uses each model's configured event_time (the same field used for microbatch incremental models) to determine which rows to include.

1 · Learn the must-know

  • Sample mode filters rows based on the model's (and its sources'/seeds') configured event_time column; models without event_time set are not sampled and run against their full dataset.
  • You invoke it as part of a normal invocation, e.g. dbt run --sample=<relative_time_range> or dbt build --sample=<relative_time_range>, restricting data to that recent window relative to the current run time.
  • Sample mode is meant for development and CI workflows to speed up iteration, not for production runs, since it intentionally works on incomplete data.
  • Because upstream data is truncated, downstream tests (row counts, uniqueness, referential integrity, etc.) can behave differently or fail compared to running against full data.
  • Sample mode combines with normal node selection (--select/--exclude), so you can scope both which models run and how much data each processes for fast local cycles.
  • It only affects what data is read/processed during that invocation—it does not modify or truncate your actual source tables or persist any sampling logic into the model's compiled SQL.

2 · Check your understanding

Check this objectiveFree · always available

What is the primary purpose of running dbt build with the --sample flag?

Your objective map0 tried · 0 answered correctly · 31 untouched

What you have tried across dbt Analytics Engineering's objectives, not a readiness score.

Developing and optimizing dbt models45.16% of the exam*0 of 14 tried
Managing dbt models governance9.68% of the exam*0 of 3 tried
Debugging data modeling errors16.13% of the exam*0 of 5 tried
Troubleshooting and optimizing dbt pipelines6.45% of the exam*0 of 2 tried
Implementing dbt tests9.68% of the exam*0 of 3 tried
Implementing and maintaining external dependencies6.45% of the exam*0 of 2 tried
Leveraging the dbt state6.45% of the exam*0 of 2 tried

* Our estimate. dbt Labs publishes no section weights.

3 · Keep going