"""Component for loading source files directly to staging_raw via stage.""" from datetime import datetime from feed_ingestion.common.staging_raw_sf.snowflake_stage_loader import ( StageLoader, ) class GfKStreamingSL(StageLoader): """StageLoader class for the GfK Streaming ETL.""" def load_staging_raw_table( self, staging_raw_table, source_files_dict, date, stage_name, query_name='load_staging_raw', **kwargs, ): """Load the staging_raw data from the Snowflake stage. Args: staging_raw_table (str): A table name in Snowflake. source_files_dict (dict): Not used in this class. date (str): Date of the data being processed (YYYY-MM-DD). stage_name (str): Name of Snowflake stage containing source files. query_name (str): File name of the query (without .sql extension). kwargs (dict): Additional args to the SQL template as params. """ ingestion_time = datetime.now().replace(microsecond=0) params = dict( db=self.executor.sf_config['db'], schema=self.executor.sf_config['schema'], stage=stage_name, staging_raw_table=staging_raw_table, pattern='.*/*.csv', download_date=date, ingestion_time=ingestion_time, ) self.resolve_sql_loader_and_execute(query_name, params=params)