This is probably more applicable for the dbt Slack...
# getting-started
j
This is probably more applicable for the dbt Slack community but I'm going to try here anyways. I'm confused about the models not needing to be declared in the
.yml
with schemas etc. Seems that if I just drop my
.sql
files in the
models
folder the views are created. So far so good. I want to integrate it with Metabase, and it seems
dbt-metabase
needs the models to be properly declared in the YaML files... But I wonder; why introduce this source of inconsistency? My `SELECT`s may very well not have the same schema as whatever I declare in
models.yml
. To me the query should be enough declaration in itself, shouldn't it?
m
It sounds like you are hardcoding the schema in the model SQL files, rather than using the
ref
macro.
why introduce this source of inconsistency? My `SELECT`s may very well not have the same schema as whatever I declare in
models.yml
.
If you use the
ref
macro in your SQL models, there’s no inconsistency. You can define the schema just once (e.g., in your
dbt_project.yml
file). This is a far better approach because it supports workflows like a developer using a differenct schema for local testing than for production - easy to configure that when it’s defined in just one place rather than being hardcoded in many.
1
j
The set of selected columns in my
.sql
file SHOULD be the same as in
models.yml
but as far as I can tell that's not enforced