Hi All I had below job in which monthly_asset ie m...
# ask-community
s
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
you need to define a partition mapping, as described in that link. Looks like you’re importing it, but not actually using it.
s
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
monthly asset should still be using a daily partitions def - the partition will handle the rollup into a month of data