Created
April 6, 2026 14:45
-
-
Save cnolanminich/9b997da0661d935bbea284a28732b1e1 to your computer and use it in GitHub Desktop.
dbt cost insights with a component
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
| from collections.abc import Iterator | |
| import dagster as dg | |
| from dagster_dbt import DbtCliResource, DbtProjectComponent | |
| class DbtProjectWithInsightsComponent(DbtProjectComponent): | |
| """A DbtProjectComponent subclass that enables Dagster+ Insights. | |
| Chains `.with_insights()` onto the dbt event iterator so that warehouse | |
| query costs are associated with the produced asset materializations in | |
| the Dagster+ Insights dashboard. | |
| Requires: | |
| - dagster-cloud installed | |
| - Snowflake or BigQuery adapter in the dbt project | |
| - An InsightsSnowflakeResource (or BigQuery equivalent) configured | |
| """ | |
| def execute( | |
| self, context: dg.AssetExecutionContext, dbt: DbtCliResource | |
| ) -> Iterator: | |
| yield from self._get_dbt_event_iterator(context, dbt).with_insights() |
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
| type: dagster_open_platform.lib.dbt.insights_component.DbtProjectWithInsightsComponent | |
| attributes: | |
| project_dir: ../../../dagster_open_platform_dbt | |
| select: "tag:daily" | |
| exclude: "config.materialized:incremental" | |
| include_metadata: | |
| - column_metadata |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment