"""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, ) from feed_ingestion.util.aws import athena class AmazonDataPulseSL(StageLoader): """StageLoader class.""" def load_staging_raw_table( self, staging_raw_table, source_files_dict, date, stage_name, query_name, **kwargs, ): """Load the temp_staging_raw data to the feed's staging_raw table. 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 process (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=f'.*/{athena.PARQUET_FILE_PATTERN}', download_date=date, ingestion_time=ingestion_time, **kwargs, ) self.resolve_sql_loader_and_execute(query_name, params=params)