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-1478655: snowflake_clusterby produces incorrect quoting when using expressions #505

Closed
ravirahman opened this issue Jun 12, 2024 · 3 comments
Labels
enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team

Comments

@ravirahman
Copy link

snowflake_clusterby produces incorrect quoting when using expressions

  1. What version of Python are you using?

Python 3.11.9 (main, Apr 2 2024, 08:25:04) [Clang 15.0.0 (clang-1500.3.9.4)]

  1. What operating system and processor architecture are you using?

macOS-14.5-arm64-arm-64bit

  1. What are the component versions in the environment (pip freeze)?

(trimming to just the snowflake packages -- the others are not relevant for this issue)

snowflake-connector-python==3.7.0
snowflake-sqlalchemy==1.5.0
  1. What did you do?
from sqlalchemy import Table, Column, MetaData
from sqlalchemy.schema import CreateTable
from snowflake.sqlalchemy import (
    STRING,
    TIMESTAMP_NTZ,
    dialect as snowflake_dialect
)

metadata = MetaData(bind=None, schema='database.schema', quote_schema=False)

test_table = Table('table', metadata,
                   Column('id', STRING, primary_key=True),
                   Column('created', TIMESTAMP_NTZ),
                   quote=False,
                   snowflake_clusterby=['id', 'to_date(created)']
                   )

sql_stmt = CreateTable(test_table).compile(dialect=snowflake_dialect())
print(sql_stmt)

Produced


CREATE TABLE database.schema.table (
	id VARCHAR NOT NULL, 
	created TIMESTAMP_NTZ, 
	PRIMARY KEY (id)
) CLUSTER BY (id, "to_date(created)")
  1. What did you expect to see?
CREATE TABLE database.schema.table (
	id VARCHAR NOT NULL,
	created TIMESTAMP WITHOUT TIME ZONE,
	PRIMARY KEY (id)
) CLUSTER BY (id, to_date("CREATED"))

(note where the quotes are and the capitalization transformation)
7. Can you set logging to DEBUG and collect the logs?

There were no logs emitted

@ravirahman ravirahman added bug Something isn't working needs triage labels Jun 12, 2024
@github-actions github-actions bot changed the title snowflake_clusterby produces incorrect quoting when using expressions SNOW-1478655: snowflake_clusterby produces incorrect quoting when using expressions Jun 12, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Jun 26, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage Issue is under initial triage and removed bug Something isn't working needs triage labels Jun 26, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hi - thanks for raising this. let me check and get back to you.

@sfc-gh-dszmolka sfc-gh-dszmolka added enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team and removed status-triage Issue is under initial triage labels Jun 27, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka removed their assignment Jun 27, 2024
@sfc-gh-dszmolka
Copy link
Contributor

confirmed with the dev team - right now, all input to snowflake_clusterby is indeed treated as strings, as you observed.
we'll consider this ticket for future enhancement plans to ultimately generate a SQL which would be (rightfully) expected in the first place, even when using expression as cluster key.

@sfc-gh-dszmolka
Copy link
Contributor

per release notes, I think this is resolved by version 1.7.0 in November 2024 release cycle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is a request for improvement or a new feature status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

2 participants