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

PolarisCreateTableOperator

Create an Iceberg table in a Polaris catalog.

PolarisDropTableOperator

Drop an Iceberg table from a Polaris catalog.

PolarisUpdateTablePropertiesOperator

Set and/or remove properties of an Iceberg table, committing only what would change.

PolarisRegisterTableOperator

Register an existing Iceberg table in a Polaris catalog from its metadata file.

PolarisRenameTableOperator

Rename an Iceberg table, optionally moving it to another namespace of the same catalog.

Functions

table_to_dict(result, namespace, table)

Return a summary of a table as returned by the hook (Iceberg REST LoadTableResult JSON).

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 LoadTableResult JSON).

The response’s config and storage-credentials are 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.PolarisCatalogBaseOperator

Create 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]
template_fields_renderers[source]
namespace[source]
table[source]
schema[source]
partition_spec = None[source]
sort_order = None[source]
location = None[source]
properties = None[source]
catalog = None[source]
if_exists = 'skip'[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

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.PolarisCatalogBaseOperator

Drop 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 property polaris.config.drop-with-purge.enabled is "true" or the server enables the DROP_WITH_PURGE_ENABLED feature.

  • 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:

True if the table was dropped, False if it did not exist.

template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'catalog')[source]
namespace[source]
table[source]
purge = False[source]
catalog = None[source]
if_missing = 'skip'[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

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.PolarisCatalogBaseOperator

Set 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]
template_fields_renderers[source]
namespace[source]
table[source]
updates = None[source]
removals = None[source]
catalog = None[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

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.PolarisCatalogBaseOperator

Register 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.json file, 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]
namespace[source]
table[source]
metadata_location[source]
catalog = None[source]
if_exists = 'skip'[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

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.PolarisCatalogBaseOperator

Rename 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:

True if the table was renamed, False if it had already been renamed.

template_fields: collections.abc.Sequence[str] = ('polaris_conn_id', 'namespace', 'table', 'new_table', 'new_namespace', 'catalog')[source]
namespace[source]
table[source]
new_table[source]
new_namespace = None[source]
catalog = None[source]
if_missing = 'skip'[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

Was this entry helpful?