How to use MultiPartitions and DynamicPartitions together? #14334
Answered
by
jamiedemaria
jamiedemaria
asked this question in
Q&A
-
Is it possible to use a |
Beta Was this translation helpful? Give feedback.
Answered by
jamiedemaria
May 17, 2023
Replies: 1 comment 2 replies
-
yes it is! here is a code sample from dagster import asset, MultiPartitionsDefinition, DynamicPartitionsDefinition, Definitions, DailyPartitionsDefinition
dynamic_colors = DynamicPartitionsDefinition(name="dynamic_colors")
partitions_def = MultiPartitionsDefinition(
{
"time": DailyPartitionsDefinition(start_date="2022-01-01"),
"color": dynamic_colors,
}
)
@asset(
partitions_def=partitions_def
)
def mutli_dynamic_asset(context):
partition = context.partition_key.keys_by_dimension
context.log.info(f"Partition: time: {partition['time']}, color: {partition['color']}")
defs = Definitions(
assets=[mutli_dynamic_asset]
) If you run this in the UI, you can add colors to the dynamic partition and successfully materialize the asset |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
jamiedemaria
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes it is! here is a code sample