Skip to content

SNOW-1232488 feat case sensitive support#675

Merged
sfc-gh-mraba merged 9 commits into
mainfrom
SNOW-1232488-feat-case-sensitive-support
Apr 23, 2026
Merged

SNOW-1232488 feat case sensitive support#675
sfc-gh-mraba merged 9 commits into
mainfrom
SNOW-1232488-feat-case-sensitive-support

Conversation

@sfc-gh-mraba

@sfc-gh-mraba sfc-gh-mraba commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

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.

    Fixes SNOW-1232488

  2. Fill out the following pre-review checklist:

    • 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.

Fix case-sensitive identifier handling (SNOW-1232488)

Fixes #[issue]

Background

Snowflake stores unquoted identifiers in uppercase (mytable → MYTABLE). SQLAlchemy's dialect normalises names on the way in (MYTABLE → mytable) and denormalises on the way out (mytable → MYTABLE). Three bugs in this round-trip silently corrupted case-sensitive identifiers, and there was no supported way to opt into correct handling of mixed-case quoted names.

What changed

Bug fixes (always active):

  • denormalize_column_name in base.py — now correctly emits double-quoted SQL for quoted_name("mycol", True) columns in CLUSTER BY clauses. Previously the quote=True signal was dropped and the column was silently rendered unquoted.
  • _has_object in snowdialect.py — now applies denormalize_name before building the DESC TABLE statement, making has_table / has_sequence consistent with all other reflection methods.
  • _split_schema_by_dot in base.py — now preserves quote=True on inner-quoted schema parts during dot-splitting, preventing normalisation loss for schemas like "myDb"."mySchema".

New opt-in flag — case_sensitive_identifiers:

Pass as a create_engine keyword or ?case_sensitive_identifiers=true URL parameter. When enabled, ALL-UPPERCASE reserved-word identifiers (e.g. a column literally named TABLE) are normalised to quoted_name("table", True) instead of being returned unchanged, preventing key-lookup mismatches between object creation and reflection.

New helpers:

  • create_snowflake_engine(url, schema=..., case_sensitive_schema=True) — URL-encodes case-sensitive schema names via %22 so the Snowflake connector receives the correct double-quoted form.
  • snowflake.sqlalchemy.alembic_util.render_item — a drop-in Alembic render_item hook for env.py that serialises quoted_name columns correctly in generated migration files, preventing autogenerate from silently uppercasing case-sensitive column names.

Test infrastructure:

  • 54 unit tests covering all new and fixed code paths (mock-based, no live connection required).
  • --case-sensitive pytest flag to run the entire integration suite with the flag enabled for local debugging.
  • engine_testaccount_case_sensitive fixture for targeted case-sensitive integration tests in CI.
  • Fixed flaky test_begin_read_commited — buffer flush after create_all prevents DDL COMMITs from polluting transaction count assertions.

Scope

No changes to default normalisation behaviour. All fixes behind the case_sensitive_identifiers flag are additive. Existing applications are unaffected unless they explicitly opt in.

@sfc-gh-mraba sfc-gh-mraba self-assigned this Apr 17, 2026
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-1232488-feat-case-sensitive-support branch from 0cd98e6 to 2bf40d2 Compare April 20, 2026 07:10
@sfc-gh-mraba sfc-gh-mraba marked this pull request as ready for review April 20, 2026 07:25
@sfc-gh-mraba sfc-gh-mraba requested a review from a team as a code owner April 20, 2026 07:25
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-1232488-feat-case-sensitive-support branch from 2bf40d2 to 2a50e39 Compare April 20, 2026 07:36
@sfc-gh-mraba sfc-gh-mraba mentioned this pull request Apr 20, 2026
4 tasks
@sfc-gh-mraba sfc-gh-mraba changed the title Snow 1232488 feat case sensitive support SNOW-1232488 feat case sensitive support Apr 20, 2026
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-1232488-feat-case-sensitive-support branch from 2a50e39 to 1e240ea Compare April 20, 2026 13:44
Comment thread README.md
Comment thread README.md
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread tests/test_transactions.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread src/snowflake/sqlalchemy/alembic_util.py Outdated
Comment thread tests/test_unit_case_sensitivity.py
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread tests/test_unit_case_sensitivity.py Outdated
Comment thread src/snowflake/sqlalchemy/name_utils.py
@sfc-gh-mraba sfc-gh-mraba force-pushed the SNOW-1232488-feat-case-sensitive-support branch from c0aeb15 to 03ee95d Compare April 23, 2026 09:23
@sfc-gh-mraba sfc-gh-mraba merged commit 9a74b48 into main Apr 23, 2026
63 checks passed
@sfc-gh-mraba sfc-gh-mraba deleted the SNOW-1232488-feat-case-sensitive-support branch April 23, 2026 13:46
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants