Tomme / dbt-athena

The athena adapter plugin for dbt (https://getdbt.com)
Apache License 2.0
142 stars 79 forks source link

Schema getting appended #28

Closed prabavnc closed 3 years ago

prabavnc commented 3 years ago

Hi @Tomme ,

Thanks for dbt-athena , it works great.

I am trying to give a different schema than whats specified in profiles.yml, the model gets created in a schema completely different . Examples below

profiles.yml

default:
  outputs:
    dev_test:
      type: athena
      s3_staging_dir: s3://test_bucket/
      region_name: eu-west-1
      schema: default
      database: awsdatacatalog

dbt_project.yml

models:
  first_project:
    staging:
      +materialized: table
      +schema: test

Resulting table is getting created in default_test, basically its getting concatenating the schemas from both with an underscore

19:17:53 | Concurrency: 1 threads (target='dev_test')
19:17:53 |
19:17:53 | 1 of 1 START table model default_test.test_dbt....................... [RUN]
19:17:57 | 1 of 1 OK created table model default_test.test_dbt.................. [OK -1 in 3.96s]
19:17:57 |
19:17:57 | Finished running 1 table model in 51.26s.

Is there a way to override the schema with the one under dbt_project.yml Any help highly appreciated. Thanks in advance

Tomme commented 3 years ago

Hey @prabavnc,

I'm glad you are finding dbt-athena useful!

Regarding your question/issue, this is expected dbt behaviour and you can find more about it here: Using custom schemas

If you wish to change this behaviour you will need to override the generate_schema_name macro (dbt will always use the macro in your dbt project instead of the default macro), of which the source can be seen here: How does dbt generate a model's schema name?

I hope this helps, and I will leave this open for a while in case you have any any follow up questions.