airflow.providers.apache.polaris.operators.table¶
Operators that manage Iceberg table definitions in a Polaris catalog.
They create, drop, register, rename and set properties of tables. Reading and writing table data is left to pyiceberg and the engines (Spark, Trino, …).
Classes¶
Create an Iceberg table in a Polaris catalog. |
|
Drop an Iceberg table from a Polaris catalog. |
|
Set and/or remove properties of an Iceberg table, committing only what would change. |
|
Register an existing Iceberg table in a Polaris catalog from its metadata file. |
|
Rename an Iceberg table, optionally moving it to another namespace of the same catalog. |
Functions¶
|
Return a summary of a table as returned by the hook (Iceberg REST |
Module Contents¶
- airflow.providers.apache.polaris.operators.table.table_to_dict(result, namespace, table)[source]¶
Return a summary of a table as returned by the hook (Iceberg REST
LoadTableResultJSON).The response’s
configandstorage-credentialsare left out on purpose: they can carry storage credentials, which must not reach XCom.
- class airflow.providers.apache.polaris.operators.table.PolarisCreateTableOperator(*, namespace, table, schema, partition_spec=None, sort_order=None, location=None, properties=None, catalog=None, if_exists='skip', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorCreate an Iceberg table in a Polaris catalog.
The table’s definition uses the JSON shapes of the Iceberg REST specification.
See also
For more information, take a look at the guide: PolarisCreateTableOperator
- Parameters:
namespace (str | list[str]) – Namespace of the table, as
"a.b"or["a", "b"].table (str) – Table name.
schema (dict[str, Any]) – The schema, for example
{"type": "struct", "fields": [{"id": 1, "name": "id", "type": "long", "required": False}]}.partition_spec (dict[str, Any] | None) – Optional partition spec, for example
{"fields": [{"source-id": 1, "field-id": 1000, "name": "id_bucket", "transform": "bucket[16]"}]}.sort_order (dict[str, Any] | None) – Optional write order, for example
{"order-id": 1, "fields": [{"source-id": 1, "transform": "identity", "direction": "asc", "null-order": "nulls-first"}]}.location (str | None) – Optional base location; defaults to one derived from the namespace’s.
properties (dict[str, str] | None) – Optional table properties, for example
{"format-version": "3"}; values are strings.catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_exists (airflow.providers.apache.polaris.hooks.polaris.IfExists) –
"skip"(default) succeeds and returns the existing table unchanged;"fail"raises.polaris_conn_id – Polaris connection id.
- Returns:
{"namespace", "name", "table_uuid", "location", "metadata_location", "format_version"}.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'schema', 'partition_spec', 'sort_order', 'location',...[source]¶
- class airflow.providers.apache.polaris.operators.table.PolarisDropTableOperator(*, namespace, table, purge=False, catalog=None, if_missing='skip', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorDrop an Iceberg table from a Polaris catalog.
See also
For more information, take a look at the guide: PolarisDropTableOperator
- Parameters:
namespace (str | list[str]) – Namespace of the table, as
"a.b"or["a", "b"].table (str) – Table name.
purge (bool) – Also delete the table’s data and metadata files (default
False: only the catalog entry is removed). Irreversible; Polaris refuses it (HTTP 403) unless the catalog propertypolaris.config.drop-with-purge.enabledis"true"or the server enables theDROP_WITH_PURGE_ENABLEDfeature.catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_missing (airflow.providers.apache.polaris.hooks.polaris.IfMissing) –
"skip"(default) succeeds when the table does not exist;"fail"raises.polaris_conn_id – Polaris connection id.
- Returns:
Trueif the table was dropped,Falseif it did not exist.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.table.PolarisUpdateTablePropertiesOperator(*, namespace, table, updates=None, removals=None, catalog=None, **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorSet and/or remove properties of an Iceberg table, committing only what would change.
See also
For more information, take a look at the guide: PolarisUpdateTablePropertiesOperator
- Parameters:
namespace (str | list[str]) – Namespace of the table, as
"a.b"or["a", "b"].table (str) – Table name.
updates (dict[str, str] | None) – Properties to set, for example
{"history.expire.max-snapshot-age-ms": "604800000"}. Values are strings.removals (list[str] | None) – Property keys to remove; keys that do not exist are ignored. A key cannot be both updated and removed.
catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.polaris_conn_id – Polaris connection id.
- Returns:
{"updated": [...], "removed": [...], "properties": {...}}: the keys this run changed and the table’s properties afterwards.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'updates', 'removals', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.table.PolarisRegisterTableOperator(*, namespace, table, metadata_location, catalog=None, if_exists='skip', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorRegister an existing Iceberg table in a Polaris catalog from its metadata file.
See also
For more information, take a look at the guide: PolarisRegisterTableOperator
- Parameters:
namespace (str | list[str]) – Namespace to register the table in, as
"a.b"or["a", "b"].table (str) – Table name in Polaris.
metadata_location (str) – The table’s current
metadata.jsonfile, within the catalog’s allowed locations.catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_exists (airflow.providers.apache.polaris.hooks.polaris.IfExists) –
"skip"(default) succeeds and returns the existing table without comparing its metadata location;"fail"raises.polaris_conn_id – Polaris connection id.
- Returns:
{"namespace", "name", "table_uuid", "location", "metadata_location", "format_version"}.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'metadata_location', 'catalog')[source]¶
- class airflow.providers.apache.polaris.operators.table.PolarisRenameTableOperator(*, namespace, table, new_table, new_namespace=None, catalog=None, if_missing='skip', **kwargs)[source]¶
Bases:
airflow.providers.apache.polaris.operators.base.PolarisCatalogBaseOperatorRename an Iceberg table, optionally moving it to another namespace of the same catalog.
See also
For more information, take a look at the guide: PolarisRenameTableOperator
- Parameters:
namespace (str | list[str]) – Current namespace of the table, as
"a.b"or["a", "b"].table (str) – Current table name.
new_table (str) – New table name.
new_namespace (str | list[str] | None) – New namespace; defaults to the current one. Since Polaris 1.9.0 a move is refused (HTTP 403) unless the table’s files lie within the new namespace’s location or the catalog enables
ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalog (str | None) – Catalog; defaults to the connection’s
default_catalog.if_missing (airflow.providers.apache.polaris.hooks.polaris.IfMissing) –
"skip"(default) succeeds when the table is gone but its new name exists, i.e. it was already renamed. A table missing under both names always fails.polaris_conn_id – Polaris connection id.
- Returns:
Trueif the table was renamed,Falseif it had already been renamed.
- template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'new_table', 'new_namespace', 'catalog')[source]¶