-
Notifications
You must be signed in to change notification settings - Fork 175
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
[CT-1522] [Bug] Easy : Can't Create lowercase model on SnowFlake (double quotes conflict) #330
Comments
@jugodfroy Thanks for opening - I think you've got the right idea!
This is definitely the most expedient. For consistency in output code, we might prefer to keep it as a double-quoted string, with escapes for any quotes inside. This looks awkward, but something like it might get the job done: target_relation = {{ target_relation }}
df.write.mode("overwrite").save_as_table("{{ target_relation | replace('"', '\"' }}", create_temp_table={{temporary}}) @ChenyuLInx Any preference between those two? |
Let's go for the escape route... just in case the quoted relation name contains a single quote (gross) @jugodfroy Is this something you'd be interested in contributing? |
I would love to ! |
@jugodfroy Check out the contributing guide! We'll just want an additional test case here, which has a Python model with a lowercase name + |
Actually it will be quicker if someone else fix this one :) |
* Respect quoting in dbt-py models #330 * Add changelog entry * Switch dbt-core back to main Co-authored-by: Chenyu Li <[email protected]>
Is this a new bug in dbt-snowflake?
Current Behavior
When trying to create a python model with lowercase name, the name of the model is under double quotes which lead to a conflit of double quote in the function save_as_table().
Expected Behavior
The expected behavior is the good creation of the model in lowercase in Snowflake
Steps To Reproduce
In dbt_project.yml specifiy the quoting settings :
Then try to run a python model. The error should be reproduced.
Relevant log output
![image](https://user-images.githubusercontent.com/79590825/202451775-681be1e0-8d03-4082-8c94-1229c88dde52.png)
Environment
Additional Context
Idea To fix : in file : dbt-snowflake/dbt/include/snowflake/macros/materializations/table.sql
line 52 (double to simple quote) :
replace
df.write.mode("overwrite").save_as_table("{{ target_relation }}", create_temp_table={{temporary}})
by
df.write.mode("overwrite").save_as_table('{{ target_relation }}', create_temp_table={{temporary}})
The text was updated successfully, but these errors were encountered: