Partition Types
Partitions allow you to organize assets and jobs by time windows, dimensions, or custom criteria. Dagster provides several partition definition types for different use cases.PartitionsDefinition
Abstract base class for all partition definitions. Defines a set of partitions that can be attached to an asset or job.Common Methods
Returns a list of partition keys.Parameters:
current_time(datetime, optional): Current time for time-based partitionsdynamic_partitions_store(DynamicPartitionsStore, optional): Store for dynamic partitions
Sequence[str] - List of partition keysReturns partition keys within a specified range.Parameters:
partition_key_range(PartitionKeyRange): The range to query
Sequence[str] - Partition keys in the rangeChecks if a partition key exists.Parameters:
partition_key(str): The partition key to check
bool - True if the partition existsReturns the total number of partitions.Returns:
int - Number of partitionsStaticPartitionsDefinition
A statically-defined set of partitions with explicit partition keys.Constructor
List of partition key strings. Recommended to limit to 100,000 partitions or fewer per asset.
Example: Country Partitions
TimeWindowPartitionsDefinition
Partitions based on time windows with customizable cron schedules.Constructor
The start datetime or string for the partition set. The first partition starts at the first cron schedule tick equal to or after this value.
Cron schedule string that determines the partition boundaries (e.g., “0 0 * * *” for daily at midnight).
Date format string for partition keys (e.g., “%Y-%m-%d”).
Timezone string (IANA format, e.g., “America/Los_Angeles”). Defaults to “UTC”.
Optional end datetime. The last partition ends before this value.
Number of partitions to extend beyond the current time. Default is 0 (last partition ends before current time).
Cron strings or datetime objects to exclude from the partition set.
Properties
The start datetime of the partition set.
The end datetime of the partition set, if specified.
The timezone string for the partition set.
Enum representing the partition cadence (HOURLY, DAILY, WEEKLY, or MONTHLY), if it matches a standard pattern.
Number of minutes past the hour when partitions start.
Number of hours past midnight when partitions start.
For weekly/monthly partitions, the day when partitions start.
Time Window Methods
Gets the time window for a specific partition key.Parameters:
partition_key(str): The partition key
TimeWindow - The time windowGets all partition keys within a time window.Parameters:
time_window(TimeWindow): The time window
Sequence[str] - Partition keys in the windowExample: Custom Schedule
DailyPartitionsDefinition
Convenience subclass for daily partitions.Constructor
Start date in “YYYY-MM-DD” format or as a datetime object.
Optional end date.
Timezone string. Defaults to “UTC”.
Number of partitions to extend beyond current time. Default is 0.
Date format string. Defaults to “%Y-%m-%d”.
HourlyPartitionsDefinition
Convenience subclass for hourly partitions.Constructor
Start datetime in “YYYY-MM-DD-HH:MM” format or as a datetime object.
Optional end datetime.
Timezone string. Defaults to “UTC”.
Number of partitions to extend beyond current time. Default is 0.
Datetime format string. Defaults to “%Y-%m-%d-%H:%M”.
WeeklyPartitionsDefinition
Convenience subclass for weekly partitions.Constructor
Start date.
Optional end date.
Timezone string. Defaults to “UTC”.
Day of week to start partitions (0=Sunday, 1=Monday, …, 6=Saturday). Defaults to 0.
Number of partitions to extend beyond current time. Default is 0.
Date format string. Defaults to “%Y-%m-%d”.
MonthlyPartitionsDefinition
Convenience subclass for monthly partitions.Constructor
Start date.
Optional end date.
Timezone string. Defaults to “UTC”.
Day of month to start partitions (1-31). Defaults to 1.
Number of partitions to extend beyond current time. Default is 0.
Date format string. Defaults to “%Y-%m-%d”.
DynamicPartitionsDefinition
Partitions whose keys can be dynamically added and removed at runtime.Constructor
Name of the dynamic partitions definition. Must be unique.
Methods
Creates a request to add new partitions.Parameters:
partition_keys(Sequence[str]): Partition keys to add
AddDynamicPartitionsRequestCreates a request to delete partitions.Parameters:
partition_keys(Sequence[str]): Partition keys to delete
DeleteDynamicPartitionsRequestUsage with Instance
MultiPartitionsDefinition
Creates a cross-product of partitions from two partitions definitions.Constructor
Mapping of dimension name to partitions definition. Currently supports exactly 2 dimensions. Supported types are StaticPartitionsDefinition, TimeWindowPartitionsDefinition, and DynamicPartitionsDefinition.
MultiPartitionKey
Represents a key in a multi-dimensional partition space.Mapping from dimension name to partition key.
Example: Time and Category
PartitionKeyRange
Represents a range of partition keys.The starting partition key (inclusive).
The ending partition key (inclusive).
TimeWindow
Represents a time window for time-based partitions.The start datetime of the window.
The end datetime of the window.
Best Practices
Partition Count Limits
We recommend limiting partition counts to 100,000 or fewer per asset for optimal performance.Time-based Partitions
Static Partitions
Dynamic Partitions
See Also
- Assets - Learn about partitioned assets
- Jobs - Learn about partitioned jobs
- Config Types - Learn about configuration
- Metadata Types - Learn about metadata
