You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Adam Andersen Læssøe (JIRA)" <ji...@apache.org> on 2019/07/12 09:44:00 UTC

[jira] [Updated] (AIRFLOW-4938) next_execution_date is not a Pendulum object

     [ https://issues.apache.org/jira/browse/AIRFLOW-4938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Andersen Læssøe updated AIRFLOW-4938:
------------------------------------------
    Description: 
When templating, it seems `execution_date` refers to a Pendulum object while `next_execution_date` refers to a native `datetime` object.
 This is inconsistent, and contrary to what the docs say, so I'm thinking it's a bug.

*Observation*
 Airflow is configured to run in timezone Copenhagen.
 I have a where clause like
 ```
{code:java}
WHERE inserted_at >= '{{execution_date}}' AND inserted_at < '{{next_execution_date}}'{code}
I execute the task using `airflow test ... 2019-07-01`.
 The clause is rendered as
{code:java}
WHERE inserted_at >= '2019-07-01T00:00:00+02:00' AND inserted_at < '2019-07-01 22:00:00+00:00'{code}
 

Note how `execution_date` is printed as UTC+2, while `next_execution_date` is printed in UTC. I believe the timestamps actually decribe the correct interval, but to be certain I tried explicitly converting to UTC:
{code:java}
WHERE inserted_at >= '{{execution_date.in_tz('UTC')}}' AND inserted_at < '{{next_execution_date.in_tz('UTC')}}'{code}
I then get an error that datetime.datetime does not have an in_tz method.

 

  was:
When templating, it seems `execution_date` refers to a Pendulum object while `next_execution_date` refers to a native `datetime` object.
This is inconsistent, and contrary to what the docs say, so I'm thinking it's a bug.

*Observation*
Airflow is configured to run in timezone Copenhagen.
I have a where clause like
```
{code:java}
WHERE inserted_at >= '{{execution_date}}' AND inserted_at < '{{next_execution_date}}'{code}
I execute the task using `airflow test ... 2019-07-01`.
The clause is rendered as
{code:java}
WHERE inserted_at >= '2019-07-01T00:00:00+02:00' AND inserted_at < '2019-07-01 22:00:00+00:00'{code}
 

Note how `execution_date` is printed as utc+2, while `next_execution_date` is printed in UTC. I believe the timestamps actually decribe the correct interval, but to be certain I tried explicitly converting to UTC:
{code:java}
WHERE inserted_at >= '{{execution_date.in_tz('UTC')}}' AND inserted_at < '{{next_execution_date.in_tz('UTC')}}'{code}
I then get an error that datetime.datetime does not have an in_tz method.

 


> next_execution_date is not a Pendulum object
> --------------------------------------------
>
>                 Key: AIRFLOW-4938
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4938
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: models
>    Affects Versions: 1.10.2
>         Environment: Airlfow 1.10.2 in Docker using puckel docker image.
> Configured for timezone Copenhagen
>            Reporter: Adam Andersen Læssøe
>            Priority: Major
>
> When templating, it seems `execution_date` refers to a Pendulum object while `next_execution_date` refers to a native `datetime` object.
>  This is inconsistent, and contrary to what the docs say, so I'm thinking it's a bug.
> *Observation*
>  Airflow is configured to run in timezone Copenhagen.
>  I have a where clause like
>  ```
> {code:java}
> WHERE inserted_at >= '{{execution_date}}' AND inserted_at < '{{next_execution_date}}'{code}
> I execute the task using `airflow test ... 2019-07-01`.
>  The clause is rendered as
> {code:java}
> WHERE inserted_at >= '2019-07-01T00:00:00+02:00' AND inserted_at < '2019-07-01 22:00:00+00:00'{code}
>  
> Note how `execution_date` is printed as UTC+2, while `next_execution_date` is printed in UTC. I believe the timestamps actually decribe the correct interval, but to be certain I tried explicitly converting to UTC:
> {code:java}
> WHERE inserted_at >= '{{execution_date.in_tz('UTC')}}' AND inserted_at < '{{next_execution_date.in_tz('UTC')}}'{code}
> I then get an error that datetime.datetime does not have an in_tz method.
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)