gouline / dbt-metabase

dbt + Metabase integration
https://pypi.org/project/dbt-metabase/
MIT License
441 stars 63 forks source link

Auto-Create Metabase Questions from dbt Models #255

Closed korbash closed 2 months ago

korbash commented 2 months ago

Auto-Create Metabase Questions from dbt Models

Creating SQL queries with multiple filters can be challenging. One of the most useful types of filters in Metabase is the Field Filters. Interestingly, it's possible to integrate these filters directly from dbt models!

We can enhance the schema.yml file by adding filter features to columns intended to be used as filters. Here's an example of how to define these attributes in the metadata section:

models:
  - name: orders
    columns:
      - name: order_date
        meta:
          metabase.filter:
            base-type: "type/Date"
            widget-type: "date/range"

To utilize these filters in the dbt models that are to be transformed into Metabase queries, reference the column in your model as follows:

WHERE '__filter__.<model_name>.<column_name>' = '__filter__.<model_name>.<column_name>'

After this setup, the dbt-metabase tool can automatically generate Metabase questions using the information from the manifest.json and the compiled models code.

gouline commented 2 months ago

Current focus of the tool is syncing metadata (like tables and exposures) between dbt and Metabase. Generating questions goes well beyond that into analytics.

korbash commented 2 months ago

Okay, I see. This feature is really needed for me, so I will implement it anyway. If you decide to add it to this project one day, please let me know)

gouline commented 2 months ago

Tag me on the pull request in your fork when you do, I'd be curious how you implement it.