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

shailesh

04/27/2023, 3:16 PM
Hi All I had below job in which monthly_asset ie monthly partition depends on daily_asset asset ie daily partition
Copy code
from dagster import (
    AssetIn,
    DailyPartitionsDefinition,
    MonthlyPartitionsDefinition,
    TimeWindowPartitionMapping,
    asset,
)

partitions_def_daily = DailyPartitionsDefinition(start_date="2023-01-01")
partitions_def_monthly = MonthlyPartitionsDefinition(start_date="2023-01-01")


@asset(partitions_def=partitions_def_daily)
def daily_asset():
    ...


@asset(
    partitions_def=partitions_def_monthly
)
def monthly_asset(daily_asset):
    ...
But when I am executing job getting error :
Copy code
Selected assets must have the same partitions definitions, but the selected assets have different partitions definitions:
I had refered this link: https://docs.dagster.io/concepts/partitions-schedules-sensors/partitions#partition-dependencies Please help me out, how can I achieve both daily and monthly partition in one job 🙏
c

chris

04/27/2023, 6:15 PM
you need to define a partition mapping, as described in that link. Looks like you’re importing it, but not actually using it.
s

shailesh

05/08/2023, 12:21 PM
Thanks @chris for replying , I had updated my code
Copy code
from dagster import (
    AssetIn,
    DailyPartitionsDefinition,
    MonthlyPartitionsDefinition,
    TimeWindowPartitionMapping,
    asset,
)

partitions_def_daily = DailyPartitionsDefinition(start_date="2023-01-01")
partitions_def_monthly = MonthlyPartitionsDefinition(start_date="2023-01-01")


@asset(partitions_def=partitions_def_daily)
def daily_asset():
    ...


@asset(
    partitions_def=partitions_def_monthly,
    ins={
        "daily_asset": AssetIn(
            partition_mapping=TimeWindowPartitionMapping(
                start_offset=-1, end_offset=-1
            ),
        )
    }
)
def monthly_asset(daily_asset):
Still getting same error :
Copy code
Selected assets must have the same partitions definitions, but the selected assets have different partitions definitions:
c

chris

05/26/2023, 4:12 PM
monthly asset should still be using a daily partitions def - the partition will handle the rollup into a month of data
5 Views