Skip to content

feat(plugin-iceberg): Write native Iceberg data to the location provider's directory (#28803) - #28803

Open
apurva-meta wants to merge 1 commit into
prestodb:masterfrom
apurva-meta:export-D126539789
Open

apurva-meta wants to merge 1 commit into
prestodb:masterfrom
apurva-meta:export-D126539789

Conversation

@apurva-meta

@apurva-meta apurva-meta commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694

Native workers write Iceberg data files to <outputPath>/data/<partition>/<file>, where outputPath is table.location(). The location provider never chooses the directory, so write.data.path is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while table.location() still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from <directory>/<index>/<file>, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:

  • outputPath: the directory for new data and delete files, resolved on the coordinator from the location provider.
  • includePartitionPaths (new, optional): false means outputPath is the directory every file goes into, with no partition subdirectories. Absent or true keeps today's meaning: outputPath is the table location, and files go under <outputPath>/data/<partition>/. Neither field is a table property.

The coordinator resolves them through IcebergWriteLocation, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and rewrite_data_files. Read handles are unchanged, and so is the handle finishUpdate builds at commit time: it keeps table.location() and the partition layout, and does not resolve a location after the workers have written.

Table's provider What the coordinator sends
Registration (unified catalog) the commit's registered directory, includePartitionPaths=false
Anything else unchanged: table.location(), table properties, includePartitionPaths=true

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (PrestoHmsIcebergCatalog.prepareWriteLocation).

When includePartitionPaths is false, the native adapter uses outputPath as-is and writes flat (D126539787). Otherwise it keeps appending /data with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable std::shared_ptr<bool>, like fullRefreshRequired: the generated header, the special/*.inc sources, the presto_protocol_iceberg.yml overrides, and Boolean mapped to bool in java-to-struct-json.py.

Rollout: backward compatible, so coordinators and workers can roll out in either order.

  • Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
  • New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same outputPath as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
  • OSS presto-iceberg behaviour does not change: the public connector always sends the table location with includePartitionPaths=true, the meaning it had before.
== NO RELEASE NOTE ==

Reviewed By: sam0x1C

Differential Revision: D126539789

@prestodb-ci

Copy link
Copy Markdown
Contributor

Failed to query author email: Error 1045 (28000): Access denied for user 'presto'@'10.167.107.7' (using password: YES)

@sourcery-ai

sourcery-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Data structures

Add includePartitionPaths to the writable Java handles, preserving the legacy partitioned layout when older coordinators omit the field.

  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergDeleteTableHandle.java L67, L83-84
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergDistributedProcedureHandle.java L41, L56-57
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergInsertTableHandle.java L47-147 (10 small edits)
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergOutputTableHandle.java L36, L49-50
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergWritableTableHandle.java L142-147 (+7 small edits)

API

Extend the Java/C++ Iceberg handle protocol with the nullable layout field and serialize it compatibly across coordinator and worker versions.

  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.cpp L1001-1007, L1103-1109, L1569-1575 (+5 small edits)
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.h L231-355 (4 small edits)
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/presto_protocol_iceberg.yml L75-77, L84-94
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/special/IcebergDeleteTableHandle.cpp.inc L65-71, L167-173
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/special/IcebergDeleteTableHandle.hpp.inc L26
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/special/IcebergDistributedProcedureHandle.hpp.inc L27
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/special/IcebergInsertTableHandle.hpp.inc L26
  • presto-native-execution/presto_cpp/presto_protocol/connector/iceberg/special/IcebergOutputTableHandle.hpp.inc L26
  • presto-native-execution/presto_cpp/presto_protocol/java-to-struct-json.py L27, L51, L68

Uses of the API

Resolve and pass the write location through each coordinator write path, including create, insert, merge, delete, update, refresh, and file rewrite.

  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java L787-791, L805-809, L1284-1288 (+8 small edits)
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java L433
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergNativeMetadata.java L508, L515-519
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RewriteDataFilesProcedure.java L26, L285, L292-296

Implementation

Define the coordinator write-location value and the provider-directory resolution used to select the output directory and flat-versus-partitioned layout.

  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java L903-933
  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergWriteLocation.java L1-74

Translate the handle layout into Velox location handles so explicit flat writes use the supplied directory while legacy writes retain /data and partition paths.

  • presto-native-execution/presto_cpp/main/connectors/IcebergPrestoToVeloxConnector.cpp L537-562, L893-905, L941-953 (+8 small edits)

Tests

Cover write-location selection, handle compatibility, protocol round-tripping, and native flat-versus-legacy path translation.

  • presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergInsertTableHandle.java L50, L103
  • presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergWriteLocation.java L1-266
  • presto-native-execution/presto_cpp/main/types/tests/PrestoToVeloxConnectorTest.cpp L1667, L1682-1684, L1813-1962

Other changes

Files not grouped.

  • presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergPageSinkProvider.java L108, L134

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java" line_range="787-789" />
<code_context>
         return finishInsert(session, (IcebergOutputTableHandle) tableHandle, fragments);
     }

+    protected IcebergWriteLocation getWriteLocation(ConnectorSession session, Table icebergTable)
+    {
+        return IcebergWriteLocation.forTable(icebergTable);
+    }
+
</code_context>
<issue_to_address>
**Provider writes use stale directories**

When a table uses a per-commit registration location provider, `getWriteLocation` returns `forTable` in the inherited default, so production write paths pass `table.location()` and partition paths to workers instead of selecting the provider location; files land outside the directory registered for the commit.

Resolve the provider-selected `IcebergWriteLocation` in the production metadata hook and route writes through it.

Also at `presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RewriteDataFilesProcedure.java:285`.
</issue_to_address>

### Comment 2
<location path="presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RewriteDataFilesProcedure.java" line_range="285" />
<code_context>
                         .add(new SortField(Z_ORDER.getId(), com.facebook.presto.common.block.SortOrder.ASC_NULLS_LAST))
                         .build();
             }
+            IcebergWriteLocation writeLocation = IcebergWriteLocation.forTable(icebergTable);
             return new IcebergDistributedProcedureHandle(
                     tableHandle.getSchemaName(),
</code_context>
<issue_to_address>
**Rewrites use stale directories**

When `rewrite_data_files` runs for a table whose provider selects a per-commit directory, `RewriteDataFilesProcedure` calls `forTable` directly, so rewrite workers receive `table.location()` and the legacy partition layout instead of the provider-selected directory; rewritten files land outside the directory registered for the commit.

Resolve the provider-selected write location for rewrite tasks instead of calling `forTable` directly.
</issue_to_address>

### Comment 3
<location path="presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java" line_range="2861" />
<code_context>
         validateGeospatialWrite(icebergTable);
         // Return value (file schema) is intentionally ignored here; IcebergFileWriterFactory recomputes it per writer.
         UnknownUtils.validateWritable(icebergTable.schema());
+        IcebergWriteLocation writeLocation = getWriteLocation(session, icebergTable);
         return new IcebergInsertTableHandle(
                 table.getSchemaName(),
</code_context>
<issue_to_address>
**Updates change legacy write layout**

When a copy-on-write UPDATE runs for a table whose write-location hook selects a per-commit directory, `finishUpdate` resolves `getWriteLocation` and propagates its location and partition-path flag in the output handle, so copy-on-write UPDATEs use the provider-selected directory and layout instead of the legacy table location and partition paths, contrary to the stated scope.

Keep copy-on-write UPDATEs on the legacy table location and partition paths, and avoid resolving a per-commit location after workers have written their fragments.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

.add(new SortField(Z_ORDER.getId(), com.facebook.presto.common.block.SortOrder.ASC_NULLS_LAST))
.build();
}
IcebergWriteLocation writeLocation = IcebergWriteLocation.forTable(icebergTable);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Rewrites use stale directories

When rewrite_data_files runs for a table whose provider selects a per-commit directory, RewriteDataFilesProcedure calls forTable directly, so rewrite workers receive table.location() and the legacy partition layout instead of the provider-selected directory; rewritten files land outside the directory registered for the commit.

Resolve the provider-selected write location for rewrite tasks instead of calling forTable directly.

Prompt for AI agents
In `presto-iceberg/src/main/java/com/facebook/presto/iceberg/procedure/RewriteDataFilesProcedure.java` at line 285:

**Rewrites use stale directories**

When `rewrite_data_files` runs for a table whose provider selects a per-commit directory, `RewriteDataFilesProcedure` calls `forTable` directly, so rewrite workers receive `table.location()` and the legacy partition layout instead of the provider-selected directory; rewritten files land outside the directory registered for the commit.

Resolve the provider-selected write location for rewrite tasks instead of calling `forTable` directly.

@meta-codesync meta-codesync Bot changed the title [Iceberg][Presto] Write native Iceberg data to the location provider's directory [Iceberg][Presto] Write native Iceberg data to the location provider's directory (#28803) Nov 16, 2026
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 16, 2026
…s directory (prestodb#28803)

Summary:

Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles and copy-on-write UPDATE are unchanged.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

Differential Revision: D126539789
@meta-codesync meta-codesync Bot changed the title [Iceberg][Presto] Write native Iceberg data to the location provider's directory (#28803) [Iceberg][Presto] Write native Iceberg data to the location provider's directory Nov 16, 2026
@meta-codesync meta-codesync Bot changed the title [Iceberg][Presto] Write native Iceberg data to the location provider's directory feat(plugin-iceberg): Write native Iceberg data to the location provider's directory Nov 16, 2026
@meta-codesync meta-codesync Bot changed the title feat(plugin-iceberg): Write native Iceberg data to the location provider's directory feat(plugin-iceberg): Write native Iceberg data to the location provider's directory (#28803) Nov 16, 2026
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 16, 2026
…der's directory (prestodb#28803)

Summary:

Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles and copy-on-write UPDATE are unchanged.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Differential Revision: D126539789
@meta-codesync meta-codesync Bot changed the title feat(plugin-iceberg): Write native Iceberg data to the location provider's directory (#28803) feat(plugin-iceberg): Write native Iceberg data to the location provider's directory Nov 16, 2026
@apurva-meta
apurva-meta force-pushed the export-D126539789 branch 2 times, most recently from e728558 to 9d6d67e Compare November 16, 2026 23:57
@meta-codesync meta-codesync Bot changed the title feat(plugin-iceberg): Write native Iceberg data to the location provider's directory feat(plugin-iceberg): Write native Iceberg data to the location provider's directory (#28803) Nov 18, 2026
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 18, 2026
…der's directory (prestodb#28803)

Summary:

Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Differential Revision: D126539789
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 19, 2026
…der's directory (prestodb#28803)

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694


Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Differential Revision: D126539789
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 20, 2026
…der's directory (prestodb#28803)

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694


Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Reviewed By: sam0x1C

Differential Revision: D126539789
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 20, 2026
…der's directory (prestodb#28803)

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694


Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Reviewed By: sam0x1C

Differential Revision: D126539789
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 23, 2026
…der's directory (prestodb#28803)

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694


Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Reviewed By: sam0x1C

Differential Revision: D126539789
apurva-meta added a commit to apurva-meta/presto that referenced this pull request Nov 23, 2026
…der's directory (prestodb#28803)

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694


Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Reviewed By: sam0x1C

Differential Revision: D126539789
…der's directory (prestodb#28803)

Summary:
X-link: https://github.com/facebookexternal/presto-facebook/pull/3694


Native workers write Iceberg data files to `<outputPath>/data/<partition>/<file>`, where `outputPath` is `table.location()`. The location provider never chooses the directory, so `write.data.path` is ignored. For tables in the unified Iceberg catalog the result is wrong. That catalog's RegistrationLocationProvider registers a new Warm Storage directory for every commit, while `table.location()` still points at the previous commit's directory. Files land in a sealed directory the new commit does not own. Replication and read routing parse the replication index from `<directory>/<index>/<file>`, so the partition subdirectories break them as well.

This implements the contract from sam28's design doc ("Handoff: native Presto Iceberg writes use the location provider", §3), reusing his D123720654, D123720657, D125787241, D125787243 and D125787244. The rule: the location provider selects the directory, and the writer adds no directory the provider did not select.

Every writable handle carries two fields:
- `outputPath`: the directory for new data and delete files, resolved on the coordinator from the location provider.
- `includePartitionPaths` (new, optional): `false` means `outputPath` is the directory every file goes into, with no partition subdirectories. Absent or `true` keeps today's meaning: `outputPath` is the table location, and files go under `<outputPath>/data/<partition>/`. Neither field is a table property.

The coordinator resolves them through `IcebergWriteLocation`, the same way for INSERT, CTAS, DELETE, MERGE, materialized-view refresh and `rewrite_data_files`. Read handles are unchanged, and so is the handle `finishUpdate` builds at commit time: it keeps `table.location()` and the partition layout, and does not resolve a location after the workers have written.

| Table's provider | What the coordinator sends |
|---|---|
| Registration (unified catalog) | the commit's registered directory, `includePartitionPaths=false` |
| Anything else | unchanged: `table.location()`, table properties, `includePartitionPaths=true` |

Only tables whose catalog vends a per-commit directory change behaviour. Every other table, Java or native, writes exactly where it does today.

The registration row is supplied by the catalog adapter in the next diff (`PrestoHmsIcebergCatalog.prepareWriteLocation`).

When `includePartitionPaths` is `false`, the native adapter uses `outputPath` as-is and writes flat (D126539787). Otherwise it keeps appending `/data` with partition subdirectories, as today. Partition values stay in the commit metadata. The protocol structs gain the field as nullable `std::shared_ptr<bool>`, like `fullRefreshRequired`: the generated header, the `special/*.inc` sources, the `presto_protocol_iceberg.yml` overrides, and `Boolean` mapped to `bool` in `java-to-struct-json.py`.

Rollout: backward compatible, so coordinators and workers can roll out in either order.
- Old coordinator, new workers: the field is absent, so Java and native workers keep the legacy layout.
- New coordinator, old workers: for every table except unified-catalog ones, the handle carries the same `outputPath` as today, and old workers ignore the extra field. Unified-catalog tables only get a correct directory once their workers are new. Until then they behave as today, already wrong for those tables, which is what this diff fixes.
- OSS presto-iceberg behaviour does not change: the public connector always sends the table location with `includePartitionPaths=true`, the meaning it had before.

```
== NO RELEASE NOTE ==
```

Reviewed By: sam0x1C

Differential Revision: D126539789

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants