Skip to content

Conversation

@mrlimacz
Copy link


This PR implements an XCom serializer for pendulum.date.Date.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@mrlimacz mrlimacz force-pushed the serialize_pendulum_date branch from 5f986fa to 4bb272a Compare January 28, 2026 18:11
@shahar1 shahar1 changed the title Add XCom serilizer for pendulum.date.Date Add XCom serializer for pendulum.date.Date Jan 28, 2026
Copy link
Contributor

@SameerMesiah97 SameerMesiah97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. But may I know what motivated this PR?

@mrlimacz mrlimacz force-pushed the serialize_pendulum_date branch from 4bb272a to ccbccba Compare January 29, 2026 10:48
@mrlimacz
Copy link
Author

@SameerMesiah97 we want to have a task used across multiple DAGs that would take dates or date times object from DAG parameters for manual runs (ad-hoc client requests, for scheduled DAGs we use data_interval_start and data_interval_end). The resulting period is returned in XComs. For convinience I use pendulum for all date(time) related operations and stumbled upon pendulum.Date not being supported (while datetime.date is).

@mrlimacz mrlimacz force-pushed the serialize_pendulum_date branch 4 times, most recently from 5ce191b to 02a3005 Compare January 29, 2026 19:53
@amoghrajesh
Copy link
Contributor

@mrlimacz we do have support for pendulum.DateTime, does that not suffice your need?

Example:

>>> import pendulum
>>> s = pendulum.datetime(2021, 1, 1, tz="UTC")
>>> from airflow.sdk.serde import serialize, deserialize
>>> serialize(s)
{'__classname__': 'pendulum.datetime.DateTime', '__version__': 2, '__data__': {'timestamp': 1609459200.0, 'tz': {'__classname__': 'builtins.tuple', '__version__': 1, '__data__': ['UTC', 'pendulum.tz.timezone.Timezone', 1, True]}}}
>>> deserialize(serialize(s))
DateTime(2021, 1, 1, 0, 0, 0, tzinfo=Timezone('UTC'))
>>> deserialize(serialize(s)) == s
True

@mrlimacz mrlimacz force-pushed the serialize_pendulum_date branch from 02a3005 to 27b1308 Compare January 30, 2026 06:55
@mrlimacz
Copy link
Author

@amoghrajesh I'd like to have the object type consistent with the input format. Whenever DAG parameters of date-time format, I'd like to return pendulum.DateTime. But when they are of format date, I'd like the serialized output to be pendulum.Date

@mrlimacz mrlimacz force-pushed the serialize_pendulum_date branch from 27b1308 to b4bd3d5 Compare January 30, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants