← Back to Pull requests

test(native): Add Iceberg V3 end-to-end tests for native workers (#28699) #28699

Merged
apurva-meta merged 20 files (2414 lines) on Oct 27, 2026 04:26 UTC
View on GitHub
apurva-meta apurva-meta commented on Oct 21, 2026 23:28 UTC
Author

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

  • DDL: create, CTAS, primitive, decimal and nested types, identity and transform partitioning, partition evolution, V2 to V3 upgrade, metadata-only deletes, unsupported format version.

  • DQL: projections, aggregations, grouping sets, joins, subqueries, set operations, window and scalar functions, hidden columns, and reads of tables with position deletes.

  • DML: INSERT, and native DELETE, UPDATE and MERGE.

  • Delete stress: repeated DELETE, UPDATE and MERGE rounds checked against an in-memory model, plus compaction, time travel, rollback and snapshot expiry across deletes.

  • System tables and procedures: $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.

  • Spec features: row lineage (_row_id, _last_updated_sequence_number), column default values, equality deletes.

  • Complex types, schema evolution and table properties.

  • ORC: native reads of ORC data written by Java workers.
  • The tests pin current behavior where native execution does not yet work:

  • Row-level DELETE, UPDATE and MERGE are rejected on V3 tables, so they run on V2 merge-on-read tables.

  • Native DELETE fails to deserialize the Iceberg delete table handle on the worker (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.

  • Native ORC writes go through the DWRF writer and cannot be read back by the native ORC reader.

  • Native writes of decimal(38, 10) to ORC fail.

  • Partitioning by a nested struct field fails in the native writer.

  • Native reads of Java-written ORC timestamps differ from Java (disabled test).
  • New classes live under nativeworker/iceberg/, so the existing native e2e workflow picks them up.

    == NO RELEASE NOTE ==
    

    Differential Revision: D126779159

    Diff: 2414 lines (+2414 / -0) across 20 files Reviewer: aditi-pandit Review duration: 7498m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.72) × (1 − Review Confidence (0.70)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 2414 lines diff across 20 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.50 · 3 substantive comment(s)
    0.50
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    70%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    9 items
    sourcery-ai[bot] sourcery-ai[bot] commented on Oct 21, 2026 23:28 UTC
    Bot

    <!-- 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

  • #N/A: The PR adds broad native Iceberg V3 end-to-end coverage for the issue’s support goals, including reads, row lineage, and defaults.
  • ---

    <details>
    <summary>Tips and commands</summary>

    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

  • [Contact our support team](mailto:support@sourcery.ai) for questions or feedback.

  • Visit our documentation for detailed guides and information.

  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
  • </details>

    <!-- Generated by sourcery-ai[bot]: end review_guide -->

    sourcery-ai[bot] sourcery-ai[bot] commented on code on Oct 21, 2026 23:32 UTC
    Code Review
    presto-native-tests/src/test/java/com/facebook/presto/nativetests/iceberg/AbstractNativeIcebergV3Test.java:1
    @@ -0,0 +1,309 @@
    +/*
    + * Licensed under the Apache License, Version 2.0 (the "License");
    + * you may not use this file except in compliance with the License.
    + * You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package com.facebook.presto.nativeworker.iceberg.v3;
    +
    +import com.facebook.presto.hive.HdfsEnvironment;
    +import com.facebook.presto.hive.HiveClientConfig;
    +import com.facebook.presto.hive.MetastoreClientConfig;
    +import com.facebook.presto.hive.metastore.ExtendedHiveMetastore;
    +import com.facebook.presto.hive.s3.HiveS3Config;
    +import com.facebook.presto.iceberg.FileFormat;
    +import com.facebook.presto.iceberg.IcebergCatalogName;
    +import com.facebook.presto.iceberg.IcebergDistributedTestBase;
    +import com.facebook.presto.iceberg.IcebergHiveTableOperationsConfig;
    +import com.facebook.presto.iceberg.IcebergUtil;
    +import com.facebook.presto.iceberg.ManifestFileCache;
    +import com.facebook.presto.iceberg.hive.IcebergFileHiveMetastore;
    +import com.facebook.presto.spi.ConnectorId;
    +import com.facebook.presto.spi.SchemaTableName;
    +import com.facebook.presto.testing.ExpectedQueryRunner;
    +import com.facebook.presto.testing.QueryRunner;
    +import com.facebook.presto.tests.AbstractTestQueryFramework;
    +import com.google.common.cache.CacheBuilder;
    +import com.google.common.collect.ImmutableList;
    +import org.apache.iceberg.BaseTable;
    +import org.apache.iceberg.DeleteFile;
    +import org.apache.iceberg.FileContent;
    +import org.apache.iceberg.FileScanTask;
    +import org.apache.iceberg.Table;
    +import org.apache.iceberg.io.CloseableIterable;
    +
    +import java.io.IOException;
    +import java.io.UncheckedIOException;
    +import java.nio.file.Path;
    +import java.util.LinkedHashMap;
    +import java.util.List;
    +import java.util.Map;
    +
    +import static com.facebook.presto.hive.metastore.InMemoryCachingHiveMetastore.memoizeMetastore;
    +import static com.facebook.presto.iceberg.CatalogType.HIVE;
    +import static com.facebook.presto.iceberg.IcebergQueryRunner.ICEBERG_CATALOG;
    +import static com.facebook.presto.iceberg.IcebergQueryRunner.getIcebergDataDirectoryPath;
    +import static com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils.javaIcebergQueryRunnerBuilder;
    +import static com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils.nativeIcebergQueryRunnerBuilder;
    +import static com.google.common.base.Preconditions.checkArgument;
    +import static java.lang.String.format;
    +import static java.util.Locale.ENGLISH;
    +import static java.util.Objects.requireNonNull;
    +import static org.testng.Assert.assertEquals;
    +
    +/**
    + * Base for the Iceberg V3 end-to-end suites on native workers. The query runner uses native
    + * workers; the expected runner uses Java workers over the same Iceberg warehouse, so
    + * {@code assertQuery} checks native results against Java execution on the same data.
    + *
    + * <p>Every table is created with an explicit format version: the connector default is V2.
    + * Row-level DELETE, UPDATE and MERGE are rejected on V3 tables, so the DML suites run them on
    + * V2 merge-on-read tables, which write position-delete files.
    + */
    +public abstract class AbstractNativeIcebergV3Test
    +        extends AbstractTestQueryFramework
    +{
    +    protected static final String SCHEMA = "iceberg_v3";
    +    protected static final String V3_ROW_LEVEL_DML_UNSUPPORTED = ".*Iceberg table updates for format version 3 are not supported yet.*";
    +
    +    private final String storageFormat;
    +
    +    protected AbstractNativeIcebergV3Test(String storageFormat)
    +    {
    +        this.storageFormat = requireNonNull(storageFormat, "storageFormat is null");
    +    }
    +
    +    @Override
    +    protected QueryRunner createQueryRunner()
    +            throws Exception
    +    {
    +        return nativeIcebergQueryRunnerBuilder()
    +                .setStorageFormat(storageFormat)
    +                .setAddStorageFormatToPath(true)
    +                .setSchemaName(SCHEMA)
    +                .build();
    +    }
    +
    +    @Override
    +    protected ExpectedQueryRunner createExpectedQueryRunner()
    +            throws Exception
    +    {
    +        return javaIcebergQueryRunnerBuilder()
    +                .setStorageFormat(storageFormat)
    +                .setAddStorageFormatToPath(true)
    +                .setSchemaName(SCHEMA)
    +                .build();
    +    }
    +
    +    @Override
    +    protected void createTables()
    +    {
    +        javaRunner().execute("CREATE SCHEMA IF NOT EXISTS " + SCHEMA);
    +    }
    +
    +    /**
    +     * Writes tpch.tiny tables with Java workers, then copies them into V3 tables with native
    +     * workers, so the copies are native-written V3 data files.
    +     */
    +    protected void createTpchTables(String... tables)
    +    {
    +        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));

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

    sourcery-ai[bot] sourcery-ai[bot] commented on code on Oct 21, 2026 23:32 UTC
    Code Review
    presto-native-tests/src/test/java/com/facebook/presto/nativetests/iceberg/AbstractNativeIcebergV3Test.java:1
    @@ -0,0 +1,309 @@
    +/*
    + * Licensed under the Apache License, Version 2.0 (the "License");
    + * you may not use this file except in compliance with the License.
    + * You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package com.facebook.presto.nativeworker.iceberg.v3;
    +
    +import com.facebook.presto.hive.HdfsEnvironment;
    +import com.facebook.presto.hive.HiveClientConfig;
    +import com.facebook.presto.hive.MetastoreClientConfig;
    +import com.facebook.presto.hive.metastore.ExtendedHiveMetastore;
    +import com.facebook.presto.hive.s3.HiveS3Config;
    +import com.facebook.presto.iceberg.FileFormat;
    +import com.facebook.presto.iceberg.IcebergCatalogName;
    +import com.facebook.presto.iceberg.IcebergDistributedTestBase;
    +import com.facebook.presto.iceberg.IcebergHiveTableOperationsConfig;
    +import com.facebook.presto.iceberg.IcebergUtil;
    +import com.facebook.presto.iceberg.ManifestFileCache;
    +import com.facebook.presto.iceberg.hive.IcebergFileHiveMetastore;
    +import com.facebook.presto.spi.ConnectorId;
    +import com.facebook.presto.spi.SchemaTableName;
    +import com.facebook.presto.testing.ExpectedQueryRunner;
    +import com.facebook.presto.testing.QueryRunner;
    +import com.facebook.presto.tests.AbstractTestQueryFramework;
    +import com.google.common.cache.CacheBuilder;
    +import com.google.common.collect.ImmutableList;
    +import org.apache.iceberg.BaseTable;
    +import org.apache.iceberg.DeleteFile;
    +import org.apache.iceberg.FileContent;
    +import org.apache.iceberg.FileScanTask;
    +import org.apache.iceberg.Table;
    +import org.apache.iceberg.io.CloseableIterable;
    +
    +import java.io.IOException;
    +import java.io.UncheckedIOException;
    +import java.nio.file.Path;
    +import java.util.LinkedHashMap;
    +import java.util.List;
    +import java.util.Map;
    +
    +import static com.facebook.presto.hive.metastore.InMemoryCachingHiveMetastore.memoizeMetastore;
    +import static com.facebook.presto.iceberg.CatalogType.HIVE;
    +import static com.facebook.presto.iceberg.IcebergQueryRunner.ICEBERG_CATALOG;
    +import static com.facebook.presto.iceberg.IcebergQueryRunner.getIcebergDataDirectoryPath;
    +import static com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils.javaIcebergQueryRunnerBuilder;
    +import static com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils.nativeIcebergQueryRunnerBuilder;
    +import static com.google.common.base.Preconditions.checkArgument;
    +import static java.lang.String.format;
    +import static java.util.Locale.ENGLISH;
    +import static java.util.Objects.requireNonNull;
    +import static org.testng.Assert.assertEquals;
    +
    +/**
    + * Base for the Iceberg V3 end-to-end suites on native workers. The query runner uses native
    + * workers; the expected runner uses Java workers over the same Iceberg warehouse, so
    + * {@code assertQuery} checks native results against Java execution on the same data.
    + *
    + * <p>Every table is created with an explicit format version: the connector default is V2.
    + * Row-level DELETE, UPDATE and MERGE are rejected on V3 tables, so the DML suites run them on
    + * V2 merge-on-read tables, which write position-delete files.
    + */
    +public abstract class AbstractNativeIcebergV3Test
    +        extends AbstractTestQueryFramework
    +{
    +    protected static final String SCHEMA = "iceberg_v3";
    +    protected static final String V3_ROW_LEVEL_DML_UNSUPPORTED = ".*Iceberg table updates for format version 3 are not supported yet.*";
    +
    +    private final String storageFormat;
    +
    +    protected AbstractNativeIcebergV3Test(String storageFormat)
    +    {
    +        this.storageFormat = requireNonNull(storageFormat, "storageFormat is null");
    +    }
    +
    +    @Override
    +    protected QueryRunner createQueryRunner()
    +            throws Exception
    +    {
    +        return nativeIcebergQueryRunnerBuilder()
    +                .setStorageFormat(storageFormat)
    +                .setAddStorageFormatToPath(true)
    +                .setSchemaName(SCHEMA)
    +                .build();
    +    }
    +
    +    @Override
    +    protected ExpectedQueryRunner createExpectedQueryRunner()
    +            throws Exception
    +    {
    +        return javaIcebergQueryRunnerBuilder()
    +                .setStorageFormat(storageFormat)
    +                .setAddStorageFormatToPath(true)
    +                .setSchemaName(SCHEMA)
    +                .build();
    +    }
    +
    +    @Override
    +    protected void createTables()
    +    {
    +        javaRunner().execute("CREATE SCHEMA IF NOT EXISTS " + SCHEMA);
    +    }
    +
    +    /**
    +     * Writes tpch.tiny tables with Java workers, then copies them into V3 tables with native
    +     * workers, so the copies are native-written V3 data files.
    +     */
    +    protected void createTpchTables(String... tables)
    +    {
    +        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));
    +        }
    +    }
    +
    +    protected QueryRunner javaRunner()
    +    {
    +        return (QueryRunner) getExpectedQueryRunner();
    +    }
    +
    +    // Runs a DML statement on Java workers and checks its row count.
    +    protected void assertJavaUpdate(String sql, long expectedRows)
    +    {
    +        assertEquals(javaRunner().execute(sql).getUpdateCount().getAsLong(), expectedRows, sql);
    +    }
    +
    +    protected String storageFormat()
    +    {
    +        return storageFormat;
    +    }
    +
    +    protected String v3With()
    +    {
    +        return format("WITH (\"format-version\" = '3', format = '%s')", storageFormat);
    +    }
    +
    +    protected String v3With(String extraProperties)
    +    {
    +        return format("WITH (\"format-version\" = '3', format = '%s', %s)", storageFormat, extraProperties);
    +    }
    +
    +    protected void createV3Table(String table, String columns)
    +    {
    +        dropTable(table);
    +        assertUpdate(format("CREATE TABLE %s (%s) %s", table, columns, v3With()));
    +    }
    +
    +    protected void createV3Table(String table, String columns, String extraProperties)
    +    {
    +        dropTable(table);
    +        assertUpdate(format("CREATE TABLE %s (%s) %s", table, columns, v3With(extraProperties)));
    +    }
    +
    +    protected void createV3TableAs(String table, String query, long rows)
    +    {
    +        dropTable(table);
    +        assertUpdate(format("CREATE TABLE %s %s AS %s", table, v3With(), query), rows);
    +    }
    +
    +    protected void createV3TableAs(String table, String extraProperties, String query, long rows)
    +    {
    +        dropTable(table);
    +        assertUpdate(format("CREATE TABLE %s %s AS %s", table, v3With(extraProperties), query), rows);
    +    }
    +
    +    // 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);
    +    }

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

    sourcery-ai[bot] sourcery-ai[bot] commented on Oct 21, 2026 23:32 UTC
    Reviewer

    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>

  • X

  • Mastodon

  • LinkedIn

  • Facebook
  • </details>

    aditi-pandit aditi-pandit commented on Oct 22, 2026 22:21 UTC
    Reviewer

    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.

    aditi-pandit aditi-pandit commented on Oct 22, 2026 23:34 UTC
    Reviewer

    Thanks @apurva-meta

    aditi-pandit aditi-pandit approved these changes on Oct 26, 2026 19:55 UTC
    Approved Reviewer

    Thanks @apurva-meta

    nmahadevuni nmahadevuni approved these changes on Oct 27, 2026 04:25 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    apurva-meta apurva-meta
    Labels
    risk: low confidence: 70.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 70.4% · Lower = rushed or shallow review
    70.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.1% · Safe to merge
    21.1%