Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/file-formats-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ server pg_lake
options (path 's3://mybucket/table/v14.metadata.json');
```

Note that changes to the external Iceberg table will **not** be reflected in the foreign table unless you update the path to point to the new metadata file.
Note that changes to the external Iceberg table will **not** be reflected in the foreign table unless you update the path to point to the new metadata file. You can do this without dropping and recreating the table:

```sql
ALTER FOREIGN TABLE external_iceberg OPTIONS (SET path 's3://mybucket/table/v15.metadata.json');
```

## Hugging Face

Expand Down
11 changes: 11 additions & 0 deletions docs/iceberg-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,17 @@ There are a few additional limitations regarding `ALTER TABLE` compared to regul

Some advanced table management features such as declarative partitioning and inheritance are supported. Do be careful with those features, since the PostgreSQL planner does not always know how to efficiently perform aggregations across Iceberg (read: foreign) partitions.

### Altering external Iceberg tables

External read-only Iceberg foreign tables (created via `SERVER pg_lake OPTIONS (path '...metadata.json')`) support one `ALTER` operation: updating the `path` option to redirect the table to a different snapshot. All other `ALTER` operations are unsupported on external tables.

```sql
-- Redirect an external Iceberg table to a newer snapshot
ALTER FOREIGN TABLE external_iceberg OPTIONS (SET path 's3://mybucket/table/v15.metadata.json');
```

This avoids having to `DROP` and re-`CREATE` the table when a new snapshot is available, preserving any dependent views, permissions, or references.

## Vacuuming an Iceberg table

Each insert/update/delete operation on an Iceberg table results in additional data files being written. Quite often, this can result in the table being made up of many small files. The solution to that is to vacuum the table, similar to (auto)vacuum for regular heap tables. VACUUM on Iceberg tables does the following tasks:
Expand Down
15 changes: 15 additions & 0 deletions pg_lake_table/src/ddl/alter_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include "pg_lake/rest_catalog/rest_catalog.h"
#include "pg_lake/object_store_catalog/object_store_catalog.h"
#include "pg_lake/util/rel_utils.h"
#include "pg_lake/util/table_type.h"


typedef enum PgLakeDDLType
Expand Down Expand Up @@ -280,6 +281,20 @@ ProcessAlterTable(ProcessUtilityParams * processUtilityParams, void *arg)

return false;
}
else if (icebergCatalogType == NONE_CATALOG && IsExternalIcebergTable(relationId))
{
/*
* For external read-only Iceberg foreign tables created via
* SERVER pg_lake OPTIONS (path '...metadata.json'), allow
* updating the path option so callers can redirect the table to a
* newer snapshot without DROP + CREATE.
*/
List *allowedOptions = list_make1("path");

ErrorIfUnsupportedTableOptionChange(alterStmt, allowedOptions);

return false;
}

}

Expand Down