question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overriding the database in the dbt_project file does not work

See original GitHub issue

When I override the database to something different than the database configured in the profile, the CLI says it’s going to built into the override database, but it’s executed on the profile database.

Example profiles.xml:

datawarehouse:
  target: development
  outputs:
    development:
      type: sqlserver
      driver: 'ODBC Driver 17 for SQL Server'
      server: bisql
      port: 1433
      windows_login: True
      database: Test
      schema: test
      threads: 4

example dbt_project.yml:

...
models:
  my_datawarehouse:
    materialized: view
    products:
      +database: ProductsModels
      +schema: ProductsModels

When ran, the CLI says “created view model ProductsModels.ProductsModels.Metrics…” but in reality it’s created in Test.ProductsModels.Metrics

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:21

github_iconTop GitHub Comments

1reaction
CMRobbiecommented, Nov 19, 2020

Ah, sorry… I changed the materialization to table so it’s obviously using sqlserver__create_table_as now.

1reaction
CMRobbiecommented, Nov 19, 2020

I’m all for an adventure! 😃 And I’m also happy to wait to next week.

I added a file called sqlserver_create_view_as.sql in my macros folder with this as content:

{% macro sqlserver__create_view_as(relation, sql) -%}
  create view {{ relation.schema }}.{{ relation.identifier }} as
    --THIS IS A TEST
    {{ sql }}
{% endmacro %}

But I have the impression it’s not using it at all, because it’s not logging the “THIS IS A TEST” anywhere. Or maybe I did not understand you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom databases - dbt Developer Hub
To override dbt's database name generation, create a macro named generate_database_name in your own dbt project. The generate_database_name ...
Read more >
Deploy to custom schemas & override dbt defaults - YouTube
By default, all dbt models are built in the target schema specified in your profiles.yml file. In dbt projects with a lot of...
Read more >
dbt depends on a source not found - Stack Overflow
This is due to the automate.metrics table missing from the database (either the dbt project's target database or a different database on the ......
Read more >
Anatomy of a dbt project - Towards Data Science
For analysts not from a technical background, working with dbt can be ... This file contains the database connection that dbt will use...
Read more >
dbt Guide - GitLab
dbt, short for data build tool, is an open source project for managing data ... There is no need to restart the container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found