quoting
quoting:database: true | falseschema: true | falseidentifier: true | false
Definition
Optionally configure whether dbt should quote databases, schemas, and identifiers when:
- creating relations (tables/views)
- resolving a
ref
function to a direct relation reference
BigQuery Terminology
Note that for BigQuery quoting configuration, database
and schema
should be used here, though these configs will apply to project
and dataset
names respectively
Default
The default values vary by database.
- Default
- Snowflake
For most adapters, quoting is set to true
by default.
This is because creating relations with quoted identifiers does not inhibit the ability to select from them, and quoting allows you to use reserved words as object names (though that should probably be avoided)
quoting:database: trueschema: trueidentifier: true
Examples
Set quoting to false
for a project:
quoting:database: falseschema: falseidentifier: false
dbt will then create relations without quotes:
create table analytics.dbt_alice.dim_customers
Recommendation
Snowflake
Set all quoting configs to False
. This means that you cannot use reserved words as identifiers, however it's usually a good idea to avoid these reserved words anyway.
Explanation:
Whereas most databases will lowercase unquoted identifiers, Snowflake will uppercase unquoted identifiers. If a model name is lowercased and quoted, then it cannot be referred to without quotes! Check out the example below for more information.
/*You can run the following queries against your databaseto build an intuition for how quoting works on Snowflake.*/-- This is the output of an example `orders.sql` model with quoting enabledcreate table "analytics"."orders" as (select 1 as id);/*These queries WILL NOT work! Since the table above was created with quotes,Snowflake created the orders table with a lowercase schema and identifier.Since unquoted identifiers are automatically uppercased, both of thefollowing queries are equivalent, and neither will work correctly.*/select * from analytics.orders;select * from ANALYTICS.ORDERS;/*To query this table, you'll need to quote the schema and table. Thisquery should indeed complete without error.*/select * from "analytics"."orders";/*To avoid this quoting madness, you can disable quoting for schemasand identifiers in your dbt_project.yml file. This means that youwon't be able to use reserved words as model names, but you probablyshouldn't be doing that anyway! Assuming schema and identifier quoting isdisabled, the following query would indeed work:*/select * from analytics.orders;
Other warehouses
Leave the default values for your warehouse.