Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/dbt_osmosis/core/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,16 +1154,27 @@ def process_column(c: BaseColumn | ColumnMetadata, /) -> None:

if catalog := context.read_catalog():
logger.debug(":blue_book: Catalog found => Checking for ref => %s", rendered_relation)
matcher = getattr(relation_any, "matches", None)

def matches_relation(entry: t.Any) -> bool:
if not callable(matcher):
return False
return bool(matcher(*entry.key()))


def matches_relation_case_insensitive(c: t.Any) -> bool:
#For Snowflake, use case-insensitive matching
if context.project.runtime_cfg.credentials.type == "snowflake":
try:
catalog_key = tuple(
k.upper() if isinstance(k, str) else k for k in c.key()
)
relation_key = tuple(
k.upper() if isinstance(k, str) else k
for k in (relation.database, relation.schema, relation.name)
)
return catalog_key == relation_key
except Exception:
pass
# Default to case-ensitive matching:
return relation.matches(*c.key())

catalog_entry = _find_first(
chain(catalog.nodes.values(), catalog.sources.values()),
matches_relation,
matches_relation_case_insensitive,
)
if catalog_entry:
logger.info(
Expand Down