Skip to content

Commit

Permalink
Handle uppercase references from Metabase GUI derived queries (#242)
Browse files Browse the repository at this point in the history
* lowercase normal question exposures in from and join

* handle edge case where source_table is None

* change table name to uppercase in fixtures to verify changes

* fix indentation
  • Loading branch information
alex-float-on authored Mar 14, 2024
1 parent 4d40277 commit 27821ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions dbtmetabase/_exposures.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ def __extract_card_exposures(
elif query_source in ctx.table_names:
# Normal question
source_table = ctx.table_names.get(query_source)
_logger.info("Extracted model '%s' from card", source_table)
depends.add(source_table)
if source_table:
source_table = source_table.lower()
_logger.info("Extracted model '%s' from card", source_table)
depends.add(source_table)

# Find models exposed through joins
for join in query.get("query", {}).get("joins", []):
Expand All @@ -237,6 +239,7 @@ def __extract_card_exposures(
# Joined model parsed
joined_table = ctx.table_names.get(join_source)
if joined_table:
joined_table = joined_table.lower()
_logger.info("Extracted model '%s' from join", joined_table)
depends.add(joined_table)

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/api/table.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"points_of_interest": null
},
"show_in_getting_started": false,
"name": "customers",
"name": "CUSTOMERS",
"caveats": null,
"updated_at": "2021-07-21T07:30:35.159586Z",
"entity_name": null,
Expand Down

0 comments on commit 27821ef

Please sign in to comment.