Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import pandas as pd 

2 

3from sdc_etl_libs.sdc_filetransfer.utils.delete_files_mechanism.DeleteCriteria import \ 

4 DeleteCriteria 

5 

6 

7class ExistsInTableDeleteCriteria(DeleteCriteria): 

8 

9 def __init__(self, snowflake_connection): 

10 self.snowflake_connection = snowflake_connection 

11 

12 def get_files_to_delete(self, files): 

13 """ 

14 Filter the files whose name is present in a specific snowflake table 

15 :param files: List of sftp files 

16 :type files: List(SFTPAttributes) 

17 :return: list of filtered SFTPAttributes objects 

18 :rtype: List(SFTPAttributes) 

19 """ 

20 files_moved = pd.read_sql( 

21 self.snowflake_connection.query.format(self.snowflake_connection.database), 

22 self.snowflake_connection.connection) 

23 

24 return [file for file in files if file.filename in files_moved.values]