-
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
dbt does not appropriately quote column names for incremental models and seed files. #1847
Comments
Two quick editorial notes:
|
Fix quoting on columns for seeds/incremental models (#1847)
I'm actually running into the same issue, also documented in this SO question. My table is built flawlessly but the incremental runs fail because the engine "uppercases" a column name that's not fully uppercased in my database: The query: {{
config(
materialized='incremental',
unique_key='event_ID'
)
}}
SELECT
{{ dbt_utils.star(from=ref('staging_pg_ahoy_events'), relation_alias='events', prefix='event_') }},
{{ dbt_utils.star(from=ref('staging_pg_ahoy_visits'), relation_alias='visits', prefix='visit_') }}
FROM
{{ ref('staging_pg_ahoy_events') }} AS events
LEFT JOIN {{ ref('staging_pg_ahoy_visits') }} AS visits ON events.visit_id = visits.id
{% if is_incremental() %}
WHERE "event_ID" >= (SELECT max("event_ID") FROM {{ this }})
{% endif %} The error:
The only fix I've found so far is by upper casing the prefix via |
Experiencing the same |
@dvd-p would you be able to open a new issue please? It just would make it easier to look at this with your specific scenario and details to make sure we are able to reproduce the error correctly |
Came here as this bug is still active using the Snowflake adapter. I did have success by implementing this workaround in the config (using @coisnepe example). |
Describe the bug
dbt doesn't cooperate with lower- or mixed-case column names on Snowflake, regardless of quoting settings currently. While sometimes this "just works", there are two areas of the product that I've run into in testing that exhibit issues when mixed casing is used:
dbt seed
does not respect quotes in column names inside of a CSV file, creating the columns as unquoted.merge
anddelete+insert
) list out the columns using introspection and do not quote the column list. Therefore, if any of the columns in an incremental model are mixed- or lower-case, incremental updates will always fail with aninvalid identifier
error.I also tested snapshotting on top of the same test dataset I was using, and in all cases I could identify, column-level quoting was applied correctly and dbt produced the intended results.
Steps To Reproduce
Here's my test scenario:
Expected behavior
I would expect that all columns that are quoted when their column name is provided to be referenced by dbt using their quoted column name.
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using: OSX
The output of
python --version
: Python 2.7.10The text was updated successfully, but these errors were encountered: