snowflake-sqlalchemy icon indicating copy to clipboard operation
snowflake-sqlalchemy copied to clipboard

Single Quotes for COLLATE statements (New PR)

Open YYYasin19 opened this issue 3 years ago • 5 comments

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    This solves the issue described in #186, unfortunately, there was no issue referenced there.

  2. Fill out the following pre-review checklist:

    • [x] I am adding a new automated test(s) to verify correctness of my new code
    • [ ] I am adding new logging messages
    • [ ] I am adding new credentials
    • [ ] I am adding a new dependency
  3. Please describe how your code solves the related issue.

The initial problem description can be viewed here. TL;DR: When creating tables with columns that have collation in sqlalchemy

table = sqlalchemy.Table("table1", Column("char_column", String(collation="en")))

the resulting SQL statements use double quotes

CREATE TABLE table1 (char_column VARCHAR COLLATE "en")

which is allowed in other database engines but does not work in snowflake.

This PR fixes that issue by overwriting the rendering in the SQLAlchemy statement Compiler for text columns and adding at least one new test.

YYYasin19 avatar Nov 09 '22 11:11 YYYasin19

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Nov 09 '22 11:11 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

YYYasin19 avatar Nov 09 '22 11:11 YYYasin19

My initial idea was to write a test that validates if the column is sorted according to the specified collation. I think, however, that that is something snowflake itself should have to test. Therefore I am just validating that the information was passed correctly. Previously, before this feature, it was not even possible to create tables with collation information so that is tested implicitly as well.

YYYasin19 avatar Nov 09 '22 13:11 YYYasin19

@sfc-gh-mkeller do you have some time or know someone from snowflake who could have a look at this?

YYYasin19 avatar Nov 13 '22 16:11 YYYasin19

Just checking to see if there is an update on this issue.

toobeyonewing avatar Apr 13 '23 15:04 toobeyonewing