Quoting for database catalogs, schemas, tables, and columns #3518
Labels
content
Improvements or additions to content
improvement
Use this when an area of the docs needs improvement as it's currently unclear
Contributions
TLDR
database
,schema
, andidentifier
names on a dbt project-wide basis viaquoting
, but not a per-model basis. However,column
names can be configured on a per-model basis viaquote
, but not project-wide.database
,schema
, andidentifier
, andcolumn
names can be configured on a per-source and per-table basis (viaquoting
andquote
), but not project-wide.There are many related pieces in the product documentation, but they aren't linked together (which is the aim of this documentation proposal).
The feature proposal in dbt-labs/dbt-core#2986 aims to unify these 4 levels of quoting into a
quote
config that can be applied hierarchically from project-wide down to the individual resource-level.Link to the page on docs.getdbt.com requiring updates
There are a couple things that are mostly frequently quoted within SQL:
For example, all of the following can be quoted within SQL:
database
/ catalog names (project
in BigQuery)schema
names (dataset
in BigQuery)identifier
names (table / view / etc. names)column
namescolumn
valuesuser
s,role
s,index
es, etc.)We have all of the following documentation, but it rarely refers to each other:
For
database
,schema
, andidentifier
namesquoting
- Configuring quoting in projects (fordatabase
,schema
, andidentifier
)quoting
- Configuring quoting in sources (fordatabase
,schema
, andidentifier
)quoted
method in the Relation class - Applying quoting to relations (fordatabase
,schema
, andidentifier
) (source)as_case_sensitive
in the SnowflakeRelation class (see also: dbt-snowflake dbt-labs/dbt-adapters#714)For
column
namesquote
- Configuring quoting in models forcolumn
namesquote_columns
- Configuring quoting in seed files forcolumn
namesquote_seed_column
- Quote or do not quote the column name of a seed according to thequote_columns
configurationquoted
method in the Column class via Column API - Applying quoting to relation columns forcolumn
namesquote_identifiers
in macros withindbt_utils
(likestar
andpivot
)For
column
valuesquote
withinaccepted_values
- Configuring quoting in data tests for acceptedcolumn
valuesdbt.string_literal
- Applying quoting tocolumn
values in Jinjadbt.escape_single_quotes
- Escaping single quotes withincolumn
values in JinjaFor multiple purposes
adapter.quote
- Applying quoting via the adapter-specific macro to acolumn
name or individual components of a (database
,schema
,identifier
) combo (or even other database objects likeusers
orroles
) (source).quote_as_configured
- Quote or do not quote the given database, schema, or identifier according to thequoting
project configuration.For users / groups / roles in grants
As hinted at in dbt-labs/dbt-postgres#55, we don't have any mechanism to specify that a grant should be quoted. i.e., we don't have a
quote_grants
config.What part(s) of the page would you like to see updated?
It would be an improvement to merely cross-link these different pages so that the first result in a Google search is likely to eventually lead where you want to get.
Additional information
Instigating scenario: dbt-labs/dbt-core#7832
dbt-labs/dbt-core#2986 aims to unify all of these under a single
quote
config/property, but the earliest that might happen is v1.9+, and we'd want to clarify things for users earlier than that as well.The text was updated successfully, but these errors were encountered: