← Back to Pull requests

fix(plugin-iceberg): Ignore row lineage stats in Parquet and ORC #28746

Merged
Joe-Abraham merged 3 files (213 lines) on Nov 03, 2026 05:21 UTC
View on GitHub
Joe-Abraham Joe-Abraham commented on Oct 30, 2026 02:44 UTC
Author

Description

A query filtering on _row_id or _last_updated_sequence_number could miss rows that inherit their value from the data file. For example, a compacted file can hold row 1 with a stored _row_id of 0 and row 2 with a null _row_id that inherits 3. The row group statistics cover only the stored value 0, so

SELECT id FROM t WHERE "_row_id" = 3

skipped the row group and returned no rows.

Row lineage columns are now left out of the predicates handed to the Parquet and ORC readers, so their statistics no longer prune row groups or stripes.

Motivation and Context

Files that mix stored and inherited lineage values come from compaction or from an UPDATE/MERGE that preserves row lineage. Filtering on a lineage column over such a file silently dropped rows.

Impact

No public API or configuration changes. Predicates on row lineage columns no longer prune Parquet row groups or ORC stripes.

Test Plan

The tests build a mixed file through the Iceberg API and commit it as an overwrite. Parquet uses Iceberg's writer; ORC uses the ORC writer from hive-apache with Iceberg field ids. The mixed-file assertions on _last_updated_sequence_number also need the split pruning fix, so they come in the next PR.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.

  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.

  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.

  • If release notes are required, they follow the release notes guidelines.

  • Adequate tests were added if applicable.

  • CI passed.

  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).
  • Release Notes

    == RELEASE NOTES ==
    
    Iceberg Connector Changes
    * Fix queries filtering on ``_row_id`` or ``_last_updated_sequence_number`` skipping Parquet row groups and ORC stripes that hold rows with inherited values.
    

    Summary by Sourcery

    Fix Iceberg row lineage filtering so inherited values are not skipped by Parquet or ORC statistics-based pruning.

    Bug Fixes:

  • Prevent predicates on Iceberg row lineage columns from pruning Parquet row groups or ORC stripes based on incomplete stored-value statistics.

  • Ensure queries filtering on inherited _row_id and _last_updated_sequence_number values return the expected rows.
  • Enhancements:

  • Add coverage for mixed stored and inherited row lineage values across Parquet and ORC files, including null predicates.
  • Tests:

  • Add Iceberg row lineage tests covering mixed stored and inherited values in both supported file formats.
  • Diff: 213 lines (+211 / -2) across 3 files Reviewer: aditi-pandit Review duration: 5917m
    All Vouch review confidence checks passed
    Residual risk 0.05 = Change Risk (0.38) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.38 · 213 lines diff across 3 files
    0.38
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    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.321
    Real PR Conversation Timeline
    9 items
    sourcery-ai[bot] sourcery-ai[bot] commented on Oct 30, 2026 02:44 UTC
    Bot

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

    Reviewer's Guide

    The PR prevents Parquet row-group and ORC stripe pruning from using incomplete row-lineage statistics, safely removes lineage predicates from Iceberg metadata scans, and updates Java/native scan construction and extensive tests to preserve correct stored and inherited lineage behavior.

    Sequence diagram for preserving inherited Iceberg row lineage rows

    sequenceDiagram
        participant Query
        participant IcebergPageSourceProvider
        participant ParquetORCReader
        participant File
    
        Query->>IcebergPageSourceProvider: getParquetTupleDomain()
        IcebergPageSourceProvider->>IcebergPageSourceProvider: isRowLineageColumn()
        IcebergPageSourceProvider->>ParquetORCReader: Read without row-lineage statistics predicates
        ParquetORCReader->>File: Scan row groups or stripes
        File-->>ParquetORCReader: Stored and inherited lineage values
        ParquetORCReader-->>Query: Matching rows
    

    File-Level Changes

    | Change | Details | Files |
    | ------ | ------- | ----- |
    | Exclude row-lineage predicates from file-level statistics pruning while preserving their physical-value reads. | <ul><li>Add a shared isRowLineageColumn() check for _row_id and _last_updated_sequence_number.</li><li>Remove lineage domains from Parquet row-group and ORC stripe predicates so inherited values cannot be skipped.</li><li>Strip lineage constraints before Iceberg delete-file expression binding to avoid metadata-column failures.</li></ul> | presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergColumnHandle.java<br/>presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergPageSourceProvider.java<br/>presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergUtil.java<br/>presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java |
    | Expand row-lineage coverage with mixed stored/inherited data and format-specific pruning scenarios. | <ul><li>Refactor shared tests to run with filter pushdown enabled or disabled and compare native results with the Java engine where applicable.</li><li>Add Parquet and ORC tests for predicates on inherited and stored lineage values, null checks, combined predicates, compaction, deletes, and statistics planning.</li><li>Add helpers that create V3 files, compaction rewrites, equality deletes, mixed lineage files, and direct Parquet/ORC test data.</li></ul> | presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineage.java<br/>presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineageBase.java<br/>presto-native-tests/src/test/java/com/facebook/presto/nativetests/iceberg/TestIcebergV3RowLineage.java |
    | Ensure native Iceberg scans include projected lineage columns in physical data columns without incorrectly treating them as filter columns. | <ul><li>Pass TableScan assignments into connector table-handle conversion.</li><li>Track lineage handles separately from predicate handles and add their field IDs to the final data-column layout.</li><li>Preserve lineage filters when a column is both filtered and projected.</li></ul> | presto-native-execution/presto_cpp/main/connectors/IcebergPrestoToVeloxConnector.cpp<br/>presto-native-execution/presto_cpp/main/connectors/IcebergPrestoToVeloxConnector.h<br/>presto-native-execution/presto_cpp/main/connectors/PrestoToVeloxConnector.h<br/>presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp |
    | Add native connector tests for lineage column assignment and field-ID propagation. | <ul><li>Verify projected-only lineage columns are returned as data columns but absent from filter handles.</li><li>Verify filtered-and-projected lineage columns are included once with the correct Iceberg field ID.</li></ul> | presto-native-execution/presto_cpp/main/types/tests/PrestoToVeloxConnectorTest.cpp |

    Possibly linked issues

  • #28287: The PR directly fixes the issue’s Parquet row-group and ORC stripe pruning bug by excluding lineage columns from reader predicates.

  • #unspecified: The PR addresses correctness of reading lineage predicates, ensuring Parquet and ORC scans retain rows whose lineage values are inherited.
  • ---

    <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 30, 2026 02:48 UTC
    Code Review
    presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineageBase.java:1
    @@ -173,36 +218,547 @@ public void testRowLineageBackfilledOnV2ToV3Upgrade()
                         GenericRecord.create(schema).copy("id", 5, "value", "five"));
                 table.refresh();
     
    -            assertEquals(computeActual("SELECT count(*) FROM " + tableName +
    -                            " WHERE \"_row_id\" IS NULL").getOnlyValue(), 0L,
    -                    "All rows should have non-null _row_id after V3 upgrade");
    -            assertEquals(computeActual("SELECT count(*) FROM " + tableName +
    -                            " WHERE \"_last_updated_sequence_number\" IS NULL").getOnlyValue(), 0L,
    -                    "All rows should have non-null _last_updated_sequence_number after V3 upgrade");
    +            assertScalar(session, "SELECT count(*) FROM " + tableName + " WHERE \"_row_id\" IS NULL",
    +                    0L, "All rows should have non-null _row_id after V3 upgrade");
    +            assertScalar(session, "SELECT count(*) FROM " + tableName + " WHERE \"_last_updated_sequence_number\" IS NULL",
    +                    0L, "All rows should have non-null _last_updated_sequence_number after V3 upgrade");
     
    -            long distinctRowIds = (Long) computeActual(
    -                    "SELECT count(DISTINCT \"_row_id\") FROM " + tableName).getOnlyValue();
    -            assertEquals(distinctRowIds, 5L, "Row IDs must be unique across all 5 rows after upgrade");
    +            assertScalar(session, "SELECT count(DISTINCT \"_row_id\") FROM " + tableName,
    +                    5L, "Row IDs must be unique across all 5 rows after upgrade");
     
                 table.refresh();
                 List<long[]> allExpectedPairs = buildExpectedPairs(table,
                         "All files should have firstRowId set after V3 upgrade");
    -            assertPrestoRowLineageMatchesExpected(tableName, allExpectedPairs);
    +            assertPrestoRowLineageMatchesExpected(session, tableName, allExpectedPairs);
             }
             finally {
    -            try {
    -                catalog.dropTable(tableId, true);
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    /**
    +     * A row whose {@code _row_id} / {@code _last_updated_sequence_number} are stored in the data
    +     * file, as an external row-preserving UPDATE/MERGE writes them, reports those stored values
    +     * whether or not the query also filters on the column.
    +     */
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testRowLineageConsistentAcrossPredicateAndProjectionOnlyQueries(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_row_lineage_predicate_vs_projection";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +
    +            writeRecords(table, GenericRecord.create(table.schema()).copy("id", 1, "value", "one"));
    +            table.refresh();
    +
    +            writeOverriddenLineageRow(table);
    +            table.refresh();
    +
    +            String unfilteredSql = "SELECT id, \"_row_id\", \"_last_updated_sequence_number\" FROM " + tableName;
    +            String filteredSql = unfilteredSql + " WHERE \"_row_id\" IS NOT NULL";
    +            assertMatchesExpectedEngine(session, unfilteredSql);
    +            assertMatchesExpectedEngine(session, filteredSql);
    +
    +            MaterializedResult unfiltered = computeActual(session, unfilteredSql);
    +            MaterializedResult filtered = computeActual(session, filteredSql);
    +
    +            assertEquals(unfiltered.getRowCount(), 2);
    +            Map<Integer, long[]> unfilteredById = rowIdAndSequenceNumberById(unfiltered);
    +            Map<Integer, long[]> filteredById = rowIdAndSequenceNumberById(filtered);
    +            assertEquals(unfilteredById.keySet(), filteredById.keySet(),
    +                    "plain projection and predicate-filtered queries must see the same rows");
    +            for (Integer id : unfilteredById.keySet()) {
    +                assertEquals(unfilteredById.get(id)[0], filteredById.get(id)[0],
    +                        "_row_id must match between unfiltered and filtered queries for id=" + id);
    +                assertEquals(unfilteredById.get(id)[1], filteredById.get(id)[1],
    +                        "_last_updated_sequence_number must match between unfiltered and filtered queries for id=" + id);
                 }
    -            catch (Exception ignored) {
    +
    +            assertEquals(unfilteredById.get(2)[0], 42L,
    +                    "_row_id should reflect the file's explicit physical value, not firstRowId+position");
    +            assertEquals(unfilteredById.get(2)[1], 99L,
    +                    "_last_updated_sequence_number should reflect the file's explicit physical value, not the file's dataSequenceNumber");
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testPredicatePushdownPreCompaction(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_pushdown_pre";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +            appendOneRow(table, 3, "three");
    +
    +            List<long[]> idAndSequenceNumber = readIdAndSequenceNumber(session, tableName);
    +            assertEquals(idAndSequenceNumber.size(), 3);
    +            long sequenceNumber1 = valueForId(idAndSequenceNumber, 1);
    +            long sequenceNumber2 = valueForId(idAndSequenceNumber, 2);
    +            long sequenceNumber3 = valueForId(idAndSequenceNumber, 3);
    +            assertTrue(sequenceNumber1 < sequenceNumber2 && sequenceNumber2 < sequenceNumber3, "sequence numbers must increase per commit");
    +
    +            assertIdsForPredicate(session, tableName, "<= " + sequenceNumber1, ImmutableList.of(1));
    +            assertIdsForPredicate(session, tableName, "<= " + sequenceNumber2, ImmutableList.of(1, 2));
    +            assertIdsForPredicate(session, tableName, "<= " + sequenceNumber3, ImmutableList.of(1, 2, 3));
    +            assertIdsForPredicate(session, tableName, "< " + sequenceNumber1, ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "BETWEEN " + sequenceNumber2 + " AND " + sequenceNumber3, ImmutableList.of(2, 3));
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    /**
    +     * Compaction rewrites two single-row files into one file that explicitly carries each row's
    +     * original {@code _row_id} / {@code _last_updated_sequence_number}, which is how lineage
    +     * survives a rewrite. The reader must report those physical values rather than the compacted
    +     * file's own firstRowId+position and dataSequenceNumber, and the lineage column statistics must
    +     * still allow the file to be pruned by a predicate.
    +     */
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testPredicatePushdownPostCompaction(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_pushdown_post";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +            table.refresh();
    +            List<long[]> preCompactionIdAndSequenceNumber = readIdAndSequenceNumber(session, tableName);
    +            long preCompactionSequenceNumber1 = valueForId(preCompactionIdAndSequenceNumber, 1);
    +            long preCompactionSequenceNumber2 = valueForId(preCompactionIdAndSequenceNumber, 2);
    +            assertTrue(preCompactionSequenceNumber1 < preCompactionSequenceNumber2);
    +
    +            Set<DataFile> preCompactionFiles = new HashSet<>(dataFiles(table));
    +            assertEquals(preCompactionFiles.size(), 2);
    +
    +            Schema lineageAugmentedSchema = MetadataColumns.schemaWithRowLineage(table.schema());
    +            Record row1 = GenericRecord.create(lineageAugmentedSchema);
    +            row1.setField("id", 1);
    +            row1.setField("value", "one");
    +            row1.setField(MetadataColumns.ROW_ID.name(), 0L);
    +            row1.setField(MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.name(), preCompactionSequenceNumber1);
    +            Record row2 = GenericRecord.create(lineageAugmentedSchema);
    +            row2.setField("id", 2);
    +            row2.setField("value", "two");
    +            row2.setField(MetadataColumns.ROW_ID.name(), 1L);
    +            row2.setField(MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.name(), preCompactionSequenceNumber2);
    +            DataFile compactedFile = writeFile(table, lineageAugmentedSchema, row1, row2);
    +
    +            table.newRewrite()
    +                    .rewriteFiles(preCompactionFiles, ImmutableSet.of(compactedFile))
    +                    .commit();
    +            table.refresh();
    +
    +            List<long[]> postCompactionIdAndSequenceNumber = readIdAndSequenceNumber(session, tableName);
    +            assertEquals(postCompactionIdAndSequenceNumber.size(), 2);
    +            assertEquals(valueForId(postCompactionIdAndSequenceNumber, 1), preCompactionSequenceNumber1);
    +            assertEquals(valueForId(postCompactionIdAndSequenceNumber, 2), preCompactionSequenceNumber2);
    +
    +            int lineageFieldId = MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.fieldId();
    +            DataFile committedFile = getOnlyElement(dataFiles(table));
    +            assertTrue(committedFile.lowerBounds() != null && committedFile.lowerBounds().containsKey(lineageFieldId),
    +                    "compaction file is missing lineage column lower bound stats");
    +
    +            assertIdsForPredicate(session, tableName, "<= " + preCompactionSequenceNumber1, ImmutableList.of(1));
    +            assertIdsForPredicate(session, tableName, "<= " + preCompactionSequenceNumber2, ImmutableList.of(1, 2));
    +            assertIdsForPredicate(session, tableName, "< " + preCompactionSequenceNumber1, ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "> " + preCompactionSequenceNumber2, ImmutableList.of());
    +
    +            // A scan whose files are all pruned still runs one empty split, so add a file the
    +            // predicate keeps.
    +            appendOneRow(table, 3, "three");
    +            String selective = "SELECT id FROM " + tableName + " WHERE \"_last_updated_sequence_number\" > " + preCompactionSequenceNumber2;
    +            assertIdsForQuery(session, selective, ImmutableList.of(3));
    +            int splitsAll = completedSplitsFor(session, "SELECT id FROM " + tableName);
    +            int splitsSelective = completedSplitsFor(session, selective);
    +            assertTrue(splitsAll > splitsSelective,
    +                    "expected the compacted file to be pruned but unrestricted=" + splitsAll + " selective=" + splitsSelective);
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testV2TableLineagePredicates(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_pushdown_v2";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "2");
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +
    +            assertIdsForPredicate(session, tableName, "<= 100", ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "> 0", ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "IS NOT NULL", ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "IS NULL", ImmutableList.of(1, 2));
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    /**
    +     * Split counts are not compared with the expected engine: split generation and metadata-based
    +     * pruning run on the Java coordinator for both, so the comparison would check identical code
    +     * against itself. The assertion stays relative so it is insensitive to worker count.
    +     */
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testPredicateActuallyPrunesSplits(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_pushdown_split_count";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +            appendOneRow(table, 3, "three");
    +
    +            long minimumSequenceNumber = valueForId(readIdAndSequenceNumber(session, tableName), 1);
    +
    +            int splitsAll = completedSplitsFor(session, "SELECT id FROM " + tableName);
    +            int splitsPruned = completedSplitsFor(session,
    +                    "SELECT id FROM " + tableName + " WHERE \"_last_updated_sequence_number\" < " + minimumSequenceNumber);
    +
    +            assertTrue(splitsAll > splitsPruned,
    +                    "expected predicate to prune splits but unrestricted=" + splitsAll + " pruned=" + splitsPruned);
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testDisjointOrRangesPruneMiddleFile(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_disjoint_or";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +            appendOneRow(table, 3, "three");
    +
    +            List<long[]> idAndSequenceNumber = readIdAndSequenceNumber(session, tableName);
    +            long sequenceNumber1 = valueForId(idAndSequenceNumber, 1);
    +            long sequenceNumber2 = valueForId(idAndSequenceNumber, 2);
    +            long sequenceNumber3 = valueForId(idAndSequenceNumber, 3);
    +            assertTrue(sequenceNumber1 < sequenceNumber2 && sequenceNumber2 < sequenceNumber3, "sequence numbers must increase per commit");
    +
    +            String disjointSql = "SELECT id FROM " + tableName
    +                    + " WHERE \"_last_updated_sequence_number\" <= " + sequenceNumber1
    +                    + " OR \"_last_updated_sequence_number\" >= " + sequenceNumber3;
    +
    +            int splitsAll = completedSplitsFor(session, "SELECT id FROM " + tableName);
    +            int splitsDisjoint = completedSplitsFor(session, disjointSql);
    +            assertTrue(splitsAll > splitsDisjoint,
    +                    "expected disjoint OR to prune middle file but unrestricted=" + splitsAll + " disjoint=" + splitsDisjoint);
    +
    +            assertIdsForQuery(session, disjointSql, ImmutableList.of(1, 3));
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testRowIdPredicatesOnInheritedValues(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_row_id_inherited";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +            appendOneRow(table, 3, "three");
    +
    +            // One row per commit, committed in id order, so ascending row ids map to ids 1, 2, 3.
    +            List<long[]> expectedPairs = buildExpectedPairs(table, "firstRowId should be set for V3 tables");
    +            long rowId1 = expectedPairs.get(0)[0];
    +            long rowId2 = expectedPairs.get(1)[0];
    +            long rowId3 = expectedPairs.get(2)[0];
    +            List<long[]> idAndRowId = readIdAndRowId(session, tableName);
    +            assertEquals(valueForId(idAndRowId, 1), rowId1);
    +            assertEquals(valueForId(idAndRowId, 2), rowId2);
    +            assertEquals(valueForId(idAndRowId, 3), rowId3);
    +
    +            assertIdsForPredicate(session, tableName, "_row_id", "= " + rowId2, ImmutableList.of(2));
    +            assertIdsForPredicate(session, tableName, "_row_id", "< " + rowId3, ImmutableList.of(1, 2));
    +            assertIdsForPredicate(session, tableName, "_row_id", "IN (" + rowId1 + ", " + rowId3 + ")", ImmutableList.of(1, 3));
    +            assertIdsForPredicate(session, tableName, "_row_id", "> " + rowId3, ImmutableList.of());
    +            assertIdsForQuery(session, "SELECT id FROM " + tableName +
    +                            " WHERE \"_row_id\" = " + rowId1 + " OR \"_row_id\" = " + rowId3,
    +                    ImmutableList.of(1, 3));
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testRowIdPredicatesOnStoredValues(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_row_id_stored";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +            writeRecords(table, GenericRecord.create(table.schema()).copy("id", 1, "value", "one"));
    +            table.refresh();
    +            writeOverriddenLineageRow(table);
    +            table.refresh();
    +
    +            DataFile storedFile = dataFiles(table).stream()
    +                    .filter(file -> file.lowerBounds() != null && file.lowerBounds().containsKey(MetadataColumns.ROW_ID.fieldId()))
    +                    .findFirst()
    +                    .orElseThrow(() -> new AssertionError("file with stored lineage not found"));
    +            long inheritedRowId = storedFile.firstRowId();
    +            long inheritedSequenceNumber = storedFile.dataSequenceNumber();
    +
    +            assertIdsForPredicate(session, tableName, "_row_id", "= 42", ImmutableList.of(2));
    +            assertIdsForPredicate(session, tableName, "_row_id", "= " + inheritedRowId, ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "_last_updated_sequence_number", "= 99", ImmutableList.of(2));
    +            assertIdsForPredicate(session, tableName, "_last_updated_sequence_number", "= " + inheritedSequenceNumber, ImmutableList.of());
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @DataProvider(name = "pushdownFilterEnabledAndFileFormat")
    +    public Object[][] pushdownFilterEnabledAndFileFormatProvider()
    +    {
    +        return new Object[][] {
    +                {false, FileFormat.PARQUET},
    +                {false, FileFormat.ORC}
    +        };
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabledAndFileFormat")
    +    public void testPredicatesOnMixedStoredAndInheritedFile(boolean pushdownFilterEnabled, FileFormat fileFormat)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_mixed_file";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            MixedLineageTable mixed = createMixedLineageTable(session, catalog, tableId, tableName, fileFormat);
    +
    +            assertIdsForPredicate(session, tableName, "_row_id", "= " + mixed.inheritedRowId, ImmutableList.of(2));
    +            assertIdsForPredicate(session, tableName, "_row_id", "= " + mixed.storedRowId, ImmutableList.of(1));
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testIsNullOnV3Table(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String inheritedTableName = "test_lineage_is_null_inherited";
    +        String mixedTableName = "test_lineage_is_null_mixed";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier inheritedTableId = TableIdentifier.of(TEST_SCHEMA, inheritedTableName);
    +        TableIdentifier mixedTableId = TableIdentifier.of(TEST_SCHEMA, mixedTableName);
    +        try {
    +            Table inherited = createTestTable(catalog, inheritedTableId, "3");
    +            appendOneRow(inherited, 1, "one");
    +            appendOneRow(inherited, 2, "two");
    +            createMixedLineageTable(session, catalog, mixedTableId, mixedTableName, FileFormat.PARQUET);
    +
    +            for (String tableName : ImmutableList.of(inheritedTableName, mixedTableName)) {
    +                for (String column : ImmutableList.of("_row_id", "_last_updated_sequence_number")) {
    +                    assertIdsForPredicate(session, tableName, column, "IS NULL", ImmutableList.of());
    +                    assertIdsForPredicate(session, tableName, column, "IS NOT NULL", ImmutableList.of(1, 2));
    +                }
                 }
             }
    +        finally {
    +            dropTableQuietly(catalog, inheritedTableId);
    +            dropTableQuietly(catalog, mixedTableId);
    +        }
         }
     
    -    protected void assertPrestoRowLineageMatchesExpected(String tableName, List<long[]> expectedPairs)
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testLineagePredicateWithDeletedRow(boolean pushdownFilterEnabled)
    +            throws Exception
         {
    -        MaterializedResult result = computeActual(
    -                "SELECT \"_row_id\", \"_last_updated_sequence_number\" FROM " + tableName +
    -                        " ORDER BY \"_row_id\"");
    +        // AUTOMATIC join distribution computes stats for the equality delete scan, which plans its
    +        // delete files with the data scan's predicate, lineage domains included.
    +        Session session = Session.builder(sessionWithPushdown(pushdownFilterEnabled))
    +                .setSystemProperty(JOIN_DISTRIBUTION_TYPE, "AUTOMATIC")
    +                .setSystemProperty(IGNORE_STATS_CALCULATOR_FAILURES, "false")
    +                .build();
    +        String tableName = "test_lineage_deleted_row";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +            Schema schema = table.schema();
    +            writeRecords(table,
    +                    GenericRecord.create(schema).copy("id", 1, "value", "one"),
    +                    GenericRecord.create(schema).copy("id", 2, "value", "two"),
    +                    GenericRecord.create(schema).copy("id", 3, "value", "three"));
    +            table.refresh();
    +            DataFile file = getOnlyElement(dataFiles(table));
    +            long firstRowId = file.firstRowId();
    +            writeEqualityDeleteOnId(table, 2);
    +
    +            List<long[]> idAndRowId = readIdAndRowId(session, tableName);
    +            assertEquals(idAndRowId.size(), 2);
    +            assertEquals(valueForId(idAndRowId, 1), firstRowId);
    +            assertEquals(valueForId(idAndRowId, 3), firstRowId + 2);
    +
    +            assertIdsForPredicate(session, tableName, "_row_id", "= " + (firstRowId + 2), ImmutableList.of(3));
    +            assertIdsForPredicate(session, tableName, "_row_id", "= " + (firstRowId + 1), ImmutableList.of());
    +            assertIdsForPredicate(session, tableName, "_last_updated_sequence_number", "= " + file.dataSequenceNumber(), ImmutableList.of(1, 3));
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testTableStatisticsWithLineagePredicate(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        // Statistics for the data scan and for the equality delete scan are computed with the
    +        // layout's predicate, lineage domains included, and Iceberg cannot bind lineage columns
    +        // when it plans either scan. AUTOMATIC join distribution makes the planner compute them.
    +        // SHOW STATS cannot cover this: a lineage predicate is also filtered per row, and SHOW
    +        // STATS rejects predicates the connector does not enforce.
    +        Session session = Session.builder(sessionWithPushdown(pushdownFilterEnabled))
    +                .setSystemProperty(JOIN_DISTRIBUTION_TYPE, "AUTOMATIC")
    +                .setSystemProperty(IGNORE_STATS_CALCULATOR_FAILURES, "false")
    +                .build();
    +        String tableName = "test_table_statistics_lineage_predicate";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +            Schema schema = table.schema();
    +            writeRecords(table,
    +                    GenericRecord.create(schema).copy("id", 1, "value", "one"),
    +                    GenericRecord.create(schema).copy("id", 2, "value", "two"));
    +            table.refresh();
    +            DataFile file = getOnlyElement(dataFiles(table));
    +            List<String> predicates = ImmutableList.of(
    +                    "\"_row_id\" = " + file.firstRowId(),
    +                    "\"_last_updated_sequence_number\" = " + file.dataSequenceNumber(),
    +                    "\"_row_id\" = " + file.firstRowId() + " AND \"_last_updated_sequence_number\" = " + file.dataSequenceNumber());
    +
    +            assertExplainWithPredicates(session, tableName, predicates);
    +
    +            // The equality delete makes the plan join the data scan with an equality delete scan.
    +            writeEqualityDeleteOnId(table, 2);
    +            assertExplainWithPredicates(session, tableName, predicates);
    +        }
    +        finally {
    +            dropTableQuietly(catalog, tableId);
    +        }
    +    }
    +
    +    private void assertExplainWithPredicates(Session session, String tableName, List<String> predicates)
    +    {
    +        for (String predicate : predicates) {
    +            assertQuerySucceeds(session, "EXPLAIN SELECT * FROM " + tableName + " WHERE " + predicate);
    +        }
    +    }
    +
    +    @Test(dataProvider = "pushdownFilterEnabled")
    +    public void testLineagePredicateCombinedWithRegularColumn(boolean pushdownFilterEnabled)
    +            throws Exception
    +    {
    +        Session session = sessionWithPushdown(pushdownFilterEnabled);
    +        String tableName = "test_lineage_combined_predicates";
    +        Catalog catalog = loadCatalog();
    +        TableIdentifier tableId = TableIdentifier.of(TEST_SCHEMA, tableName);
    +        try {
    +            Table table = createTestTable(catalog, tableId, "3");
    +            appendOneRow(table, 1, "one");
    +            appendOneRow(table, 2, "two");
    +            appendOneRow(table, 3, "three");
    +            List<long[]> idAndRowId = readIdAndRowId(session, tableName);
    +            long rowId1 = valueForId(idAndRowId, 1);
    +            long sequenceNumber2 = valueForId(readIdAndSequenceNumber(session, tableName), 2);
    +            ImmutableList.Builder<Integer> evenRowIds = ImmutableList.builder();
    +            for (long[] row : idAndRowId) {
    +                if (row[1] % 2 == 0) {
    +                    evenRowIds.add((int) row[0]);
    +                }
    +            }

    🟡 Medium · Self-derived row IDs mask errors

    When the Java test runs with consistently incorrect row-lineage values, in testLineagePredicateCombinedWithRegularColumn, evenRowIds is built from the same readIdAndRowId results used by the predicate at line 736, so incorrect but consistently read-and-filtered row IDs satisfy the assertion; the base class's engine comparison is a no-op.

    Derive the expected row IDs independently from Iceberg file metadata and assert the projected values before using them in the predicate.

    <details>
    <summary>Prompt for AI agents</summary>

    ~~~markdown
    In presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineageBase.java at lines 724-728:

    Self-derived row IDs mask errors

    When the Java test runs with consistently incorrect row-lineage values, in testLineagePredicateCombinedWithRegularColumn, evenRowIds is built from the same readIdAndRowId results used by the predicate at line 736, so incorrect but consistently read-and-filtered row IDs satisfy the assertion; the base class's engine comparison is a no-op.

    Derive the expected row IDs independently from Iceberg file metadata and assert the projected values before using them in the predicate.
    ~~~

    </details>

    sourcery-ai[bot] sourcery-ai[bot] commented on Oct 30, 2026 02:48 UTC
    Reviewer

    Hey - I've found 1 issue

    <details>
    <summary>Prompt for AI Agents</summary>

    ~~~markdown
    Please address the comments from this code review:

    Individual Comments

    Comment 1


    <location path="presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineageBase.java" line_range="724-728" />
    <code_context>
    + long rowId1 = valueForId(idAndRowId, 1);
    + long sequenceNumber2 = valueForId(readIdAndSequenceNumber(session, tableName), 2);
    + ImmutableList.Builder<Integer> evenRowIds = ImmutableList.builder();
    + for (long[] row : idAndRowId) {
    + if (row[1] % 2 == 0) {
    + evenRowIds.add((int) row[0]);
    + }
    + }
    +
    </code_context>
    <issue_to_address>
    Self-derived row IDs mask errors

    When the Java test runs with consistently incorrect row-lineage values, in testLineagePredicateCombinedWithRegularColumn, evenRowIds is built from the same readIdAndRowId results used by the predicate at line 736, so incorrect but consistently read-and-filtered row IDs satisfy the assertion; the base class's engine comparison is a no-op.

    Derive the expected row IDs independently from Iceberg file metadata and assert the projected values before using them in the predicate.
    </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>

    sourcery-ai[bot] sourcery-ai[bot] commented on Oct 30, 2026 07:50 UTC
    Bot

    Sorry @Joe-Abraham, you've used your own review budget of 250,000 diff characters for the last 7 days.

    You can request another review in 3 days and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

    aditi-pandit aditi-pandit commented on code on Oct 30, 2026 16:43 UTC
    Code Review
    presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineage.java:1
    @@ -366,4 +442,176 @@ private int completedSplitsFor(String sql)
                     .getQueryStats();
             return stats.getCompletedSplits();
         }
    +
    +    private void assertIdsForQuery(Session session, String sql, List<Integer> expectedIds)

    Same comments from previous PR apply.

    aditi-pandit aditi-pandit commented on code on Oct 30, 2026 16:52 UTC
    Code Review
    presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergRowLineage.java:1
    @@ -366,4 +442,176 @@ private int completedSplitsFor(String sql)
                     .getQueryStats();
             return stats.getCompletedSplits();
         }
    +
    +    private void assertIdsForQuery(Session session, String sql, List<Integer> expectedIds)
    +    {
    +        assertEquals(sortedIdsOf(computeActual(session, sql)), ImmutableList.sortedCopyOf(expectedIds), "rows for \"" + sql + "\"");
    +    }
    +
    +    private static List<Integer> sortedIdsOf(MaterializedResult result)
    +    {
    +        List<Integer> ids = new ArrayList<>();
    +        for (MaterializedRow row : result.getMaterializedRows()) {
    +            ids.add((Integer) row.getField(0));
    +        }
    +        ids.sort(Integer::compare);
    +        return ids;
    +    }
    +
    +    private List<long[]> readIdAndLongColumn(Session session, String tableName, String column)
    +    {
    +        List<long[]> rows = new ArrayList<>();
    +        for (MaterializedRow row : computeActual(session, "SELECT id, \"" + column + "\" FROM " + tableName).getMaterializedRows()) {
    +            rows.add(new long[] {(Integer) row.getField(0), (Long) row.getField(1)});
    +        }
    +        return rows;
    +    }
    +
    +    private static long valueForId(List<long[]> rows, int id)
    +    {
    +        for (long[] row : rows) {
    +            if (row[0] == id) {
    +                return row[1];
    +            }
    +        }
    +        throw new AssertionError("id not found: " + id);
    +    }
    +
    +    private static List<DataFile> dataFiles(Table table)
    +            throws Exception
    +    {
    +        List<DataFile> files = new ArrayList<>();
    +        try (CloseableIterable<FileScanTask> tasks = table.newScan().includeColumnStats().planFiles()) {
    +            for (FileScanTask task : tasks) {
    +                files.add(task.file());
    +            }
    +        }
    +        return files;
    +    }
    +
    +    /**
    +     * Commits ids 1 and 2 in separate appends, then rewrites both into one file in which id 1
    +     * stores its original lineage and id 2 stores none, so id 2 inherits the new file's
    +     * {@code firstRowId + 1} and data sequence number. The rewritten file is written in
    +     * {@code fileFormat}.
    +     */
    +    private MixedLineageTable createMixedLineageTable(Catalog catalog, TableIdentifier tableId, String tableName, FileFormat fileFormat)
    +            throws Exception
    +    {
    +        Table table = catalog.createTable(tableId, PUSHDOWN_TABLE_SCHEMA, PartitionSpec.unpartitioned(),
    +                ImmutableMap.of("format-version", "3"));
    +        appendOneRow(table, 1, "one");
    +        appendOneRow(table, 2, "two");
    +        long storedRowId = valueForId(readIdAndLongColumn(getSession(), tableName, "_row_id"), 1);
    +        long storedSequenceNumber = valueForId(readIdAndLongColumn(getSession(), tableName, "_last_updated_sequence_number"), 1);
    +
    +        Schema lineageSchema = MetadataColumns.schemaWithRowLineage(table.schema());
    +        Record stored = GenericRecord.create(lineageSchema);
    +        stored.setField("id", 1);
    +        stored.setField("value", "one");
    +        stored.setField(MetadataColumns.ROW_ID.name(), storedRowId);
    +        stored.setField(MetadataColumns.LAST_UPDATED_SEQUENCE_NUMBER.name(), storedSequenceNumber);
    +        Record inherited = GenericRecord.create(lineageSchema);
    +        inherited.setField("id", 2);
    +        inherited.setField("value", "two-updated");
    +        OverwriteFiles overwrite = table.newOverwrite();
    +        for (DataFile file : dataFiles(table)) {
    +            overwrite.deleteFile(file);
    +        }
    +        overwrite.addFile(writeFileInFormat(table, lineageSchema, fileFormat, stored, inherited)).commit();
    +        table.refresh();
    +
    +        DataFile file = getOnlyElement(dataFiles(table));
    +        MixedLineageTable mixed = new MixedLineageTable(storedRowId, storedSequenceNumber, file.firstRowId() + 1, file.dataSequenceNumber());
    +        assertTrue(mixed.inheritedSequenceNumber > mixed.storedSequenceNumber, "the rewrite must commit at a newer sequence number");
    +
    +        List<long[]> idAndRowId = readIdAndLongColumn(getSession(), tableName, "_row_id");
    +        assertEquals(valueForId(idAndRowId, 1), mixed.storedRowId);
    +        assertEquals(valueForId(idAndRowId, 2), mixed.inheritedRowId);
    +        List<long[]> idAndSequenceNumber = readIdAndLongColumn(getSession(), tableName, "_last_updated_sequence_number");
    +        assertEquals(valueForId(idAndSequenceNumber, 1), mixed.storedSequenceNumber);
    +        assertEquals(valueForId(idAndSequenceNumber, 2), mixed.inheritedSequenceNumber);
    +        return mixed;
    +    }
    +
    +    private DataFile writeFileInFormat(Table table, Schema writeSchema, FileFormat fileFormat, Record... records)
    +            throws Exception
    +    {
    +        if (fileFormat == FileFormat.PARQUET) {
    +            return writeFileWithSchema(table, writeSchema, records);
    +        }
    +        org.apache.hadoop.fs.Path filePath = new org.apache.hadoop.fs.Path(table.location(), "data/" + fileFormat.addExtension("data-" + UUID.randomUUID()));
    +        return writeOrcFile(table, writeSchema, filePath, records);
    +    }
    +
    +    /**
    +     * Writes {@code records} with the Apache ORC writer bundled in hive-apache, since iceberg-orc
    +     * needs a different build of the same ORC classes. Each column carries its Iceberg field id,
    +     * as Iceberg's ORC writer does. The data file has no column metrics.
    +     */
    +    private static DataFile writeOrcFile(Table table, Schema writeSchema, org.apache.hadoop.fs.Path filePath, Record... records)
    +            throws Exception
    +    {
    +        TypeDescription orcSchema = TypeDescription.createStruct();
    +        for (Types.NestedField field : writeSchema.columns()) {
    +            TypeDescription type;
    +            switch (field.type().typeId()) {
    +                case INTEGER:
    +                    type = TypeDescription.createInt();
    +                    break;
    +                case LONG:
    +                    type = TypeDescription.createLong();
    +                    break;
    +                case STRING:
    +                    type = TypeDescription.createString();
    +                    break;
    +                default:
    +                    throw new IllegalArgumentException("Unsupported type: " + field.type());
    +            }
    +            orcSchema.addField(field.name(), type.setAttribute(ORC_ICEBERG_ID_KEY, String.valueOf(field.fieldId())));
    +        }
    +        Configuration configuration = new Configuration();
    +        VectorizedRowBatch batch = orcSchema.createRowBatch();
    +        for (Record record : records) {
    +            int row = batch.size++;
    +            for (int column = 0; column < batch.cols.length; column++) {
    +                ColumnVector vector = batch.cols[column];
    +                Object value = record.get(column);
    +                if (value == null) {
    +                    vector.noNulls = false;
    +                    vector.isNull[row] = true;
    +                }
    +                else if (vector instanceof BytesColumnVector) {
    +                    ((BytesColumnVector) vector).setVal(row, ((String) value).getBytes(UTF_8));
    +                }
    +                else {
    +                    ((LongColumnVector) vector).vector[row] = ((Number) value).longValue();
    +                }
    +            }
    +        }
    +        try (Writer writer = OrcFile.createWriter(filePath, OrcFile.writerOptions(configuration).setSchema(orcSchema))) {
    +            writer.addRowBatch(batch);
    +        }
    +        return DataFiles.builder(table.spec())
    +                .withInputFile(HadoopInputFile.fromPath(filePath, configuration))
    +                .withFormat(org.apache.iceberg.FileFormat.ORC)
    +                .withRecordCount(records.length)
    +                .build();
    +    }
    +
    +    private static class MixedLineageTable

    This is more understandable as MixedLineageTuple

    aditi-pandit aditi-pandit approved these changes on Nov 03, 2026 02:18 UTC
    Approved Reviewer

    Thanks @Joe-Abraham

    Joe-Abraham Joe-Abraham commented on Nov 03, 2026 05:22 UTC
    Author

    Thank you @aditi-pandit

    Reviewers
    Assignees
    Joe-Abraham Joe-Abraham
    Labels
    risk: low confidence: 88.1% 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: 38% (MEDIUM) · Higher = larger blast radius
    38%
    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: 88.1% · Lower = rushed or shallow review
    88.1%
    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: 4.5% · Safe to merge
    4.5%