pola-rs/polars · error · NotImplementedError

sink to Iceberg table with custom location provider

Error message

sink to Iceberg table with custom location provider '{location_provider_impl}'

What it means

The table property write.py.location-provider-impl registers a custom Python location provider. Polars' sink cannot honor a custom location provider when committing Iceberg data files, so it refuses with NotImplementedError naming the configured provider.

Solutions

  1. Remove the write.py.location-provider-impl property from the target table so default path resolution is used
  2. Write to that table with pyiceberg's native append/overwrite instead of Polars' sink
  3. Sink to a different table without the custom location provider

Example fix

// before
table.properties['write.py.location-provider-impl'] = 'my_mod.MyProvider'
lf.sink_iceberg(table)
// after
del table.properties['write.py.location-provider-impl']
lf.sink_iceberg(table)
Defensive patterns

Strategy: validation

Validate before calling

from pyiceberg.table.properties import TableProperties
if TableProperties.WRITE_PY_LOCATION_PROVIDER_IMPL in table.properties:
    raise NotImplementedError('custom location provider table is not sinkable')

Try / catch

try:
    lf.sink_iceberg(table)
except NotImplementedError as e:
    if 'custom location provider' in str(e):
        table.properties.pop(TableProperties.WRITE_PY_LOCATION_PROVIDER_IMPL, None)
        lf.sink_iceberg(table)
    else:
        raise

Prevention

When it happens

Trigger: Sinking to a table whose metadata properties include TableProperties.WRITE_PY_LOCATION_PROVIDER_IMPL (a custom location provider class), via sink_iceberg with any mode.

Common situations: Tables configured with a custom location-provider implementation (e.g. for non-standard object-store layouts) being written to through Polars' sink instead of pyiceberg itself.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/b54a4735f25dfa96. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/io/iceberg/_sink.py:659

        if self.schema_mode == "overwrite" and table.spec().fields:
            msg = "schema_mode='overwrite' is not supported for partitioned Iceberg tables"
            raise NotImplementedError(msg)

        partition_key_exprs = _partition_key_exprs(table, self.source_schema)

        sort_order = table.sort_order()
        if sort_order.fields and self.schema_mode == "overwrite":
            msg = "schema_mode='overwrite' is not supported for Iceberg tables with a sort order"
            raise NotImplementedError(msg)

        if location_provider_impl := table_properties.get(
            TableProperties.WRITE_PY_LOCATION_PROVIDER_IMPL
        ):
            msg = (
                "sink to Iceberg table with custom location provider"
                f" '{location_provider_impl}'"
            )
            raise NotImplementedError(msg)

        object_storage_enabled = property_as_bool(
            table_properties,
            TableProperties.OBJECT_STORE_ENABLED,
            TableProperties.OBJECT_STORE_ENABLED_DEFAULT,
        )
        object_storage_partitioned_paths = (
            property_as_bool(
                table_properties,
                TableProperties.WRITE_OBJECT_STORE_PARTITIONED_PATHS,
                TableProperties.WRITE_OBJECT_STORE_PARTITIONED_PATHS_DEFAULT,
            )
            if object_storage_enabled
            else None
        )

        schema, arrow_schema = self._schemas_for_write(table)
        lf = wrap_ldf(plf)

View on GitHub (pinned to fe841f959e)