MCPcopy Create free account
hub / github.com/andre-salvati/databricks-template / BaseTask

Class BaseTask

src/template/baseTask.py:4–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3
4class 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)})")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected