dbt test (Intermediate)
30 questions · 35 minutes · Free
dbt models, sources, tests and docs, incremental models, macros and deployment.
What it covers
- dbt models and sources
- dbt tests
- Incremental models
- Jinja and dbt macros
- dbt deployment and docs
Interview format
- Questions: 30 questions — 18 multiple choice, 9 multi-answer, 3 predict-the-output
- Time: 35 minutes, timed from the first question
- Difficulty: Intermediate
- Skill area: Data
- Price: Free
Sample questions
5 sample questions from the dbt test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
Which of the following best describes how Jinja templates are compiled during the rendering process in dbt?
- Jinja templates are stored as compiled files in the database for later use.
- Jinja templates are compiled into Python bytecode for faster execution.
- Jinja templates are compiled into a different language for performance optimization.
- Jinja templates are compiled into SQL for direct execution in the database.
Answer: B. Jinja templates are compiled into Python bytecode for faster execution.
Jinja templates are pre-compiled into Python bytecode during the rendering process, which improves performance by reducing the overhead of parsing templates during each execution. Other options are incorrect because Jinja does not compile templates into SQL, use a different language for compilation, or store compiled templates in the database.
Which dbt feature is the `loaded_at_field` configuration used for?
- incremental model unique key
- model materialisation configuration
- Jinja macro variable scoping
- source freshness checks
Answer: D. source freshness checks
The `loaded_at_field` is used in source freshness checks to determine if data is stale. This is the only scenario where `loaded_at_field` is used, as it is specifically tied to freshness checks for sources in dbt.
How are sources configured and referenced in dbt?
- A source is declared in a `sources.yml` file using the `sources:` configuration block and is referenced via a hard-coded schema.table in SQL models.
- A source is declared in a SQL model using a `source` macro with database, schema, and table details, and is referenced via `{{ source('src', 'table') }}`.
- A source is declared in a SQL model using a `source` macro with database, schema, and table details, and is referenced via a hard-coded schema.table in SQL models.
- A source is declared in YAML using the `sources:` configuration block with database, schema, and table details, and is referenced via `{{ source('src', 'table') }}`.
Answer: D. A source is declared in YAML using the `sources:` configuration block with database, schema, and table details, and is referenced via `{{ source('src', 'table') }}`.
Sources are declared in YAML using the `sources:` configuration block, which defines database, schema, and table details. They are referenced using `{{ source('src', 'table') }}` in SQL models. This ensures proper lineage and environment-specific handling. Other options are incorrect because they either describe a different feature or are not accurate representations of how sources are declared and referenced in dbt.
Which of the following best describes the difference between the `var()` and `env_var()` functions in Jinja, and when you would choose one over the other?
- Both `var()` and `env_var()` behave the same way, allowing you to set a default value if the variable is not defined.
- Neither `var()` nor `env_var()` allows you to set a default value if the variable is not defined.
- The `var()` function returns `None` if the variable is not defined, whereas `env_var()` allows you to set a default value.
- The `var()` function allows you to set a default value if the variable is not defined, whereas `env_var()` will return `None` if the environment variable is not found.
Answer: D. The `var()` function allows you to set a default value if the variable is not defined, whereas `env_var()` will return `None` if the environment variable is not found.
The `var()` function in Jinja allows you to specify a default value for a variable, which is useful when the variable might not be defined in the context. On the other hand, `env_var()` retrieves an environment variable and returns `None` if the variable is not found, which is less forgiving and does not provide a fallback value. Choosing `var()` is preferable when you want to ensure a default value is always available, while `env_var()` is more suitable for cases where the absence of the environment variable is an error condition.
Which of the following is the best option for adding custom content to the sidebar of the dbt documentation site, and why?
- dbt models
- dbt docs custom sidebar
- Markdown files in the docs directory
- dbt tests
Answer: B. dbt docs custom sidebar
The dbt docs custom sidebar is a feature that allows users to add custom content to the sidebar of the dbt documentation site. This is useful for adding links to external resources, team information, or other relevant content that is not directly related to the models or sources in the project. An alternative to the dbt docs custom sidebar is using markdown files directly within the docs directory. However, the custom sidebar provides a more organized and centralized way to add content to the sidebar, making it easier to maintain and update. Markdown files are more suitable for adding content directly within the documentation itself, rather than in the sidebar. Therefore, the dbt docs custom sidebar is the correct answer.
Frequently asked questions
- How many questions are in the dbt test?
- 30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
- What does the dbt test cover?
- dbt models and sources, dbt tests, Incremental models, Jinja and dbt macros, dbt deployment and docs.
- Is the dbt test free?
- Yes. It is free to take with a readyforhires account.
- What level is the dbt test?
- Intermediate, in Data.