| 2 | |
| 3 | |
| 4 | class BaseTask: |
| 5 | def __init__(self, config): |
| 6 | self.config = config |
| 7 | self.spark = config.get_spark() |
| 8 | self.logger = logging.getLogger(f"template.{self.__class__.__name__}") |
| 9 | |
| 10 | def cluster_by(self, table: str, *cols: str) -> None: |
| 11 | """Set Delta liquid-clustering keys on an existing table. |
| 12 | |
| 13 | Metadata-only and idempotent: re-running just re-asserts the keys. |
| 14 | Subsequent writes (append / MERGE / replaceWhere) and OPTIMIZE cluster |
| 15 | the data by these columns. Only pays off on accumulating tables — we do |
| 16 | not cluster full-overwrite tables (raw.*), where clustering can't amortize. |
| 17 | """ |
| 18 | self.spark.sql(f"ALTER TABLE {table} CLUSTER BY ({', '.join(cols)})") |
nothing calls this directly
no outgoing calls
no test coverage detected