You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ellisms (via GitHub)" <gi...@apache.org> on 2024/09/25 11:45:29 UTC

[PR] S3DeleteObjects Operator: Handle dates passed as strings [airflow]

ellisms opened a new pull request, #42464:
URL: https://github.com/apache/airflow/pull/42464

   
   ---
   closes: #42363
   
    `{{ macros.ds_add() }}` returns a string representation of a date, causing the operator to fail the comparison check. Added a date parser to parse strings into dates.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] S3DeleteObjects Operator: Handle dates passed as strings [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #42464:
URL: https://github.com/apache/airflow/pull/42464#discussion_r1775526283


##########
airflow/providers/amazon/aws/operators/s3.py:
##########
@@ -530,6 +533,13 @@ def execute(self, context: Context):
 
         if isinstance(self.keys, (list, str)) and not self.keys:
             return
+        # handle case where dates are strings, specifically when sent as template fields and macros.
+        if isinstance(self.to_datetime, str):
+            self.to_datetime = parser.parse(self.to_datetime).replace(tzinfo=pytz.UTC)
+
+        if isinstance(self.from_datetime, str):
+            self.from_datetime = parser.parse(self.from_datetime).replace(tzinfo=pytz.UTC)
+

Review Comment:
   We should add `str` as type in the signature then?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] S3DeleteObjects Operator: Handle dates passed as strings [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck merged PR #42464:
URL: https://github.com/apache/airflow/pull/42464


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] S3DeleteObjects Operator: Handle dates passed as strings [airflow]

Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on PR #42464:
URL: https://github.com/apache/airflow/pull/42464#issuecomment-2374753359

   Static checks are failing


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org