-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rationalize quoting configs + properties #2986
Comments
|
|
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days. |
I still care about this one :) |
I really care about this one! All I want to do is ensure that dbt quotes all column names that I reference or create (via sql selects) and my only option right now is to explicitly define every single column in every single model. I've not actually tried doing that but I suspect that will only quote OUTPUT columns in a model, not columns that I select during my sql. |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Here's a couple other issues related to quoting (specifically about applying proper escaping prior to quoting):
|
this is in adapters now, but also adding that seeds are not consistently quoted and it would be cool if they were also a config option under the proposed |
See also:
|
Adding ~quoting related issue for snapshots. #10356 cc: @jeremyyeo |
Hello, everyone. (@dbeatty10 Apologies if I mentioned the wrong person.) I have encountered the following problem, and I believe it can be resolved with some changes outlined in this issue. About the problemWhen using a case-sensitive database like Snowflake, it becomes challenging to use a mix of ASCII-only model names and non-ASCII model names. Example: models
└ only_ascii_char.sql
└ non_ascii_chars.sql To run the model "non_ascii_chars," the identifier needs to be enclosed in double quotes. The only current option is the project-level quoting parameter, so I configure it as follows: # dbt_project.yml
quoting:
identifier: true However, this causes even the only_ascii_char model to have its identifier enclosed in quotes after compilation, which means that in Snowflake, the table can only be used in lowercase: create or replace table database.schema."only_ascii_char" ... When attempting to avoid this by using an alias, a different issue arises: # non_ascii_chars.yml
models:
- name: non_ascii_chars
alias: '"non_ascii_chars"' At runtime, this results in an error due to ambiguous model name detection: Compilation Error in model non_ascii_chars (models/non_ascii_chars.sql)
When searching for a relation, dbt found an approximate match. Instead of gussing
which relation to use, dbt will move on. Please delete database.schema."non_ascii_chars", or rename it to be less ambiguous.
Searched for : database.schema."non_ascii_chars"
Found: "database"."schema"."non_ascii_chars" For people like myself who use a non-ASCII native language, it’s important to provide models in their business language (i.e., the ubiquitous language). I would like to contribute to adding this feature! Where would be the best place to start tackling this issue? As outlined in this linked issue, is it necessary to consolidate or organize the quote options? (I have also heard that non-ASCII characters cannot be used in unit tests. That may also be related to this one, however, I believe this should be addressed in a separate issue, so I will create a new one for that.) |
Thanks for reaching out and providing such a nice example @t0momi219 ! It sounds like your goal has two parts:
So you're seeking a way to configure Does that sound correct? |
Hi @dbeatty10,
Exactly. Being able to override the quoting setting specified at the project level on a per-model basis would increase flexibility and be ideal. |
From @jtcohen6:
@t0momi219 Thanks for you interest in working on this! This feature is tricky enough that we'd need to invest a significant amount of time and effort regardless if a community member works on it or if we do it ourselves (see below for some details). In those cases, we'd want to do it ourselves rather than accept community contributions. Unfortunately, this isn't a priority for us in the near-term, so we don't plan on tackling it anytime soon. |
Describe the feature
Picks up from issues like #2468 and #2975, which are narrower in scope and offer more straightforward near-term fixes
quoting
when configuring database/schema/identifier names, but thenquote
when describing properties of column names?quote_columns
, which is a seed-only config item that lives on its own level but surely belongs inside thequoting
config item (or will it bequote
?!) ascolumns
quoted
, which while not itself a config, returns the quoted version of a column name from a Relation based on the configs aboveInstead, we should have a single config/property, and I think it should be
quote
. This would take over from the current project-levelquoting
config:The
quote: {columns: true}
would also replacequote_columns
as a bespoke config for seeds. If that config is specified indbt_project.yml
, it can be superseded by:quote: {}
inside theconfig()
block for a specific moelquote: true|false
set for a specific column inmodels/*.yml
(it's implied that this really meansquote: {column: true}
model
can set itsquote: {}
config withinmodels/*.yml
, tooIf
quote
is not set, it falls back to the default behavior of the adapter plugin, which also sets the character used for quoting (almost always"
or`
).Questions
Here's what we have in the docs FAQs today for sources:
Should sources start respecting project-level
quote
settings? Or they continue to act independently, but we should enable turning this config-property on or off for all sources indbt_project.yml
:Describe alternatives you've considered
Retaining all of these configs/properties/adapter methods and documenting them exceptionally well so as to avoid confusion
Additional context
This isn't specific to any one database, though it is likely most helpful on databases that support special characters if quoted (Postgres, Redshift) or are particularly sensitive to quoting (Snowflake).
There's a round-up of all the known documentation related to quoting in dbt-labs/docs.getdbt.com#3518.
The text was updated successfully, but these errors were encountered: