test(native): Add Iceberg V3 end-to-end tests for native workers (#28699) #28699
<!-- Generated by sourcery-ai[bot]: start review_guide -->
Reviewer's Guide
Introduces comprehensive native-worker Iceberg V3 end-to-end coverage, comparing native execution with Java workers over a shared HIVE warehouse across Parquet and ORC, while explicitly documenting and asserting current native limitations.
File-Level Changes
| Change | Details | Files |
| ------ | ------- | ----- |
| Adds a shared native-versus-Java Iceberg V3 test harness and reusable table/file metadata helpers. | <ul><li>Configures native and expected Java query runners against the same HIVE-backed warehouse.</li><li>Adds explicit V3 and V2 merge-on-read table creation helpers, format checks, snapshot inspection, and delete-file inspection.</li><li>Provides common data seeding and large-range generation utilities.</li></ul> | presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractNativeIcebergV3Test.java |
| Adds broad Parquet coverage for Iceberg V3 DDL, query execution, DML behavior, and delete-file stress scenarios. | <ul><li>Tests table creation, CTAS, types, partition transforms/evolution, V2-to-V3 upgrades, metadata-only deletes, and unsupported versions.</li><li>Exercises projections, aggregations, joins, subqueries, set/window/scalar functions, hidden columns, schema/complex types, and reads through position deletes.</li><li>Validates native INSERT and insert-only MERGE while pinning current native row-level DML failures; applies mutations with Java workers for comparison.</li><li>Adds repeated and large DELETE/UPDATE/MERGE rounds with in-memory model validation, compaction, time travel, rollback, and snapshot expiry.</li></ul> | presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Ddl.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Dql.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Dml.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3DeleteStress.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3ComplexTypes.java |
| Adds tests for Iceberg V3-specific semantics, schema evolution, metadata procedures, and table properties. | <ul><li>Covers row lineage, column defaults, equality deletes, field-id-based schema changes, type promotion, partition evolution, and schema time travel.</li><li>Validates metadata tables, changelog, branches/tags, snapshot operations, maintenance procedures, and property persistence/pruning.</li><li>Checks that maintenance and property changes preserve V3 readability and writability.</li></ul> | presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3SpecFeatures.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3SchemaEvolution.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3SystemTables.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3TableProperties.java |
| Adds ORC interoperability and known limitation coverage for native Iceberg V3 workers. | <ul><li>Reads Java-written ORC V3 tables, including nested, partitioned, and evolved schemas, using native workers and Java comparisons.</li><li>Pins native ORC write/read incompatibility, unsupported long decimal writes, and disables the known timestamp mismatch test.</li></ul> | presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3Orc.java |
| Registers concrete Parquet and ORC TestNG suites under the native worker Iceberg test package. | <ul><li>Instantiates reusable suites with PARQUET storage format and adds the standalone ORC suite.</li><li>Places tests under the existing native e2e discovery path.</li></ul> | presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3ComplexTypesParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3DdlParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3DeleteStressParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3DmlParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3DqlParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3SchemaEvolutionParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3SpecFeaturesParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3SystemTablesParquet.java<br/>presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/TestNativeIcebergV3TablePropertiesParquet.java |
Possibly linked issues
---
<details>
<summary>Tips and commands</summary>
Interacting with Sourcery
@sourcery-ai review on the pull request.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.@sourcery-ai anywhere in the pullrequest 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.@sourcery-ai summary anywhere inthe 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.
@sourcery-ai guide on the pullrequest to (re-)generate the reviewer's guide at any time.
@sourcery-ai resolve on thepull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore.
@sourcery-ai dismiss on the pullrequest 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:
summary, the reviewer's guide, and others.
Getting Help
</details>
<!-- Generated by sourcery-ai[bot]: end review_guide -->
🟡 Medium · Parallel suites overwrite shared tables
When multiple Iceberg V3 leaf test classes run concurrently against the shared default DATA_DIR, the DDL and DQL suites use separate runners but share the same DATA_DIR, iceberg_v3 schema, and names such as seed_nation and nation. One suite can drop or replace a table while the other is copying or querying it, so setup and assertions become flaky or observe the other suite’s data.
Use a per-class warehouse/schema or serialize the suites that mutate shared table names.
Also at presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Ddl.java:34, presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Dql.java:37.
<details>
<summary>Prompt for AI agents</summary>
~~~markdown
In presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractNativeIcebergV3Test.java at lines 119-121:
Parallel suites overwrite shared tables
When multiple Iceberg V3 leaf test classes run concurrently against the shared default DATA_DIR, the DDL and DQL suites use separate runners but share the same DATA_DIR, iceberg_v3 schema, and names such as seed_nation and nation. One suite can drop or replace a table while the other is copying or querying it, so setup and assertions become flaky or observe the other suite’s data.
Use a per-class warehouse/schema or serialize the suites that mutate shared table names.
Also at presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Ddl.java:34, presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Dql.java:37.
~~~
</details>
✅ Addressed in a68aa89f40c391d1351279bb4f6485df2562d294: The referenced test file and its setup code have been removed from the current PR state.
🟡 Medium · MERGE tests use copy-on-write
When a test executes MERGE against a table created by createV2MergeOnReadTable, v2MergeOnReadWith sets write.delete.mode and write.update.mode but leaves write.merge.mode at its default copy-on-write setting. The MERGE scenarios rewrite data files instead of producing the expected position-delete files, so the suite does not exercise native reads of MERGE-produced delete files.
Set write.merge.mode to merge-on-read in v2MergeOnReadWith.
Also at presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3DeleteStress.java:118-122.
<details>
<summary>Prompt for AI agents</summary>
~~~markdown
In presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractNativeIcebergV3Test.java at lines 176-180:
MERGE tests use copy-on-write
When a test executes MERGE against a table created by createV2MergeOnReadTable, v2MergeOnReadWith sets write.delete.mode and write.update.mode but leaves write.merge.mode at its default copy-on-write setting. The MERGE scenarios rewrite data files instead of producing the expected position-delete files, so the suite does not exercise native reads of MERGE-produced delete files.
Set write.merge.mode to merge-on-read in v2MergeOnReadWith.
Also at presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3DeleteStress.java:118-122.
~~~
</details>
✅ Addressed in a68aa89f40c391d1351279bb4f6485df2562d294: The referenced helper has been removed from the current PR state.
Hey - I've found 2 issues
<details>
<summary>Prompt for AI Agents</summary>
~~~markdown
Please address the comments from this code review:
Individual Comments
Comment 1
<location path="presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractNativeIcebergV3Test.java" line_range="119-121" />
<code_context>
+ {
+ for (String table : tables) {
+ String seed = "seed_" + table;
+ javaRunner().execute("DROP TABLE IF EXISTS " + seed);
+ javaRunner().execute(format("CREATE TABLE %s WITH (format = '%s') AS SELECT FROM tpch.tiny.%s", seed, storageFormat, table));
+ createV3TableAs(table, "SELECT FROM " + seed, scalarLong("SELECT count() FROM " + seed));
+ }
+ }
</code_context>
<issue_to_address>
Parallel suites overwrite shared tables
When multiple Iceberg V3 leaf test classes run concurrently against the shared default DATA_DIR, the DDL and DQL suites use separate runners but share the same DATA_DIR, iceberg_v3 schema, and names such as seed_nation and nation. One suite can drop or replace a table while the other is copying or querying it, so setup and assertions become flaky or observe the other suite’s data.
Use a per-class warehouse/schema or serialize the suites that mutate shared table names.
Also at presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Ddl.java:34, presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3Dql.java:37.
</issue_to_address>
Comment 2
<location path="presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractNativeIcebergV3Test.java" line_range="176-180" />
<code_context>
+ }
+
+ // Row-level DML needs a V2 table in merge-on-read mode.
+ protected String v2MergeOnReadWith(String extraProperties)
+ {
+ return format("WITH (\"format-version\" = '2', format = '%s', \"write.delete.mode\" = 'merge-on-read', \"write.update.mode\" = 'merge-on-read'%s)",
+ storageFormat, extraProperties.isEmpty() ? "" : ", " + extraProperties);
+ }
+
+ protected void createV2MergeOnReadTable(String table, String columns)
</code_context>
<issue_to_address>
MERGE tests use copy-on-write
When a test executes MERGE against a table created by createV2MergeOnReadTable, v2MergeOnReadWith sets write.delete.mode and write.update.mode but leaves write.merge.mode at its default copy-on-write setting. The MERGE scenarios rewrite data files instead of producing the expected position-delete files, so the suite does not exercise native reads of MERGE-produced delete files.
Set write.merge.mode to merge-on-read in v2MergeOnReadWith.
Also at presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/AbstractTestNativeIcebergV3DeleteStress.java:118-122.
</issue_to_address>
~~~
</details>
**<details>
<summary>Sourcery is free for open source - if you like our reviews please consider sharing them ✨</summary>
</details>
Thanks @apurva-meta for this code.
Most of the native engine Iceberg tests are checked-in here:
https://github.com/prestodb/presto/tree/master/presto-native-tests/src/test/java/com/facebook/presto/nativetests/iceberg
Can you move all these to that directory as well ? presto-native-execution is more focused on the core Velox pieces.
Thanks @apurva-meta
Thanks @apurva-meta
Approved these changes.
aditi-pandit
apurva-meta
Summary:
Adds end-to-end tests for Iceberg format version 3 tables on native (C++) workers, under
presto-native-execution/src/test/java/com/facebook/presto/nativeworker/iceberg/v3/. Each suite runs queries on native workers and compares them against Java workers reading the same Iceberg warehouse (HIVE catalog). Tables are created with an explicit"format-version", since the connector default is V2.Suites (PARQUET leaf classes):
$snapshots,$files,$manifests,$partitions,$history,$refs,$properties,$metadata_log_entries,$changelog, time travel, branches, tags, rollback,set_current_snapshot,fast_forward,expire_snapshots,remove_orphan_files,rewrite_manifests,rewrite_data_files,set_table_property._row_id,_last_updated_sequence_number), column default values, equality deletes.The tests pin current behavior where native execution does not yet work:
cannot use at() with string IcebergTableName), and native UPDATE or MERGE with a matched clause fails to commit (Content offset is required for DV). MERGE that only inserts works. The delete, stress and query suites therefore apply row-level changes with Java workers and verify them through native reads.decimal(38, 10)to ORC fail.New classes live under
nativeworker/iceberg/, so the existing native e2e workflow picks them up.Differential Revision: D126779159