Repository navigation
Description
Under which category would you file this issue?
Task SDK
Apache Airflow version
3.3.0
What happened and how to reproduce it?
** Issue Description **
StartOfDayMapper defaults input_format to "%Y-%m-%dT%H:%M:%S". If an upstream asset emits a partition key that's already at day granularity (e.g. "2026-07-30"), calling to_downstream() without explicitly overriding input_format raises an error.
As a result, the mapper must be explicitly configured with the correct input_format up front. This prevents flexible handling of a mix of partition keys at different granularities (e.g. some upstream assets emitting day-level keys, others hour-level) without requiring separate, explicitly-configured mapper instances for each.
** Repro **
from airflow.partition_mappers.temporal import StartOfDayMapper
--- Case 1: full timestamp input (matches the default input_format) ---
mapper = StartOfDayMapper() # default input_format="%Y-%m-%dT%H:%M:%S"
print(mapper.to_downstream("2026-07-30T14:22:05")) # → "2026-07-30"
--- Case 2: date-only input (works) ---
mapper_date_only = StartOfDayMapper(input_format="%Y-%m-%d")
print(mapper_date_only.to_downstream("2026-07-30")) # → "2026-07-30"
--- Case 3: date-only input WITHOUT telling it the format (reproduces the error) ---
mapper_default = StartOfDayMapper() # still expects full timestamp
print(
mapper_default.to_downstream("2026-07-30")
) # → ValueError: time data '2026-07-30' does not match format '%Y-%m-%dT%H:%M:%S'
What you think should happen instead?
Either:
Partition keys already at day granularity should be passed through unchanged, similar to IdentityMapper,
or
StartOfDayMapper should output keys in its own default input_format (i.e. "%Y-%m-%dT%H:%M:%S", with the time component zeroed to T00:00:00), so that its output can be fed back into another instance of the same mapper (chaining).
Operating System
No response
Deployment
None
Apache Airflow Provider(s)
No response
Versions of Apache Airflow Providers
No response
Official Helm Chart version
Not Applicable
Kubernetes Version
No response
Helm Chart configuration
No response
Docker Image customizations
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
boring-cyborg commentedon Jul 30, 2026
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
Zim95 commentedon Oct 30, 2026
I can reproduce this on current
main, and the same error affects the hour, week and month mappers.Would falling back to
output_formatwheninput_formatdoesn’t match be acceptable?I’d like to work on this. I’d build on the approach in #70781, with credit. I’ve noticed #67119 (for #58943) moves towards stricter key validation, so I want to check the direction first.
Patrick539 commentedon Oct 30, 2026
@Zim95
Thank you for your interest in the issue.
I think that would solve the problem for this particular setting but not overall. I assume the same problem exists with all mappers, so prabably also StartOfYearMapper. If I look at the provided Mapper I would assume that all the outputs from the other mappers would be valide. Such that I can have a processing chain, where I map some key to the start of an hour, then use this output and map it in a following DAG to the start of the day and maybe later even use it for a DAG that maps the keys to the start of the year.
https://www.astronomer.io/docs/airflow/airflow-partitioned-runs#one-to-one-mappers
So if I look here at for example StartOfYearMapper I would assume it would work with its own output (i.e. 'YYYY') But also with outputs from the StartOfQuarterMapper ('YYYY-Q'), StartOfMonthMapper ('YYYY-MM'), StartOfWeekMapper ('YYYY-MM-DD (W%V)'), StartOfDayMapper ('YYYY-MM-DD') and so on.
Zim95 commentedon Oct 30, 2026
Thanks for the clarification, @Patrick539. I agree that falling back to output_format alone wouldn’t address chaining across different mappers.
What if we introduced a shared parser that recognizes the supported partition-key formats using strict regex matching, then fills in missing date/time components with defaults corresponding to the start of that period?
For example:
Each mapper could then operate on the normalized datetime and produce its own output format. This would allow us to reuse the parsing logic across all temporal mappers rather than introducing individual fallbacks.
We’d still need to handle ISO week formats and invalid dates explicitly.
One consideration is whether mapping from coarser to finer granularity should be supported, since a year-to-day conversion would select January 1 rather than represent every day of that year.
Would this approach make sense? If so, I’d be happy to work on the shared parser and add tests covering mapper chaining.
Zim95 commentedon Nov 1, 2026
Hi @Patrick539, I've opened #76220 for this, using the shared parser approach from my last comment.
Your chain should now work with the default settings: a key can go through
StartOfHourMapper, thenStartOfDayMapper, thenStartOfYearMapperin separate Dags.StartOfYearMapperalso accepts the default output of the week, month and quarter mappers, as you described.There are two limits to be aware of:
output_format, the next mapper still needs a matchinginput_format.RollupMapperstill accept only theirinput_format, because those are the exact keys the rollup waits for. Accepting other formats could hold the Dag run forever.If you have time, it would be great to know whether this covers your use case. The open questions are listed in the PR, and any feedback on them is welcome.
Patrick539 commentedon Nov 6, 2026
Hi @Zim95,
Thanks for the PR. The shared parser approach covers my use case and the chaining behavior is exactly what I was hoping for. The limitations around custom output_format values and RollupMapper also seem reasonable to me.
Overall this looks like a good, general solution. Thanks for the work!
Zim95 commentedon Nov 6, 2026
Thanks @Patrick539, glad it covers your use case! I’ll follow up on the PR if reviewers ask for changes.
Let temporal mappers accept each other's default output keys