Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle uppercase references from Metabase GUI derived queries #242

Merged
merged 4 commits into from
Mar 14, 2024

Conversation

alex-float-on
Copy link
Contributor

@alex-float-on alex-float-on commented Mar 13, 2024

Relates to discussion: https://github.com/gouline/dbt-metabase/discussions/241

Some data warehouses, such as snowflake, store their object names (database, schema, table, columns) in uppercase (ref).

This means that metabase questions derived from the visual editor (GUI) need to have their sources lowercased in order to match with dbt's models and nodes. We already do this for SQL native queries (refs: 1, 2) so this is just a continuation of that logic.

Update

If table.json fixture is modified to contain uppercase table names, the exposure tests fail before this change is applied and pass after it is applied.

@alex-float-on alex-float-on marked this pull request as ready for review March 13, 2024 15:20
Copy link
Owner

@gouline gouline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read CONTRIBUTING.md carefully and run all the checks locally before committing code.

Also pick one API fixture (JSON files) used by the exposure tests and capitalise the name in the response to illustrate your Snowflake case, so that the tests fail before your fix and succeed after.

dbtmetabase/_exposures.py Outdated Show resolved Hide resolved
@alex-float-on
Copy link
Contributor Author

alex-float-on commented Mar 14, 2024

Thanks for your guidance @gouline.

I modified the table.json fixture to demonstrate how the fix addresses the snowflake uppercase issue.

One thing I noticed, however, is that we don't actively test table join exposures coming from non-sql questions. The only metabase question with a join is card 23 but this card also happens to be the only one that is missing from the expected exposures.

I wasn't sure how to add this exposure fixture back in but I believe it could/should be handled in a followup PR, since it was missing before my PR. I'd be happy to make the change if you give me a nudge in the right direction 🙂

@gouline gouline merged commit 27821ef into gouline:master Mar 14, 2024
1 check passed
@gouline
Copy link
Owner

gouline commented Mar 14, 2024

One thing I noticed, however, is that we don't actively test table join exposures coming from non-sql questions. The only metabase question with a join is card 23 but this card also happens to be the only one that is missing from the expected exposures.

I fixed this in #244.

@alex-float-on alex-float-on deleted the exposures-catch-lowercase branch March 15, 2024 00:18
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.

2 participants