from abc import abstractmethod from typing import Any, Dict from ...base import BaseStep from ...mixins import PGMixin __all__ = ["AggregatesSwitchBase"] class AggregatesSwitchBase(PGMixin, BaseStep): depends_on = {"utils.switch_ready"} @property @abstractmethod def table_name(self) -> str: pass @property def alt_table_name(self) -> str: # TODO: use self.timestamp instead of "alt" # but first find a way to delete tables by wildcard like "DROP TABLE TABLE_NAME_*" return f"{self.table_name}_alt" def process(self) -> Dict[str, Any]: self.swap_tables(self.table_name, self.alt_table_name) return {"status": "ok"}