Skip to content

fix: case-insensitive Snowflake relation matching for catalog lookup in get_columns#325

Open
Felix313 wants to merge 1 commit intoz3z1ma:mainfrom
Felix313:fix/snowflake-case-insensitive-catalog-matching
Open

fix: case-insensitive Snowflake relation matching for catalog lookup in get_columns#325
Felix313 wants to merge 1 commit intoz3z1ma:mainfrom
Felix313:fix/snowflake-case-insensitive-catalog-matching

Conversation

@Felix313
Copy link

Summary

Fixes Snowflake catalog lookup failures caused by case-sensitive relation matching in get_columns().

Problem

When target/catalog.json contains uppercase relation names (common in Snowflake), dbt-osmosis may look up the same relation in lowercase and thus fails to match it.

Example mismatch:

  • searched: db.schema.table_name
  • catalog: db.schema.TABLE_NAME

This prevents selecting the catalog entry and can lead to ApproximateMatchError / missing metadata behavior.

Root Cause

Catalog matching used:

  • relation.matches(*c.key())
    which is case-sensitive for this Snowflake scenario.

Change

In src/dbt_osmosis/core/introspection.py (get_columns()):

  • Added Snowflake-specific case-insensitive catalog matching by normalizing both sides to uppercase before comparison.
  • Kept existing behavior for non-Snowflake adapters.
  • Added safe fallback to default matcher if normalization path fails.

Validation

Validated locally with:
`dbt-osmosis yaml refactor TABLE_NAME --catalog-path target\catalog.json

Result: catalog entry is found correctly despite case differences.

Related / Complementary

This PR is complementary to #322 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant