https://dagster.io/ logo
#ask-ai
Title
# ask-ai
a

Alex Berndt

02/29/2024, 10:33 PM
can I have a multipartition definition consisting of two dynamic partition definitions?
s

Scout

02/29/2024, 10:33 PM
Yes, you can have a
MultiPartitionsDefinition
that consists of two
DynamicPartitionsDefinition
. The documentation provides an example of using a
MultiPartitionsDefinition
with a
DynamicPartitionsDefinition
as one of its dimensions, and there is no restriction mentioned that would prevent using two dynamic partitions within a
MultiPartitionsDefinition
. Here's a conceptual example based on the documentation's guidance:
Copy code
python from dagster import asset, MultiPartitionsDefinition, DynamicPartitionsDefinition  dynamic_partition_1 = DynamicPartitionsDefinition(name="dynamic_partition_1") dynamic_partition_2 = DynamicPartitionsDefinition(name="dynamic_partition_2")  partitions_def = MultiPartitionsDefinition(     {         "dimension_1": dynamic_partition_1,         "dimension_2": dynamic_partition_2,     } )  @asset(partitions_def=partitions_def) def my_asset(context):     # Asset logic here     pass
In this example,
my_asset
is an asset with a multipartition definition that includes two dynamic partition definitions. Each dynamic partition definition is identified by a unique name. Remember that when working with dynamic partitions, you will need to manage the addition and removal of partition keys at runtime, as dynamic partitions are designed to accommodate partitions that are not known at definition time but are determined at runtime.
3 Views