airflow.providers.apache.polaris.utils.maintenance¶
Turn resolved Polaris table-maintenance policies into Iceberg’s Spark procedure calls.
Polaris stores and resolves maintenance policies but does not run them. to_spark_sql()
turns one item returned by PolarisGetApplicablePoliciesOperator(per_table=True) into the
CALL statement that applies it, for a Spark task to run. It makes no network calls.
Attributes¶
Functions¶
|
Return the Iceberg Spark |
Module Contents¶
- airflow.providers.apache.polaris.utils.maintenance.to_spark_sql(item, *, spark_catalog=None, strict=False, dry_run=False)[source]¶
Return the Iceberg Spark
CALLstatement that applies one resolved maintenance policy.Policy settings map to procedure arguments as follows; times become UTC timestamps counted back from now:
system.snapshot-expiry->expire_snapshots:config.max_snapshot_age_days->older_than,config.min_snapshot_to_keep->retain_last.system.data-compaction->rewrite_data_files:config.compaction_strategy(bin-packorsort) ->strategy,config.target_file_size_bytesand every hyphenated key (an Iceberg rewrite option, e.g.min-input-files) ->options.system.metadata-compaction->rewrite_manifests.system.orphan-file-removal->remove_orphan_files:max_orphan_file_age_in_days(at least 1, as Iceberg requires) ->older_than; each oflocations-> one statement withlocation, which must lie inside the table’s location.
Other
configkeys named inPASS_THROUGHare passed as the procedure argument of the same name. Any other key is dropped with a warning, or raises withstrict=True.- Parameters:
item (dict[str, Any]) – One item of
PolarisGetApplicablePoliciesOperator(per_table=True).spark_catalog (str | None) – Name of the Polaris catalog in Spark, used for the
CALLand to qualify the table; defaults to the Polaris catalog name.strict (bool) – Raise on
configkeys this function does not map, instead of dropping them.dry_run (bool) – Only list orphan files (
dry_run => true). Raises for other policy types, which have no dry run.
- Returns:
The statement; for an orphan-file policy with several
locations, one statement per location, separated by;(spark-sqlandSparkSqlOperatorrun them all; PySpark’sspark.sql()takes one at a time).- Raises:
PolarisInvalidArgumentError – For a policy that is disabled, of an unsupported type or schema version, or that holds invalid values.
- Return type: