"""Snowflake connector class for Deezer tasks.""" from snowflake_connector.etl_connector import SQLLoader from feed_ingestion.common.marketshare_sf.base_executor import \ SnowflakeSQLExecutorMS from feed_ingestion.flows.deezer_marketshare import config # Load SQL templates sql_loader = SQLLoader(__file__) class DeezerMarketshareSF(SnowflakeSQLExecutorMS): """Helper class to abstract Snowflake operations.""" @property def feed_name(self): """Name of the feed. Should match dir name of this feed, feed_name in config.py of a feed, and a key of executors dict in feed_ingestion/common/ fact_analytics_sf/__init__.py file. Returns: str: Feed name, e.g. 'amazon_unlimited'. """ return config.feed_name @property def staging_raw_table(self): """Name of the staging_raw table for the feed. Returns: str: staging_raw_{feed} table name. """ return config.snowflake_table_names['staging_raw'] @property def storeid(self): """Storeid of feed data. Should match dim_store and feed config value. Returns: integer: Feed's storeid. """ return 348 def load_marketshare_data(self, date): """Load data in main_marketshare_table. Args: date (str): Date of the data being process (YYYY-MM-DD). """ params = dict( db=self.sf_config['db'], schema=self.sf_config['schema'], main_market_share_table=self.main_marketshare_table, staging_raw_table=self.staging_raw_table, storeid=self.storeid, date=date) self.execute_query(sql_loader, 'load_main_market_share', params=params)