Closed joaocrebelo closed 4 months ago
What you raised it's not a bug.
You need to overwrite the macro generate_schema_name
to have the behavior that you expect, and it's the same in other adapters. dbt-athena doesn't have the knowledge of overwriting the schemas, this behaviour is implemented in dbt-core.
If you look the original implementation:
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if custom_schema_name is none -%}
{{ default_schema }}
{%- else -%}
{{ default_schema }}_{{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}
you can understsand why default_custom_schema.my_model
is produced in your case.
Pretty much you have a custom schema in your project configuration, that is concatenated with your default schema in the global profiles.
Implementing a macro that does what you need it's the recommended approach to tackle this.
You are totally right.
The example I checked when I faced the issue was already an overwrite of the macro generate_schema_name
that avoided the concatenation and I wrongly assumed it was the original implementation š¤¦āāļø
Thanks for your help and the fast response š
Is this a new bug in dbt-athena?
Current Behavior
The
schema
property is mandatory when configuring a profile viaprofile.yml
. This property, however, should be overwritable by the models definition indbt_project.yml
, which would allow targeting different Glue databases (aka "schemas") in the same project.However, at the moment, setting the schema property in profile.yml and dbt_project.yml is appending both and generating a new database which is not supposed to exist.
Here's an example of this behavior that I tested, assuming a model named
my_model
inside a folder namedmy_folder
Consider the following snippet of
profiles.yml
And the following snippet of
dbt_profiles.yml
Produces a model under:
default_custom_schema.my_model
Additional Tests
dbt_profiles.yml
without the + sign also produces the same resultprofiles.yml
with an empty string produces a database starting with an underscore like_custom_schema.my_model
Expected Behavior
As with other adapters, overriding the configuration of the
schema
property indbt_project.yml
for a specific group of models should apply to those models and fully override the default setting fromprofiles.yml
In the example above, the model should be created under
custom_schema.my_model
Steps To Reproduce
config.yml
with a valid schema, likedefault
dbt_profile.yml
with a schema under themodels
key different from the abovedbt run
, see cli output and created objects for reported issue.Environment
Additional Context
No response