Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save walkness/2683feec097cb2f1f0488c73f7c6e110 to your computer and use it in GitHub Desktop.

Select an option

Save walkness/2683feec097cb2f1f0488c73f7c6e110 to your computer and use it in GitHub Desktop.
Database Field References by Metabase Question
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
@walkness
Copy link
Author

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.

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