mattinbits commented on issue #21171:
URL: https://github.com/apache/airflow/issues/21171#issuecomment-1030058348


   @potiuk As an initial fix for our internal system, I replaced `func.now()` 
with `func.GETDATE()` in an internal fork which is enough to fix it for SQL 
Server. This is not enough for cross-database compatibility of course. I have 
considered creating something similar to the functionality of sqlalchemy-utc to 
airflow.utils.sqlalchemy, but I had second thoughts whether this additional 
complexity is necessary. Do we need to rely on the DB's version of "now" in 
this case? Can we instead use `timezone.utcnow()`, i.e. let the application 
server decide what "now" is and pass it as a literal to the DB? 
   
   Here are two places where `func.now()` is used in a filter, exposing this 
issue:
   https://github.com/apache/airflow/blob/main/airflow/models/dagrun.py#L294
   https://github.com/apache/airflow/blob/main/airflow/models/dag.py#L2872
   
   I can see in other places that `timezone.utcnow()` is used:
   
https://github.com/apache/airflow/blob/main/airflow/models/taskinstance.py#L293
   https://github.com/apache/airflow/blob/main/airflow/models/trigger.py#L179
   
   I'm not sure if there is a particular reason why `func.now()` is needed in 
the first two instances?
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to