-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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-1375] [Bug] on snowflake "quoting" is not respected in python models #6103
Comments
can i take this issue if nobody has time to fix it? :D |
Hey @pquadri - sorry for the delay getting back to you! cc @ChenyuLInx: Can you remember the reason why you opted for First question: How to address objects with quoted components in Snowpark Python, given that object names already need to be passed into create or replace table analytics.jerco_src_schema."$$VerySpecialTable" as (
select 1 as aggregateId, 'LeadCreated' as "type"
); version: 2
sources:
- name: jerco_src_schema
tables:
- name: very_special_table
identifier: "Very%Special&Table"
quoting:
database: false
schema: false
identifier: true Does this work in Snowpark Python if we escape the # https://docs.snowflake.com/en/sql-reference/stored-procedures-python.html
import snowflake.snowpark as snowpark
def main(session: snowpark.Session):
df = session.table("analytics.jerco_src_schema.\"Very%Special&Table\"")
df.filter(
"\"type\" = 'LeadCreated'"
)
return df.collect() I tried it out in Snowsight, and it does! Second question: Does this just work if we remove the Here's a dbt model, similar to yours: def model(dbt, session):
# switched from 'incremental' to 'table' for simplicity
dbt.config(materialized="table")
leads_created = dbt.source("jerco_src_schema", "very_special_table").filter(
"\"type\" = 'LeadCreated'"
)
# switched this to .select() so as to return a DataFrame, rather than a single Column
leads_df = leads_created.select("aggregateId")
return leads_df When I do
Third question: Given that the change here would be to For example, this works in SparkSQL: select * from `dbt_jcohen`.`orders` Does this work in PySpark? df = spark.table("`dbt_jcohen`.`orders`")
df.describe() It looks like it does! I'm going to verify that a simple Python model runs successfully on both data platforms, with the quoting enabled for |
Is this a new bug in dbt-core?
Current Behavior
Using a quoting: true parameter results in the quoting not being respected.
yields this query being executed:
when the source specifies quoting the identifier.
Expected Behavior
The identifier is correctly quoted
Steps To Reproduce
As above.
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
I think the issue might be the fact that identifier = false is passed explicitly here: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/python_model/python.sql, removing those defaults solved the problem on my machine.
The text was updated successfully, but these errors were encountered: