[
https://issues.apache.org/jira/browse/AIRFLOW-4788?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Standish updated AIRFLOW-4788:
-------------------------------------
Description:
Despite documentation on macros page, previous execution dates are in general
not pendulum type.
For one, when reading from database, UtcDateTime returns native datetime type.
Also dag.previous_schedule returns datetime type.
So, in general, `prev_execution_date` and `ti.previous_ti.execution_date` may
be non-pendulum.
(there are edge cases when the context var prev_* is pendulum e.g. when there
is no DR or no schedule interval or manually triggered, but in general, no.)
The problem is, this leads to errors and confusion when using these fields in
templating, when you expect it to be pendulum but it isn't.
There are a few things to consider:
# make UtcDateTime sqlalchemy type return pendulum
# make execution date a property of TaskInstance with appropriate getter
returning pendulum.
# Change dag.previous_schedule to return pendulum
was:
In certain circumstances previous execution dates may not be pendulum type.
For one, when reading from database, UtcDateTime returns native datetime type.
Also dag.previous_schedule returns datetime type.
So, depending on circumstances, `prev_execution_date` and
`ti.previous_ti.execution_date` may be non-pendulum.
The problem is, this leads to errors and confusion when using these fields in
templating, when you expect it to be pendulum but it isn't.
There are a few things to consider:
# make UtcDateTime sqlalchemy type return pendulum
# make execution date a property of TaskInstance with appropriate getter
returning pendulum.
# Change dag.previous_schedule to return pendulum
> prev_execution_date is not always pendulum.datetime class
> ---------------------------------------------------------
>
> Key: AIRFLOW-4788
> URL: https://issues.apache.org/jira/browse/AIRFLOW-4788
> Project: Apache Airflow
> Issue Type: Bug
> Components: core
> Affects Versions: 1.10.3
> Reporter: Daniel Standish
> Priority: Major
>
> Despite documentation on macros page, previous execution dates are in general
> not pendulum type.
> For one, when reading from database, UtcDateTime returns native datetime type.
> Also dag.previous_schedule returns datetime type.
> So, in general, `prev_execution_date` and `ti.previous_ti.execution_date` may
> be non-pendulum.
> (there are edge cases when the context var prev_* is pendulum e.g. when there
> is no DR or no schedule interval or manually triggered, but in general, no.)
> The problem is, this leads to errors and confusion when using these fields in
> templating, when you expect it to be pendulum but it isn't.
> There are a few things to consider:
> # make UtcDateTime sqlalchemy type return pendulum
> # make execution date a property of TaskInstance with appropriate getter
> returning pendulum.
> # Change dag.previous_schedule to return pendulum
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)