airflow.providers.apache.polaris.operators.policy¶
Operators for Polaris policies.
Polaris stores policies (for example the table-maintenance types system.snapshot-expiry,
system.data-compaction, system.metadata-compaction and system.orphan-file-removal),
attaches them to catalogs, namespaces and tables, and resolves which ones apply to a table through
inheritance. It does not execute them; PolarisGetApplicablePoliciesOperator hands the
resolved policies to downstream tasks that do.
Attributes¶
Classes¶
Create a policy in a namespace, or bring an existing one up to date. |
|
Drop a policy. |
|
Attach a policy to a catalog, namespace or table. Re-attaching the same policy is a no-op. |
|
Detach a policy from a catalog, namespace or table. |
|
Resolve the policies in effect on a catalog, namespace or table (inheritance applied by Polaris). |
Functions¶
|
Return a JSON-serializable view of a policy, with |
Module Contents¶
- airflow.providers.apache.polaris.operators.policy.ORPHAN_FILE_REMOVAL = 'system.orphan-file-removal'[source]¶
- airflow.providers.apache.polaris.operators.policy.policy_to_dict(policy)[source]¶
Return a JSON-serializable view of a policy, with
contentparsed from its JSON string.
- class airflow.providers.apache.polaris.operators.policy.PolarisCreatePolicyOperator(*, namespace, policy_name, policy_type, content=None, description=None, catalog=None, if_exists='update', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorCreate a policy in a namespace, or bring an existing one up to date.
See also
For more information, take a look at the guide: PolarisCreatePolicyOperator
- Parameters:
namespace (str | list[str]) – Namespace that holds the policy, as
"a.b"or["a", "b"].policy_name (str) – Policy name, unique within the namespace.
policy_type (str) – Policy type, for example
system.snapshot-expiry.content (dict[str, Any] | str | None) – Policy content as a dict or JSON string; Polaris validates it against the type’s schema.
description (str | None) – Optional description.
catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_exists (airflow.providers.apache.polaris.hooks.polaris.IfPolicyExists) –
"update"(default) updates content and description when they differ, so the task is declarative;"skip"leaves an existing policy unchanged;"fail"raises.polaris_conn_id – Polaris connection id.
- Returns:
The policy as a dict, with
contentparsed.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'policy_name', 'policy_type', 'content', 'description', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.policy.PolarisDropPolicyOperator(*, namespace, policy_name, detach_all=False, catalog=None, if_missing='skip', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorDrop a policy.
See also
For more information, take a look at the guide: Attaching, detaching and dropping policies
- Parameters:
namespace (str | list[str]) – Namespace that holds the policy, as
"a.b"or["a", "b"].policy_name (str) – Policy to drop.
detach_all (bool) – Detach the policy from all its targets first; otherwise Polaris refuses to drop an attached policy.
catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_missing (airflow.providers.apache.polaris.hooks.polaris.IfMissing) –
"skip"(default) or"fail".polaris_conn_id – Polaris connection id.
- Returns:
Trueif dropped,Falseif it did not exist.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'policy_name', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.policy.PolarisAttachPolicyOperator(*, namespace, policy_name, target, parameters=None, catalog=None, **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorAttach a policy to a catalog, namespace or table. Re-attaching the same policy is a no-op.
A target holds at most one inheritable policy of each type. If a different policy of the same type is already attached, the task fails without retrying; detach the other policy first.
See also
For more information, take a look at the guide: Attaching, detaching and dropping policies
- Parameters:
namespace (str | list[str]) – Namespace that holds the policy, as
"a.b"or["a", "b"].policy_name (str) – Policy to attach.
target (dict[str, Any]) –
{"type": "catalog"},{"type": "namespace", "path": ["sales"]}or{"type": "table-like", "path": ["sales", "orders"]}.parameters (dict[str, str] | None) – Optional attachment parameters.
catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.polaris_conn_id – Polaris connection id.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'policy_name', 'target', 'parameters', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.policy.PolarisDetachPolicyOperator(*, namespace, policy_name, target, catalog=None, if_missing='skip', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorDetach a policy from a catalog, namespace or table.
See also
For more information, take a look at the guide: Attaching, detaching and dropping policies
- Parameters:
namespace (str | list[str]) – Namespace that holds the policy, as
"a.b"or["a", "b"].policy_name (str) – Policy to detach.
target (dict[str, Any]) – Same shape as for
PolarisAttachPolicyOperator.catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_missing (airflow.providers.apache.polaris.hooks.polaris.IfMissing) –
"skip"(default) or"fail"when the policy is not attached there.polaris_conn_id – Polaris connection id.
- Returns:
Trueif detached,Falseif it was not attached.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'policy_name', 'target', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.policy.PolarisGetApplicablePoliciesOperator(*, catalog=None, namespace=None, table=None, policy_types=None, per_table=False, enabled_only=True, **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorResolve the policies in effect on a catalog, namespace or table (inheritance applied by Polaris).
Two output shapes:
per_table=False(default): a list of policies for the target, each{"name", "type", "description", "inheritable", "version", "content", "inherited", "defined_in"}withcontentparsed from JSON.per_table=True: one item per (table, policy) for every table innamespace, ready for dynamic task mapping:{"catalog", "namespace", "table", "policy": {...}}. Items forsystem.orphan-file-removalpolicies also carrytable_location(the table’s base location), so a downstream task can check that the policy’slocationsstay inside it.
See also
For more information, take a look at the guide: PolarisGetApplicablePoliciesOperator
- Parameters:
catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.namespace (str | list[str] | None) – Namespace to resolve for (
"a.b"or["a", "b"]). Required withper_tableortable; omit both for the catalog itself.table (str | None) – A single table in
namespace. Not allowed withper_table.policy_types (list[str] | str | None) – Only return policies of these types (a list, or one type as a string).
per_table (bool) – Resolve policies for every table in
namespace.enabled_only (bool) – Drop policies whose content has
"enable": false(default true).polaris_conn_id – Polaris connection id.
- Returns:
With
per_table=False, a list of policy dicts; withper_table=True, a list of{"catalog", "namespace", "table", "policy"}items (plus"table_location"forsystem.orphan-file-removal), one per table and policy.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'catalog', 'namespace', 'table', 'policy_types')[source]¶