Last active
August 20, 2024 13:33
-
-
Save walkness/2683feec097cb2f1f0488c73f7c6e110 to your computer and use it in GitHub Desktop.
Database Field References by Metabase Question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with report_card_fields as ( | |
| select | |
| id as report_card_id, | |
| (regexp_matches(dataset_query, '"field",(\d+)', 'g'))[1]::int as field_id | |
| from report_card | |
| ) | |
| select | |
| rc.name as question_name, | |
| mt.name as table_name, | |
| mf.name as field_name | |
| from report_card_fields rcf | |
| inner join report_card rc on rcf.report_card_id = rc.id | |
| left join metabase_field mf on rcf.field_id = mf.id | |
| left join metabase_table mt on mf.table_id = mt.id |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This uses a simple regex search for field IDs in the Metabase Question JSON blobs, so the results are not at all guaranteed to be exhaustive. However, it seems to work reasonably well for simple searches.