https://dagster.io/ logo
#ask-community
Title
# ask-community
c

Chris Hansen

08/08/2022, 2:11 PM
hey folks, how do i get a partitioned asset to depend on 30 days of partitions of another asset?
o

owen

08/08/2022, 5:05 PM
hi @Chris Hansen! you can define a custom PartitionMapping to do this, then set that as the
partition_mapping
on your downstream asset. (Basically, you want a PartitionMapping whose get_upstream_partitions_for_partition_range function returns those 30 upstream partition keys when passed in a range containing your single downstream key)
c

Chris Hansen

08/08/2022, 5:13 PM
what does that look like in terms of defining the @asset that depends on the 30 partitions of another asset?
o

owen

08/08/2022, 5:17 PM
hm it looks like the @asset does not currently support the partition_mapping argument (PartitionMappings are currently experimental), but @multi_asset does (via setting
partition_mapping
on an AssetIn). So you could have an (admittedly hacky) solution of using
@multi_asset
, or you could use
AssetsDefinition.from_op
(which has a
partiton_mappings
argument).
c

Chris Hansen

08/08/2022, 5:17 PM
ah good to know, thank you!
o

owen

08/08/2022, 10:39 PM
my bad on this by the way, there's totally an
ins
parameter to
@asset
, so
@asset(ins={"my_input_asset": AssetIn(partition_mapping=my_partition_mapping)})
should work