[RFC] Adding support for partition mapping to Dagster's dbt integration #17722
rexledesma
started this conversation in
Ideas
Replies: 1 comment
-
Hi, would this work for DynamicPartitionsDefinition as well? I need my different dbt_assets to use different DynamicPartitionsDefinition |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
This discussion provides an overview of the API changes to the
dagster-dbt
integration to support partition mappings for your software-defined assets (SDAs).We would like to use this document to gather feedback and answer questions about the new APIs. If you have any comments or use cases that are not addressed, please participate in the discussion!
We'll talk about two use cases here:
Requirements
dagster-dbt>=0.21.6
, which was released on November 2, 2023.@dbt_assets
to define your dbt SDAs.Usage
DagsterDbtTranslator
now has a new methodget_partition_mapping
that can be overridden to provide customPartitionMapping
's for your dbt dependencies.get_partition_mapping
is a function that takes in two dictionary parameters: the first, representing properties of a dbt resource; and the second, representing the properties of a parent dependency to the first dbt resource. The function returns aPartitionMapping
specifying the mapping for this dependency.Example 1: Overriding partition dependency rules for your dbt SDAs
For specific dbt dependencies, you can specify a custom partition mapping. This can be done by overriding
DagsterDbtTranslator.get_partition_mapping
.Example 2: Adding self-dependencies for your dbt SDAs
You can also specify a dbt model to have a self-dependency on its previous partitions. Here, you will need to indicate in the dbt metadata that the model has a self-dependency. This can be configured using
+meta.dagster.has_self_dependency
.Then, you can override
DagsterDbtTranslator.get_partition_mapping
to provide the partition mapping for the self-dependency.References
PartitionMapping
API docsBeta Was this translation helpful? Give feedback.
All reactions