In DBT, whenever we deploy the models, the database name gets prefixed to each deployed model in the sql definition in database.
I need to configure the dbt project in a way that it doesn't prefix database name to the deployed models.
In DBT, whenever we deploy the models, the database name gets prefixed to each deployed model in the sql definition in database.
I need to configure the dbt project in a way that it doesn't prefix database name to the deployed models.
On
Do you mean that:
finance.modelname instead of dbname_finance.modelname, orschema.modelname) instead of the three-part name (database.schema.modelname)?If #1, I recommend you read the entire custom schema names docs page, specifically the part about Advanced custom schema configuration
If it's #2, this is a change required at the adapter level. Since you've tagged synapse, I'd wager a guess that you're using Synapse SQL Serverless Pools because I have also encountered the fact that you can't use three-part names in Serverless pools. Last week, I actually made dbt-synapse-serverless a separate adapter from dbt-synapse which in fact disables the three-part name.
You can overwrite the built-in
refmacro. This macro returns aRelationobject, so we can manipulate its output like this:So, from there, all models that use the
reffunction will return theRelationobject without thedatabasespecification.EDIT:
As you requested, here's an example to remove the database name from the sources:
I've worked with sources from different databases, so if you ever get to that case, you might want to edit the macro to offer an option to include the database name, for example:
More details can be found in the official documentation