DBT DBT Sources & Seeds 1 — Questions and Answers
Question 1: In dbt, what is a 'source' used for?
- Defining output tables
- Declaring raw database tables that dbt did not create (Correct answer)
- Storing lookup data in CSV files
- Triggering external pipelines
Correct answer: Declaring raw database tables that dbt did not create
Sources let you declare raw tables loaded by external tools so dbt can reference, document, and test them.
Question 2: Which dbt function is used to reference a source table inside a model SQL file?
- {{ ref('source_name') }}
- {{ source('schema', 'table') }} (Correct answer)
- {{ model('schema.table') }}
- {{ from_source('table') }}
Correct answer: {{ source('schema', 'table') }}
The `{{ source('source_name', 'table_name') }}` function resolves to the fully qualified table path defined in sources.yml.
Question 3: What dbt command checks whether source tables are fresh based on a loaded_at_field?
- dbt test --source-freshness
- dbt source freshness (Correct answer)
- dbt check sources
- dbt run --freshness
Correct answer: dbt source freshness
`dbt source freshness` queries the `loaded_at_field` of each source and compares it against the defined freshness thresholds.
Question 4: Which YAML key defines how old source data can be before dbt warns about staleness?
- max_age
- freshness (Correct answer)
- staleness
- loaded_at_threshold
Correct answer: freshness
The `freshness:` block under a source (or table) defines `warn_after` and `error_after` thresholds for data staleness.
Question 5: What is a dbt seed?
- A random data generator for testing
- A CSV file loaded into the warehouse as a table (Correct answer)
- An initial schema migration script
- A template for new models
Correct answer: A CSV file loaded into the warehouse as a table
Seeds are CSV files in the `seeds/` directory that `dbt seed` loads into database tables, useful for static lookup data.
Question 6: Which dbt command loads seed CSV files into the target database?
- dbt load
- dbt import
- dbt seed (Correct answer)
- dbt upload
Correct answer: dbt seed
`dbt seed` reads CSV files from the seeds/ directory and creates or replaces the corresponding tables in the warehouse.
In dbt, what is a 'source' used for?