"""StageLoader for the Peloton Monthly Ingestion Workflow.""" from feed_ingestion.common.staging_raw_sf.snowflake_stage_loader import ( StageLoader, ) class PelotonSL(StageLoader): """Load every country file for a reporting month in a single INSERT. The Peloton monthly delivery is one file per country, all archived to the same S3 directory. The report interleaves header (``A``), summary (``M``) and trailer (``Z``) records with the detail (``N``) rows, and the country is a data column - so instead of the per-file loop of the base class we load the whole stage directory once, keeping only the ``N`` rows. """ def load_staging_raw_table( self, staging_raw_table, source_files_dict, date, stage_name, query_name='load_staging_raw', **kwargs): """Load the ``N`` (detail) rows from every archived file. Args: staging_raw_table (str): Destination staging_raw table. source_files_dict (dict): Metadata of the archived files (unused - the whole stage directory is loaded in one statement). date (str): Reporting date (YYYY-MM-DD). stage_name (str): Name of the Snowflake stage over the archive dir. query_name (str): Name of the load query (without extension). """ self.resolve_sql_loader_and_execute( query_name, params=dict( db=self.executor.sf_config['db'], schema=self.executor.sf_config['schema'], stage=stage_name, staging_raw_table=staging_raw_table, download_date=date))