Yang
10/26/2022, 6:03 PMcontext.partition_key
?jamie
10/26/2022, 6:15 PMcontext.partition_key
will have?Yang
10/26/2022, 6:39 PMjamie
10/26/2022, 7:16 PMcontext.partition_key
will work. you can also use context.asset_partition_key_for_output(<output_name>)
Yang
10/26/2022, 7:50 PMjamie
10/26/2022, 7:56 PMclaire
10/26/2022, 8:54 PMasset_partition_key_for_input
function.
Both methods that jamie mentioned pretty much do the same thing for SDAs--fetching the partition key for the current asset. The asset_partition_key_for_output
method exists separately because some users use a pre-SDA experimental feature where a partitions definition exists directly on an output.Yang
10/26/2022, 11:09 PM@asset(partitions_def=mypartition)
def part_asset(context):
datestr = context.asset_partition_key_for_input()
context.partition_key
and that workedclaire
10/28/2022, 6:14 PMasset_partition_key_for_input
is here: https://docs.dagster.io/_apidocs/execution#dagster.OpExecutionContext
context.partition_key
will return the output partition key of your asset. asset_partition_key_for_input
will return partition key of the upstream input that the current asset depends on.
So for example, if your current asset is an hourly-partitioned asset that depends on a daily-partitioned asset, context.partition_key
will return an hourly-partitioned key, while asset_partition_key_for_input
will return a daily-partitioned key.Yang
10/28/2022, 8:33 PM