sunank200 commented on a change in pull request #16821:
URL: https://github.com/apache/airflow/pull/16821#discussion_r668264380



##########
File path: airflow/providers/amazon/aws/hooks/s3.py
##########
@@ -292,18 +302,24 @@ def list_keys(
             'PageSize': page_size,
             'MaxItems': max_items,
         }
-
         paginator = self.get_conn().get_paginator('list_objects_v2')
         response = paginator.paginate(
-            Bucket=bucket_name, Prefix=prefix, Delimiter=delimiter, 
PaginationConfig=config
+            Bucket=bucket_name,
+            Prefix=prefix,
+            Delimiter=delimiter,
+            PaginationConfig=config,
+            StartAfter=start_after_key,
+        )
+        # JMESPath to query directly on paginated results
+        filtered_response = response.search(
+            "Contents[?to_string("
+            "LastModified)<='\"{}\"' && "
+            "to_string(LastModified)>='\"{"

Review comment:
       @potiuk  @dstandish @pateash I have pushed the changes just now.
   
   Created `ResponseFilter` class to parse and filter the s3 boto3 response 
based on various operations defined by the user.  This class can be extended as 
required for parsing and filtering the response based on different object 
filters operation. For now, I have added the following allowed operations.
   ```
    allowed_operations = {
           "lte": operator.le,
           "gte": operator.ge,
           "gt": operator.gt,
           "lt": operator.lt,
           "eq": operator.eq,
       }
   ```
   
   `ResponseFilter.filter(object_filter=object_filter)`  puts the filtering in 
the user's hands (through the use of a filter and would remove the ambiguity of 
strictly greater than vs greater than (and same with less than). Please refer 
to the commits in this 
[thread](https://github.com/apache/airflow/pull/16821/commits/4ef750ea486f76c98f7e5927b12fc62b4767913c)
 and [test 
changes](https://github.com/apache/airflow/pull/16821/commits/a7468c0d1591c83fd1a1c7f3ca8e32a2750e4f5b).
   
   I have added the comment for the implementation details in the code.




-- 
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