dbt (data build tool) interview questions

getDbt

26. Can I store my models in a directory other than the `models` directory in my project?
By default, dbt expects your seed files to be located in the models subdirectory of your project.
To change this, update the source-paths configuration in your dbt_project.yml file, like so:
dbt_project.yml
source-paths: [“transformations”]

27. Can I connect my dbt project to two databases?
It depends on the warehouse used in your tech stack.
dbt projects connecting to warehouses like Snowflake or Bigquery—these empower one set of credentials to draw from all datasets or ‘projects’ available to an account—are sometimes said to connect to more than one database.
dbt projects connecting to warehouses like Redshift and Postgres—these tie one set of credentials to one database—are said to connect to one database only.


28. Do I need to create my target schema before running dbt?
Nope. dbt will check if the schema exists when it runs. If the schema does not exist, dbt will create it for you.

29. How do I create dependencies between models?
When you use the ref function, dbt automatically infers the dependencies between models.

30. How do I define a column type?
Your warehouse’s SQL engine automatically assigns a datatype to every column, whether it’s found in a source or model. To force SQL to treat a columns a certain datatype, use cast functions:
select
cast(order_id as integer),
cast(order_price as double(6,2)) — a more generic way of doing type conversion
from {{ ref(‘stg_orders’) }}

Author: user

Leave a Reply