Skip to content

ExternalTaskSensor. execution-date pattern.#67138

Open
dotbg wants to merge 2 commits into
apache:mainfrom
dotbg:feature/10883-ExternalTaskSensor-execution-date-pattern
Open

ExternalTaskSensor. execution-date pattern.#67138
dotbg wants to merge 2 commits into
apache:mainfrom
dotbg:feature/10883-ExternalTaskSensor-execution-date-pattern

Conversation

@dotbg
Copy link
Copy Markdown

@dotbg dotbg commented May 18, 2026

Fixes #10883.

Implemented execution_date pattern.

allows for the following:

{{ logical_date - macros.timedelta(hours=1) }}

@boring-cyborg
Copy link
Copy Markdown

boring-cyborg Bot commented May 18, 2026

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@dotbg dotbg force-pushed the feature/10883-ExternalTaskSensor-execution-date-pattern branch 2 times, most recently from b56aa7f to 53a99f5 Compare May 18, 2026 21:42
if isinstance(execution_date_value, datetime.datetime):
return [execution_date_value]

import pendulum
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for your contribution.

I observed the following points:

I believe that lazy importing in this context doesn't make much sense; the gain is low and it deviates from the file's standard. After all, _get_dttm_filter runs on every poke/defer.

Another problem related to the pendulum: I noticed that we can import timezone through the SDK, and we even have classes imported from it in this file. It's worth evaluating if this makes sense; it would be one less library in the file.

Here's a possible suggestion regarding parsing using airflow.providers.common.compat.sdk. Some operators already use this pattern.

Therefore, we could replace:

import pendulum

...

return [pendulum.parse(execution_date_value)]

Put:

from airflow.providers.common.compat.sdk import (
    AirflowSkipException,
    BaseOperatorLink,
    BaseSensorOperator,
    conf,
    timezone,
)

...

return [timezone.parse(execution_date_value)]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks a lot. I will change the code soon. Have one test to fix 😓

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done. The tests should be green as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The pendulum removal is perfect, thank you.

@dotbg dotbg force-pushed the feature/10883-ExternalTaskSensor-execution-date-pattern branch from 53a99f5 to 120e55c Compare May 19, 2026 15:22
@dotbg dotbg requested a review from Pedrinhonitz May 19, 2026 15:23
Copy link
Copy Markdown
Contributor

@Pedrinhonitz Pedrinhonitz left a comment

Choose a reason for hiding this comment

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

It seems good to me, but I would like a more in-depth analysis from a more experienced colleague to assess the impacts of depreciation.

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.

Improve ExternalTaskSensor execution date pattern

2 participants