Skip to content
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

SNOW-1232488: Table reflection methods using .format do not respect quoted_name #276

Open
machow opened this issue Mar 14, 2022 · 2 comments
Assignees
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team

Comments

@machow
Copy link

machow commented Mar 14, 2022

Hello--thanks for your work on this library! I maintain a tool called siuba that can execute SQL analyses across many different databases (using sqlalchemy). While working on snowflake support, I noticed that table reflection often does not work for case sensitive identifiers, even if they're quoted.

Below is an example that I think shows the root cause: queries in the dialect that are built using .format, do not perform the necessary escaping of quoted_name objects.

Example

from snowflake.sqlalchemy import __version__
from snowflake.sqlalchemy.snowdialect import SnowflakeDialect

__version__    # 1.3.3
dialect = SnowflakeDialect()

# far so good
nn_schema = dialect.normalize_name("some_schema")
type(nn_schema)   # sqlalchemy.sql.elements.quoted_name
nn_schema.quote  # True

# Does not correctly quote schema name
"SHOW TABLES IN SCHEMA {}".format(nn_schema)

# output is 'SHOW TABLES IN SCHEMA some_schema'

What did you expect to see?

SHOW TABLES IN SCHEMA "some_schema"

What did you see instead?

SHOW TABLES IN SCHEMA some_schema

(and an error because SOME_SCHEMA does not exist)

@github-actions github-actions bot changed the title Table reflection methods using .format do not respect quoted_name SNOW-559151: Table reflection methods using .format do not respect quoted_name Mar 14, 2022
@cpcloud
Copy link

cpcloud commented Mar 15, 2023

@machow We worked around this broken behavior in ibis in ibis-project/ibis#5741 by effectively monkey patching dialect.normalize_name.

Yeah, it's hack, but it's not clear if anyone is fixing bugs in this project so feel free to crib from the above as needed.

@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Mar 13, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Mar 13, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka changed the title SNOW-559151: Table reflection methods using .format do not respect quoted_name SNOW-1232488: Table reflection methods using .format do not respect quoted_name Mar 13, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage labels Mar 13, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hi folks - apologies for leaving this unanswered for so long; we're changing that going forward.
for now, possibly

might be all originating from the same gap in snowflake-sqlalchemy. At this time, I cannot promise any timeline for taking care of this, but rest assured we're aware of the issue and i'll keep this thread posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants