You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/13 01:10:09 UTC

(datafusion-comet) 01/01: feat: add native Delta Lake scan contrib module (page/row-group pruning) (#5365)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-5365-c8581eeedd13e234231a22890748547e17859041
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git

commit 2b45c9d87b599f748744e95dbb5dd1125c9b1abc
Author: dustin <dw...@users.noreply.github.com>
AuthorDate: Tue Oct 13 01:09:44 2026 +0000

    feat: add native Delta Lake scan contrib module (page/row-group pruning) (#5365)
    
    * feat: add JVM-planned native Delta Lake scan contrib module
    
    Adds an optional contrib/delta-spark module that claims delta-spark DSv1
    scans through CometScanContrib and runs them on Comet's shared native
    parquet path, including main's JVM-exact field-name folding for
    case-insensitive footer matching. Deletion vectors are decoded natively
    into per-file ParquetAccessPlans that DataFusion intersects with
    row-group and page-index pruning, so DV skips and page skips compose in
    a single scan. Scans the native path cannot serve safely (DML row-index
    reads, unsupported filesystem schemes, userinfo-bearing authorities,
    credential-provider-only auth, S3 config divergence, multi-store shapes)
    fall back to Spark with an explained reason.
    
    Co-authored-by: Scott Schenkein <sc...@yahoo.com>
    Co-authored-by: Aditya Vaish <ad...@microsoft.com>
    
    * fix: contain provider link failures, gate Hadoop-only S3 endpoints, and check inline DV sizes
    
    Review round: discovery skips a provider whose class cannot link, the S3 claim
    gate declines a scheme-less endpoint with SSL off and any assumed-role STS
    endpoint, inline deletion vectors are checked against their descriptor size,
    row-group offsets use checked arithmetic, and the rebase arms return the input
    batch untouched when nothing predates the cutover. Build and CI: one
    delta.version, the spark test-jar only under the delta profile, a plain-runner
    job for the MinIO suite, a tighter change filter, and docs that name every
    Spark line the workflow runs.
    
    * fix: keep every leaf requested when the name fold fails during rebase planning
    
    * ci: activate the delta profile for the prerequisite installs and set up the MinIO runner with sudo
    
    * perf: pass null-free modern batches through the rebase untouched with one vectorised minimum
    
    * chore: drop redundant interpolators flagged by scalafix
    
    * ci: save the Delta contrib Maven caches on main only
    
    * fix: adapt the Delta contrib to the prepared plan-data API
    
    CometExecRDD now carries the driver-computed plan fingerprint, and PlanDataInjector
    splits parsing the partition-invariant common from injecting a partition. The Delta
    scan passes the fingerprint, and DeltaPlanDataInjector parses the common DeltaSparkScan
    once in prepareCommon and merges only the file list in inject. DeltaPlanDataInjectorSuite
    pins the contract, including reuse and stale replacement through core's shared memo.
    
    * chore: drop redundant string interpolators in CometDeltaNativeScanSuite
    
    * fix: keep the rebase pass-through for nullable all-modern batches
    
    The null-count guard sent any column holding a single null through try_unary, allocating
    a fresh buffer per batch even when every valid value is modern. Null-free arrays keep the
    vectorised minimum; arrays with nulls take one validity-aware pass, and the pass-through
    test asserts the same Arc comes back for masked dates and timestamps under every policy.
    
    * test: let COMET_DELTA_S3_REQUIRED turn a missing MinIO into a hard failure
    
    The dedicated runner job exists only to run CometDeltaS3Suite, so a cancelled run and a
    real one looked the same. The job sets the switch, and the suite then fails instead of
    cancelling when Docker is unavailable or MinIO does not start.
    
    * docs: guard every Delta scan config row and drop the generated-table markers
    
    Nothing fills the CONFIG_TABLE markers on the Delta page, so the table is hand-maintained.
    The guard now renders every DeltaScanConf entry with its default, flags stale rows, and
    fails rather than cancels when the page cannot be found.
    
    * ci: run the Delta contrib suites for one Spark profile in the queue
    
    The single Delta job ran three profiles on every queued change that touched native or
    spark sources. Spark 3.5 now runs in the queue and 4.0 and 4.1 run nightly, with
    run-delta-tests opting a pull request into all three, the same split the Iceberg tiers use.
    The reusable workflow takes the profile as an input, and the MinIO, feature-off and dev
    script jobs run once, on the 3.5 call.
    
    * ci: use setup-java v6 in the Delta MinIO job like the other workflows
    
    * fix: share one memory consumer across a partition's deletion vectors and drain the listener bus in the test helpers
    
    Every DV'd file registered its own memory consumer and the reservation lived in the
    file's extensions until the task ended, so a partition with many DV'd files lowered the
    fair pool's limit for every other operator in the task. attach_access_plans now registers
    one consumer per call and hands each file an empty reservation from it. A test pool that
    copies the fair limit check pins it.
    
    The plan capture helpers unregistered their listener as soon as the body returned, so a
    late callback was missed. They now drain the listener bus, and collectTaskInputMetrics
    does the same instead of polling with a floor.
    
    DV'd files are split like any other claimed file. The planning helper comment says so and
    what each split does today, and a test reads one small-row-group file as many splits.
    
    contrib/delta-spark reads its own delta.spark.version property so the in-tree contrib's
    delta.version, which spark/pom.xml overrides per Spark profile, no longer diverges from it.
    
    * style: drop a redundant string interpolator in the Delta scan suite
    
    * docs: list every check the Delta scan reuses from the core native scan gate
    
    * fix: choose the timestamp rebase policy from the requested type
    
    The native Delta scan picked a timestamp leaf's rebase policy from its
    physical Arrow type, while Spark's ParquetVectorUpdaterFactory keys on the
    Spark type the column is read as. Two cases differed. An INT96 or adjusted
    INT64 column read as TIMESTAMP_NTZ was checked or rebased, though Spark never
    rebases NTZ reads, so an ancient value failed under EXCEPTION. A timezone-free
    INT64 column read as TIMESTAMP was never rebased, though Spark applies the
    datetime rebase mode whatever isAdjustedToUTC says, so EXCEPTION returned the
    row and LEGACY returned it unshifted.
    
    The walk that already pairs each physical leaf with its requested type now
    records the leaves read as TIMESTAMP_NTZ and the timezone-free leaves read as
    TIMESTAMP, and the policy follows that record. Dates keep the date policy,
    including a DATE column read as TIMESTAMP_NTZ, which Spark 4.x rebases.
    
    A metadata-free timezone-free file read as TIMESTAMP under LEGACY is now
    refused, as adjusted files without a recorded writer time zone already are,
    because the rebase needs the JVM's time zone tables.
    
    * perf: limit Delta deletion-vector selectors to each file split
    
    * docs: describe per-split row selectors in the Delta scan planning comment
    
    Each split builds selectors only for the row groups that start inside it
    and shrinks its reservation to match, so the comment no longer says the
    access plan and reservation cover the whole file.
    
    * chore: tighten Delta scan comments
    
    Shorten several comment blocks in the Delta scan and rebase code and
    describe each test case directly. Rename the 1500-01-01 day rebase test
    after what it checks.
    
    * test: check Delta S3 key coverage in the native tests
    
    The Delta suite requires its S3 config comparator to cover every
    fs.s3a.* key the native S3 client reads, but it only runs in the merge
    queue. A core change that adds a key passed the pull request checks and
    then failed in the queue.
    
    A Rust test in s3.rs now reads S3ConfigKeyConsumers from
    DeltaScanSupport.scala and fails when a native key is missing, so the
    pull request run reports it. A Delta suite test checks that the same
    text parse matches the compiled key list, so a reformat of that block
    fails in the Delta change's own run instead of breaking the Rust test
    later.
    
    * fix: skip calendar rebase checks when Spark reads a date or timestamp as a number
    
    Spark picks a numeric updater before any temporal handling when the
    requested type is numeric, so a date read as an integer type or a
    timestamp read as BIGINT comes back as the stored value with no
    calendar check. The native Delta scan still applied the column's
    temporal rebase policy and failed ancient values under EXCEPTION mode,
    for example a metadata-free TIMESTAMP(NANOS) file read as BIGINT with
    spark.sql.legacy.parquet.nanosAsLong after CONVERT TO DELTA.
    
    Leaves requested as one of Spark's numeric pairings now get no rebase
    policy, while temporal requests keep theirs.
    
    * fix: decline split-dependent metadata and resolve SSE-C like Hadoop in the Delta scan
    
    Two gaps in the native Delta scan's admission checks:
    
    - `_metadata.file_block_start` and `file_block_length` came back with
      the wrong split's values on a split file, because DataFusion assigns
      a row group to the split holding its first page while Spark uses its
      midpoint. Core already falls back for these columns; the Delta scan
      claimed the read before core's guard ran. It now declines when either
      column is used above the scan, so deletion-vector reads, which carry
      the whole `_metadata` struct, stay native.
    
    - The SSE-C check resolved the encryption algorithm on the raw Hadoop
      configuration. S3AFileSystem resolves it on the bucket-propagated
      view, so a bucket override reached through a `${...}` reference could
      select SSE-C while the check saw AES256. The algorithm is now
      resolved on both views and the scan declines unless both are on the
      allowlist. A credential provider path is read only when every entry
      is a local keystore or the user provider, since Hadoop drops
      providers backed by other filesystems.
    
    Decline reasons no longer print a resolved configuration value: the
    algorithm reason names only a known algorithm, and the provider-class
    reason names the key and bucket.
    
    * fix: rebase INT32 values Spark reads as DATE in the Delta scan
    
    Spark's Parquet reader rebases an INT32 column requested as DATE
    whether or not the file annotates it as a date. The native Delta scan
    treated an unannotated INT32 leaf as already proleptic, so a legacy or
    metadata-free file converted with CONVERT TO DELTA returned 1500-01-10
    where Spark returns 1500-01-01 under LEGACY, and returned the row where
    Spark refuses it under EXCEPTION.
    
    An INT32 leaf requested as DATE now takes the file's date policy, and
    the stored days are rebased before the schema adapter casts them.
    
    * fix: restore the Delta scan with its live pruning filters on transition revert
    
    When transition reversion hands a stage back to Spark, it restores each
    Comet node's original plan. The Delta native scan inherited the default,
    which returned the original FileSourceScanExec still holding the
    SubqueryAdaptiveBroadcastExec placeholder that AQE had already rewritten
    on the live scan, so execution failed with "SubqueryAdaptiveBroadcastExec
    does not support the execute() code path".
    
    The scan now restores the original plan with its current partition
    filters and logical link, as CometNativeScanExec does. Data filters keep
    the original scan's list, because the live list also carries subquery
    predicates taken from the parent filter.
    
    * test: fix strict-warnings errors in the Delta contrib suites
    
    Literal Hadoop ${...} references now sit in s-strings with $$ so the
    strings are unchanged, spark.range bounds use Long literals, an unused
    helper is removed, and an inferred existential type is spelled out.
    
    * ci: run the Delta contrib suites nightly and compile the contrib in the PR tier
    
    The Spark 3.5 Delta suites leave the merge queue and run nightly with 4.0 and 4.1, still on demand through run-delta-tests. The strict warnings job now compiles with -Pdelta, and changes under contrib/delta-spark route to the Linux PR build, so a change that breaks the contrib build on Spark 3.5 fails on its own pull request instead of in the queue.
    
    * docs: say the Delta contrib jar is built from source and mark the guide experimental
    
    No release publishes comet-contrib-delta-spark yet, so the setup step points at the contrib README's build steps, and the sidebar entry carries the same (experimental) marker as the page heading.
    
    * test: check the timestamp labels of a Delta scan that runs alone
    
    #6868 passes each native plan's Spark output types to CometExecRDD, so
    that under spark.comet.testing.strictTimestampLabels.enabled
    CometExecIterator checks the labels on every batch the plan returns.
    CometDeltaNativeScanExec builds its own CometExecRDD when it is not
    fused into a larger native block, and it passed no output types, so the
    check skipped it. Pass them, as CometNativeScanExec and
    CometIcebergNativeScanExec do.
    
    ---------
    
    Co-authored-by: Scott Schenkein <sc...@yahoo.com>
    Co-authored-by: Aditya Vaish <ad...@microsoft.com>
    Co-authored-by: Andy Grove <ag...@apache.org>
    Co-authored-by: Chao Sun <ch...@openai.com>
---
 .github/workflows/README.md                        |   13 +-
 .github/workflows/ci.yml                           |   45 +-
 .github/workflows/delta_build_gate.yml             |   11 +-
 .github/workflows/delta_contrib_test.yml           |  270 ++
 .github/workflows/pr_build_linux.yml               |    8 +-
 contrib/delta-spark/README.md                      |   70 +
 contrib/delta-spark/dev/bench_delta_comet.py       |  272 ++
 contrib/delta-spark/dev/run-delta-regression.sh    |  176 +
 contrib/delta-spark/pom.xml                        |  241 ++
 .../services/org.apache.comet.CometConfigProvider  |   17 +
 .../org.apache.comet.rules.CometScanContrib        |   17 +
 .../org.apache.spark.sql.comet.PlanDataInjector    |   17 +
 .../comet/contrib/delta/CometDeltaNativeScan.scala |  599 +++
 .../apache/comet/contrib/delta/DeltaScanConf.scala |   76 +
 .../comet/contrib/delta/DeltaScanContrib.scala     |  107 +
 .../comet/contrib/delta/DeltaScanSupport.scala     | 2026 ++++++++++
 .../contrib/delta/DeltaSparkConfigProvider.scala   |   34 +
 .../contrib/delta/DeltaSparkScanEnvelope.scala     |   54 +
 .../spark/sql/comet/CometDeltaNativeScanExec.scala |  329 ++
 .../spark/sql/comet/DeltaPlanDataInjector.scala    |   89 +
 .../contrib/delta/CometDeltaDmlReproSuite.scala    |  155 +
 .../contrib/delta/CometDeltaNativeScanSuite.scala  | 3952 ++++++++++++++++++++
 .../comet/contrib/delta/CometDeltaS3Suite.scala    |  307 ++
 .../comet/contrib/delta/CometDeltaTestBase.scala   |   57 +
 .../contrib/delta/DeltaScanContribSuite.scala      | 2905 ++++++++++++++
 .../sql/comet/DeltaPlanDataInjectorSuite.scala     |  141 +
 dev/ci/check-ci-config.py                          |   41 +-
 dev/ci/check-suites.py                             |    4 +
 dev/ci/compute-changes.py                          |   36 +
 dev/verify-contrib-delta-gate.sh                   |  106 +-
 docs/source/contributor-guide/ci.md                |   14 +-
 docs/source/contributor-guide/development.md       |    2 +-
 docs/source/user-guide/latest/delta.md             |   74 +
 docs/source/user-guide/latest/index.rst            |    1 +
 native/Cargo.lock                                  |    1 +
 native/core/Cargo.toml                             |   23 +-
 native/core/src/execution/delta_dv.rs              | 2748 ++++++++++++++
 native/core/src/execution/mod.rs                   |    2 +
 .../operators/dynamic_filter/join/tests.rs         |    6 +
 .../dynamic_filter/join/tests/schema_errors.rs     |    3 +
 .../join/tests/schema_errors/partition_columns.rs  |    3 +
 .../dynamic_filter/join/tests/timestamp_errors.rs  |    3 +
 .../operators/dynamic_filter/topk/tests.rs         |    3 +
 .../dynamic_filter/topk/tests/timestamp.rs         |    3 +
 native/core/src/execution/planner.rs               |  448 ++-
 .../core/src/execution/planner/delta_spark_scan.rs |  928 +++++
 native/core/src/parquet/datetime_rebase.rs         | 3652 ++++++++++++++++++
 .../src/parquet/eager_page_index_reader_factory.rs |   61 +-
 native/core/src/parquet/mod.rs                     |    1 +
 native/core/src/parquet/objectstore/s3.rs          |  177 +
 native/core/src/parquet/parquet_exec.rs            |  624 +++-
 .../core/src/parquet/parquet_exec/variant_tests.rs |    9 +
 native/core/src/parquet/parquet_support.rs         |  201 +-
 native/core/src/parquet/schema_adapter.rs          |   71 +
 native/proto/src/proto/operator.proto              |   70 +
 pom.xml                                            |   47 +-
 spark/pom.xml                                      |   21 +
 .../scala/org/apache/comet/ContribServices.scala   |   11 +-
 .../org/apache/comet/rules/CometScanContrib.scala  |   26 +-
 .../org/apache/comet/rules/CometScanRule.scala     |    6 +-
 .../comet/serde/operator/CometNativeScan.scala     |  320 +-
 .../org/apache/comet/serde/operator/package.scala  |    4 +-
 .../org/apache/spark/sql/comet/CometExecRDD.scala  |   17 +-
 .../org/apache/spark/sql/comet/operators.scala     |    7 +-
 .../scala/org/apache/comet/CometS3TestBase.scala   |    3 +
 .../apache/comet/rules/CometScanContribSuite.scala |  131 +-
 66 files changed, 21504 insertions(+), 392 deletions(-)

diff --git a/.github/workflows/README.md b/.github/workflows/README.md
index 7e2436df55..1976ca2632 100644
--- a/.github/workflows/README.md
+++ b/.github/workflows/README.md
@@ -24,9 +24,9 @@ ruleset in `.asf.yaml`. That splits CI into three tiers:
   and one Iceberg version, both the default profile's.
 - **Nightly tier** (`nightly`): the regression sweep of everything else, once
   a day against `main` as it stands. The Comet test suites against the other
-  four Spark profiles, Spark SQL on Spark 3.5, 4.0 and 4.2, and Iceberg
-  1.8/1.9/1.10. See [Nightly tier](#nightly-tier) below for how a failure
-  surfaces.
+  four Spark profiles, Spark SQL on Spark 3.5, 4.0 and 4.2, Iceberg
+  1.8/1.9/1.10, and the Delta contrib suites on Spark 3.5, 4.0 and 4.1. See
+  [Nightly tier](#nightly-tier) below for how a failure surfaces.
 
 Every queue-only and nightly job has a `run-*` label that opts a pull request
 into it early, listed in the diagram below. The Lint Java matrix compiles
@@ -129,6 +129,9 @@ tiers partition the list and that the `pr` tier is exactly the default profile.
                                       iceberg_1_8         run-iceberg-tests
                                       iceberg_1_9         run-iceberg-tests
                                       iceberg_1_10        run-iceberg-tests
+                                      delta_3_5           run-delta-tests
+                                      delta_4_0           run-delta-tests
+                                      delta_4_1           run-delta-tests
 
         |                                   |                                   |
         +-----------------------------------+-----------------------------------+
@@ -165,6 +168,9 @@ tiers partition the list and that the `pr` tier is exactly the default profile.
 | `pr_benchmark_check` | merge group, **or** PR with `run-benchmark-check`                                                                                                                                                                                                      | benchmark sources only              |
 | `delta_build_gate`   | merge group, **or** PR with `run-delta-build-gate`                                                                                                                                                                                                     | main sources, poms, `contrib/delta` |
 | `pyarrow_udf_test`   | merge group, **or** PR with `run-pyarrow-udf-tests`                                                                                                                                                                                                    | map-in-batch and Python runner code |
+| `delta_3_5`          | nightly, **or** PR with `run-delta-tests`                                                                                                                                                                                                              | Delta contrib and native sources    |
+| `delta_4_0`          | nightly, **or** PR with `run-delta-tests`                                                                                                                                                                                                              | Delta contrib and native sources    |
+| `delta_4_1`          | nightly, **or** PR with `run-delta-tests`                                                                                                                                                                                                              | Delta contrib and native sources    |
 | `docs`               | push to main, paths matched, **or** dispatch on `main`                                                                                                                                                                                                 | `.asf.yaml`, `docs/**`, `docs.yaml` |
 | `spark_3_5`          | nightly, **or** PR with `run-spark-3.5-tests`                                                                                                                                                                                                          | Spark 3.5 sources                   |
 | `spark_4_1`          | merge group, **or** PR with `run-spark-4.1-tests`; the `sql_hive` shards alone with `run-spark-4.1-hive-tests`                                                                                                                                         | Spark 4.1 sources                   |
@@ -303,6 +309,7 @@ umbrella doesn't watch, or operate independently of the rest of CI:
 | `pr_build_macos.yml`              | `pr_build_macos`                                                |
 | `pr_benchmark_check.yml`          | `pr_benchmark_check`                                            |
 | `delta_build_gate.yml`            | `delta_build_gate`                                              |
+| `delta_contrib_test.yml`          | `delta_3_5`, `delta_4_0`, `delta_4_1`                           |
 | `pyarrow_udf_test.yml`            | `pyarrow_udf_test`                                              |
 | `docs.yaml`                       | `docs`                                                          |
 | `spark_sql_test_reusable.yml`     | `spark_3_4`, `spark_3_5`, `spark_4_0`, `spark_4_1`, `spark_4_2` |
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 075dd29236..936b804272 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -263,6 +263,9 @@ jobs:
       iceberg_1_9:  ${{ steps.compute.outputs.iceberg_1_9 }}
       iceberg_1_10: ${{ steps.compute.outputs.iceberg_1_10 }}
       iceberg_1_11: ${{ steps.compute.outputs.iceberg_1_11 }}
+      delta_3_5:    ${{ steps.compute.outputs.delta_3_5 }}
+      delta_4_0:    ${{ steps.compute.outputs.delta_4_0 }}
+      delta_4_1:    ${{ steps.compute.outputs.delta_4_1 }}
     steps:
       - uses: actions/checkout@v7
         with:
@@ -469,6 +472,43 @@ jobs:
       spark-full: '3.5.9'
       java: 17
 
+  delta_3_5:
+    name: Delta Contrib Tests (Spark 3.5)
+    needs: changes
+    permissions:
+      contents: read
+    # Nightly by default; PRs need the `run-delta-tests` label.
+    if: needs.changes.outputs.delta_3_5 == 'true'
+    uses: ./.github/workflows/delta_contrib_test.yml
+    with:
+      spark: '3.5'
+      java: '17'
+
+  delta_4_0:
+    name: Delta Contrib Tests (Spark 4.0)
+    needs: changes
+    permissions:
+      contents: read
+    # Nightly by default; PRs need the `run-delta-tests` label.
+    if: needs.changes.outputs.delta_4_0 == 'true'
+    uses: ./.github/workflows/delta_contrib_test.yml
+    with:
+      spark: '4.0'
+      java: '17'
+
+  delta_4_1:
+    name: Delta Contrib Tests (Spark 4.1)
+    needs: changes
+    permissions:
+      contents: read
+    # Nightly by default; PRs need the `run-delta-tests` label. No Spark 4.2
+    # caller: the contrib profile is dormant until a Delta release supports it.
+    if: needs.changes.outputs.delta_4_1 == 'true'
+    uses: ./.github/workflows/delta_contrib_test.yml
+    with:
+      spark: '4.1'
+      java: '17'
+
   spark_4_0:
     name: Spark SQL Tests (Spark 4.0)
     needs: changes
@@ -616,6 +656,9 @@ jobs:
       - pyarrow_udf_test
       - spark_3_4
       - spark_3_5
+      - delta_3_5
+      - delta_4_0
+      - delta_4_1
       - spark_4_0
       - spark_4_1
       - spark_4_2
@@ -684,7 +727,7 @@ jobs:
               failed.length ? 'Jobs that did not succeed:' : 'No individual job reported a failure; see the run for details.',
               ...failed,
               '',
-              'The nightly tier runs the Spark and Iceberg versions the merge queue does not',
+              'The nightly tier runs the Spark, Iceberg and Delta versions the merge queue does not',
               '(see `POLICY` in `dev/ci/compute-changes.py`). Close this issue once the failure',
               'is understood; the next red nightly opens a new one.',
             ].join('\n');
diff --git a/.github/workflows/delta_build_gate.yml b/.github/workflows/delta_build_gate.yml
index cd7fd2ac19..caf8a37ae3 100644
--- a/.github/workflows/delta_build_gate.yml
+++ b/.github/workflows/delta_build_gate.yml
@@ -15,12 +15,15 @@
 # specific language governing permissions and limitations
 # under the License.
 
-# Build-gate verification for the optional contrib/delta integration.
+# Build-gate verification for the Delta split of the native library and the JVM build.
 #
 # A single cheap job that runs dev/verify-contrib-delta-gate.sh, which proves:
-#   - the DEFAULT cargo / mvn / dylib build carries ZERO Delta surface
-#     (no comet-contrib-delta / delta_kernel in the cargo tree, no io.delta in
-#     the effective pom, no Delta symbols in libcomet); and
+#   - the kernel-backed `comet-contrib-delta` crate stays out of every shipped
+#     build (no comet-contrib-delta / delta_kernel in the default or
+#     --no-default-features cargo tree, no io.delta in the effective pom, no
+#     contrib symbols in libcomet), while the small default-on `delta` feature
+#     (deletion-vector decoding) is deliberately in and its symbol footprint is
+#     pinned; and
 #   - the gated build (`--features contrib-delta` / `-Pcontrib-delta`) compiles
 #     and pulls the right delta-spark per Spark profile.
 #
diff --git a/.github/workflows/delta_contrib_test.yml b/.github/workflows/delta_contrib_test.yml
new file mode 100644
index 0000000000..8bf1d14b41
--- /dev/null
+++ b/.github/workflows/delta_contrib_test.yml
@@ -0,0 +1,270 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+name: Delta Contrib Tests
+
+# Reusable: invoked by ci.yml once per Spark profile. Triggering, path
+# filters, and concurrency live in the umbrella workflow.
+on:
+  workflow_call:
+    inputs:
+      spark:
+        description: 'Spark minor version, e.g. 3.5'
+        required: true
+        type: string
+      java:
+        description: 'JDK major version, e.g. 17'
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+env:
+  RUST_VERSION: stable
+  RUST_BACKTRACE: 1
+  # Force GNU ld on Linux: rust-lld cannot resolve -ljvm against the Zulu JDK
+  # layout installed by setup-java (same rationale as pr_build_linux.yml).
+  RUSTFLAGS: "-Clink-arg=-fuse-ld=bfd"
+  # The container's default locale is POSIX, which makes the JVM's file-path encoder
+  # reject non-ASCII partition directory names the suites create.
+  LANG: "C.UTF-8"
+  LC_ALL: "C.UTF-8"
+
+jobs:
+
+  contrib-delta:
+    name: Delta contrib (Spark ${{ inputs.spark }})
+    runs-on: ubuntu-24.04
+    container:
+      image: amd64/rust
+    steps:
+      - uses: actions/checkout@v7
+
+      - name: Setup Rust & Java toolchain
+        uses: ./.github/actions/setup-builder
+        with:
+          rust-version: ${{ env.RUST_VERSION }}
+          jdk-version: ${{ inputs.java }}
+
+      - name: Restore Maven dependencies
+        id: maven-cache
+        uses: actions/cache/restore@v6
+        with:
+          path: |
+            ~/.m2/repository
+            /root/.m2/repository
+          key: ${{ runner.os }}-java-maven-${{ hashFiles('**/pom.xml') }}-delta-${{ inputs.spark }}
+          restore-keys: |
+            ${{ runner.os }}-java-maven-
+
+      - name: Restore Cargo cache
+        uses: actions/cache/restore@v6
+        with:
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            native/target
+          key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
+          restore-keys: |
+            ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-
+
+      - name: Build native library (CI profile)
+        run: |
+          cd native
+          # `delta` is in the default feature set, so no feature flag is needed.
+          cargo build --profile ci
+        env:
+          # Must match the flags spark_sql_test_reusable.yml builds with:
+          # cargo folds RUSTFLAGS into its fingerprints, so any divergence
+          # would make the shared cargo cache restore without ever hitting.
+          RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd"
+
+      # No cache save: this workflow never runs on a push to main, so the restore above
+      # falls back to the cache build_linux saves there.
+
+      - name: Stage native library at release path
+        run: |
+          # Maven's -Prelease profile (activated below) expects libcomet.so
+          # under native/target/release/; --profile ci builds it under
+          # native/target/ci/ instead (same as the other native-building
+          # workflows), so copy it into place.
+          mkdir -p native/target/release
+          cp native/target/ci/libcomet.so native/target/release/libcomet.so
+
+      - name: Install Comet core jars
+        run: |
+          # The delta profile is what produces the spark test-jar the contrib suites depend on.
+          ./mvnw -B -q -Prelease -Pspark-${{ inputs.spark }},delta install -pl common,spark -DskipTests -Dspotless.check.skip=true
+
+      - name: Run Delta contrib test suites
+        run: |
+          SPARK_HOME=$(pwd) COMET_CONF_DIR=$(pwd)/conf ./mvnw -B -Prelease -Pspark-${{ inputs.spark }},delta test -pl contrib/delta-spark
+
+      # Saved only on main: an entry written from a pull request or a
+      # `gh-readonly-queue/*` branch cannot be restored by any later run, and
+      # it evicts main's from the shared budget. See "Large caches are written
+      # on main only" in README.md.
+      - name: Save Maven dependencies
+        if: ${{ github.ref == 'refs/heads/main' && steps.maven-cache.outputs.cache-hit != 'true' }}
+        uses: actions/cache/save@v6
+        with:
+          path: |
+            ~/.m2/repository
+            /root/.m2/repository
+          key: ${{ runner.os }}-java-maven-${{ hashFiles('**/pom.xml') }}-delta-${{ inputs.spark }}
+
+  # The container job above has no Docker socket, so CometDeltaS3Suite cancels itself
+  # there. This job runs it on the plain runner, where Testcontainers can start MinIO.
+  contrib-delta-s3:
+    name: Delta contrib S3 suite (Spark 3.5, MinIO)
+    # Pinned to Spark 3.5, so only that caller runs it: once per ci.yml run.
+    if: inputs.spark == '3.5'
+    runs-on: ubuntu-24.04
+    steps:
+      - uses: actions/checkout@v7
+
+      # setup-builder runs apt-get as root inside the container jobs; the hosted runner needs
+      # sudo for that, so the same steps are spelled out here.
+      - name: Install build dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y protobuf-compiler clang
+
+      - name: Install JDK 17
+        uses: actions/setup-java@v6
+        with:
+          distribution: 'zulu'
+          java-version: "17"
+
+      - name: Setup Rust toolchain
+        run: |
+          rustup toolchain install ${{ env.RUST_VERSION }}
+          rustup default ${{ env.RUST_VERSION }}
+          rustup component add rustfmt clippy
+
+      - name: Restore Maven dependencies
+        id: maven-cache
+        uses: actions/cache/restore@v6
+        with:
+          path: |
+            ~/.m2/repository
+          key: ${{ runner.os }}-java-maven-${{ hashFiles('**/pom.xml') }}-delta-3.5
+          restore-keys: |
+            ${{ runner.os }}-java-maven-
+
+      - name: Restore Cargo cache
+        uses: actions/cache/restore@v6
+        with:
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            native/target
+          key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
+          restore-keys: |
+            ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-
+
+      - name: Build native library (CI profile)
+        run: |
+          cd native
+          cargo build --profile ci
+        env:
+          RUSTFLAGS: "-Ctarget-cpu=x86-64-v3 -Clink-arg=-fuse-ld=bfd"
+
+      - name: Stage native library at release path
+        run: |
+          mkdir -p native/target/release
+          cp native/target/ci/libcomet.so native/target/release/libcomet.so
+
+      - name: Install Comet core jars
+        run: |
+          ./mvnw -B -q -Prelease -Pspark-3.5,delta install -pl common,spark -DskipTests -Dspotless.check.skip=true
+
+      - name: Run the MinIO-backed S3 suite
+        run: |
+          docker info > /dev/null
+          SPARK_HOME=$(pwd) COMET_CONF_DIR=$(pwd)/conf ./mvnw -B -Prelease -Pspark-3.5,delta test -pl contrib/delta-spark -DwildcardSuites=org.apache.comet.contrib.delta.CometDeltaS3Suite
+        env:
+          # This job exists only to run the suite, so a Docker or MinIO failure must fail
+          # it instead of cancelling every test, which the container job above relies on.
+          COMET_DELTA_S3_REQUIRED: "1"
+
+      # Saved only on main, for the same reason as the container job above.
+      - name: Save Maven dependencies
+        if: ${{ github.ref == 'refs/heads/main' && steps.maven-cache.outputs.cache-hit != 'true' }}
+        uses: actions/cache/save@v6
+        with:
+          path: |
+            ~/.m2/repository
+          key: ${{ runner.os }}-java-maven-${{ hashFiles('**/pom.xml') }}-delta-3.5
+
+  # `delta` is in the default feature set, so no regular job builds without it;
+  # this keeps the feature-off build and its "built without the delta feature"
+  # error arm (planner.rs cfg(not(feature = "delta"))) from becoming dead code.
+  feature-off-build:
+    name: Feature-off native build
+    # Spark-independent, so only the 3.5 caller runs it: once per ci.yml run.
+    if: inputs.spark == '3.5'
+    runs-on: ubuntu-24.04
+    container:
+      image: amd64/rust
+    steps:
+      - uses: actions/checkout@v7
+
+      - name: Setup Rust & Java toolchain
+        uses: ./.github/actions/setup-builder
+        with:
+          rust-version: ${{ env.RUST_VERSION }}
+          jdk-version: "17"
+
+      - name: Restore Cargo cache
+        uses: actions/cache/restore@v6
+        with:
+          path: |
+            ~/.cargo/registry
+            ~/.cargo/git
+            native/target
+          key: ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-${{ hashFiles('native/**/*.rs') }}
+          restore-keys: |
+            ${{ runner.os }}-cargo-ci-${{ hashFiles('native/**/Cargo.lock', 'native/**/Cargo.toml') }}-
+
+      - name: Test the delta-off error path
+        run: |
+          cd native
+          # The test binary links JNI; libjvm.so must be resolvable at load
+          # time (same as .github/actions/rust-test).
+          export LD_LIBRARY_PATH=${JAVA_HOME}/lib/server:${LD_LIBRARY_PATH}
+          cargo test -p datafusion-comet --no-default-features --features hdfs-opendal delta_scan
+
+  # The contrib's dev tooling (benchmark and regression-harness scripts) is
+  # Python; keep it import-clean on one supported interpreter.
+  dev-scripts-python:
+    name: Delta dev scripts (Python)
+    # Spark-independent, so only the 3.5 caller runs it: once per ci.yml run.
+    if: inputs.spark == '3.5'
+    runs-on: ubuntu-24.04
+    steps:
+      - uses: actions/checkout@v7
+
+      - name: Setup Python
+        uses: actions/setup-python@v6
+        with:
+          python-version: "3.12"
+
+      - name: Byte-compile contrib dev scripts
+        run: |
+          python -m compileall -q contrib/delta-spark/dev
diff --git a/.github/workflows/pr_build_linux.yml b/.github/workflows/pr_build_linux.yml
index 192dc8ffb3..499ad824bc 100644
--- a/.github/workflows/pr_build_linux.yml
+++ b/.github/workflows/pr_build_linux.yml
@@ -242,8 +242,10 @@ jobs:
 
   # Compiles main and test sources with -Pstrict-warnings, which promotes scalac warnings to
   # errors, so a change that reintroduces a cleared warning (an Int widened into a Long metric,
-  # a discarded builder result) fails here rather than accumulating. Spark 3.5 only: the profile
-  # passes on the Scala 2.12 profiles, and the Scala 2.13 remainder is tracked in
+  # a discarded builder result) fails here rather than accumulating. It also compiles the Delta
+  # contrib (-Pdelta) against Spark 3.5, so a change that breaks the contrib build on Spark 3.5
+  # fails on its own pull request rather than in the nightly Delta suites. Spark 3.5 only: the
+  # profile passes on the Scala 2.12 profiles, and the Scala 2.13 remainder is tracked in
   # https://github.com/apache/datafusion-comet/issues/5893.
   strict-scala-warnings:
     needs: lint
@@ -273,7 +275,7 @@ jobs:
             ${{ runner.os }}-java-maven-
 
       - name: Compile with strict warnings
-        run: ./mvnw -B test-compile -Pspark-3.5 -Pstrict-warnings -DskipTests
+        run: ./mvnw -B test-compile -Pspark-3.5,delta -Pstrict-warnings -DskipTests
 
       # Saved only on main: an entry written from a pull request or a
       # `gh-readonly-queue/*` branch cannot be restored by any later run, and
diff --git a/contrib/delta-spark/README.md b/contrib/delta-spark/README.md
new file mode 100644
index 0000000000..89664d3d61
--- /dev/null
+++ b/contrib/delta-spark/README.md
@@ -0,0 +1,70 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+# Comet Delta Lake Contrib (experimental)
+
+Native Delta Lake reads for Comet. Delta tables are scanned through Comet's
+existing native Parquet reader, so they get row-group pruning, page-index
+pruning, and filter pushdown, with deletion vectors applied inside the scan.
+
+Support is experimental and explicitly opt-in. Two things are required:
+
+1. This module's jar (`comet-contrib-delta-spark`) on the classpath, alongside
+   `delta-spark`. It is never bundled into `comet-spark`; without it, Comet
+   has no Delta surface at all.
+2. `spark.comet.scan.delta.enabled=true`. The default is `false`, so the jar
+   alone does nothing.
+
+Unsupported tables and features fall back to Spark's reader. See the
+[user guide](https://datafusion.apache.org/comet/user-guide/latest/delta.html)
+for configuration details.
+
+## Supported versions
+
+| Spark | Delta          | Status                                        |
+| ----- | -------------- | --------------------------------------------- |
+| 3.5   | 3.3.x          | supported                                     |
+| 4.0   | 4.0.x          | supported                                     |
+| 4.1   | 4.3.x          | supported                                     |
+| 3.4   | delta-core 2.4 | not supported (older Delta, would need shims) |
+| 4.2   | none released  | inert until Delta ships a Spark 4.2 release   |
+
+## Building and testing
+
+The module builds under the `delta` Maven profile. It resolves `comet-spark`
+from the local Maven repository, so install `common` and `spark` from the same
+checkout immediately before, as CI does, with the `delta` profile active so that
+install produces the spark test-jar the contrib suites depend on; a stale sibling
+install is the trap the contributor guide warns about:
+
+```shell
+./mvnw -Pspark-3.5,delta install -pl common,spark -DskipTests
+./mvnw -Pspark-3.5,delta install -pl contrib/delta-spark
+```
+
+Run the test suites the same way (`test` instead of `install` on the second
+line). CI runs them via `.github/workflows/delta_contrib_test.yml`: nightly on
+Spark 3.5, 4.0 and 4.1, or on a pull request carrying the `run-delta-tests`
+label.
+`CometDeltaS3Suite` starts MinIO through Testcontainers and cancels itself when
+no Docker daemon is reachable; setting `COMET_DELTA_S3_REQUIRED=1`, as the
+`contrib-delta-s3` CI job does, turns that cancel into a suite failure.
+
+`dev/` contains a benchmark script (`bench_delta_comet.py`) and a harness for
+running Delta's own test suites against Comet (`run-delta-regression.sh`).
diff --git a/contrib/delta-spark/dev/bench_delta_comet.py b/contrib/delta-spark/dev/bench_delta_comet.py
new file mode 100644
index 0000000000..66003c39c3
--- /dev/null
+++ b/contrib/delta-spark/dev/bench_delta_comet.py
@@ -0,0 +1,272 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+"""
+Benchmark: page-level skipping on a DELTA table under three configurations.
+
+  1. stock     -- plain Spark 3.5.6 + delta-spark 3.3.2
+  2. comet     -- Comet enabled WITHOUT the Delta contrib (scan falls back to Spark)
+  3. contrib   -- Comet + comet-contrib-delta (native Delta scan)
+
+Writes a 20M-row table sorted by `ts` (4 files, zstd, small pages) as Delta,
+optionally deletes a slice via DVs, then runs a 5%-wide range predicate and
+reports the fraction of the table materialized by the scan plus wall time.
+
+Usage: python bench_delta_comet.py <mode> <workdir> [--dv] [--subquery]
+  mode: stock | comet | contrib  (jars/extensions injected by the wrapper script)
+  --subquery: bound the range predicate with scalar subqueries over a one-row
+    thresholds Delta table instead of literals. Same rows selected; exercises
+    the execution-time resolve-and-push path (which stock Spark 3.5 lacks:
+    FileSourceStrategy strips subquery predicates from scan dataFilters).
+"""
+
+import os
+import sys
+import time
+
+from pyspark.sql import SparkSession
+from pyspark.sql import functions as F
+
+ROWS = 20_000_000
+FILES = 4
+PRED_LO, PRED_HI = 0.475, 0.525  # 5% slice in the middle
+# DV delete ranges: one nested inside the predicate slice, one far outside it.
+DV_DELETE_LO, DV_DELETE_HI = 0.48, 0.49
+
+
+def build_session(mode: str) -> SparkSession:
+    extensions = "io.delta.sql.DeltaSparkSessionExtension"
+    if mode in ("comet", "contrib"):
+        extensions += ",org.apache.comet.CometSparkSessionExtensions"
+    b = (
+        SparkSession.builder.appName(f"delta-comet-bench-{mode}")
+        .config("spark.sql.extensions", extensions)
+        .config("spark.sql.adaptive.enabled", "false")
+        .config(
+            "spark.sql.catalog.spark_catalog",
+            "org.apache.spark.sql.delta.catalog.DeltaCatalog",
+        )
+        .config("spark.driver.memory", "6g")
+        .config("spark.sql.shuffle.partitions", "8")
+        .config("spark.ui.enabled", "false")
+        .config("spark.hadoop.parquet.page.size", str(64 * 1024))
+        .config("spark.hadoop.parquet.block.size", str(32 * 1024 * 1024))
+    )
+    if mode in ("comet", "contrib"):
+        b = (
+            b.config("spark.comet.enabled", "true")
+            .config("spark.comet.exec.enabled", "true")
+            .config("spark.comet.exec.shuffle.enabled", "true")
+            .config(
+                "spark.shuffle.manager",
+                "org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager",
+            )
+            .config("spark.memory.offHeap.enabled", "true")
+            .config("spark.memory.offHeap.size", "4g")
+            .config("spark.comet.explainFallback.enabled", "true")
+        )
+    if mode == "contrib":
+        b = b.config("spark.comet.scan.delta.enabled", "true")
+    return b.getOrCreate()
+
+
+def write_table(spark: SparkSession, path: str, with_dv: bool) -> None:
+    df = (
+        spark.range(ROWS)
+        .withColumn("ts", F.col("id"))
+        .withColumn("payload", F.sha1(F.col("id").cast("string")))
+        .repartitionByRange(FILES, "ts")
+        .sortWithinPartitions("ts")
+    )
+    (
+        df.write.format("delta")
+        .option("compression", "zstd")
+        .mode("overwrite")
+        .save(path)
+    )
+    if with_dv:
+        spark.sql(
+            f"ALTER TABLE delta.`{path}` SET TBLPROPERTIES "
+            "('delta.enableDeletionVectors' = 'true')"
+        )
+        lo = int(ROWS * DV_DELETE_LO)
+        hi = int(ROWS * DV_DELETE_HI)
+        spark.sql(f"DELETE FROM delta.`{path}` WHERE ts >= {lo} AND ts < {hi}")
+
+
+def scan_metrics(plan):
+    """Walk the executed plan and pull metrics from the leaf scan node(s).
+
+    Safe to call right after collect(): the Dataset caches its QueryExecution,
+    per-task SQLMetric accumulator updates are merged on the driver before the
+    job completes, and AQE is disabled so the executed plan is final.
+    """
+    from py4j.protocol import Py4JError, Py4JJavaError
+
+    out = {}
+
+    def walk(node):
+        try:
+            name = node.nodeName()
+            if "Scan" in name:
+                metrics = node.metrics()
+                it = metrics.keysIterator()
+                while it.hasNext():
+                    k = it.next()
+                    out.setdefault((name, k), metrics.get(k).get().value())
+            for i in range(node.children().length()):
+                walk(node.children().apply(i))
+            # innerChildren covers plan-in-plan nodes; entries may not be
+            # SparkPlans, so failures here are ignored rather than fatal.
+            inner = node.innerChildren()
+            for i in range(inner.length()):
+                walk(inner.apply(i))
+        except (Py4JError, Py4JJavaError):
+            pass
+
+    walk(plan)
+    return out
+
+
+def has_native_scan_with_column(plan, column: str) -> bool:
+    """True if the executed plan (including subquery inner plans) contains a
+    CometDeltaNativeScan whose output includes `column`. Programmatic version of
+    the test suite's `output.exists(_.name == col)` check -- identifies the MAIN
+    table's scan by its distinctive column, since subquery mode adds trivial
+    thresholds-table scans that would fool any name-only or count-based check.
+    """
+    from py4j.protocol import Py4JError, Py4JJavaError
+
+    def walk(node) -> bool:
+        try:
+            if node.nodeName().startswith("CometDeltaNativeScan"):
+                attrs = node.output()
+                for i in range(attrs.length()):
+                    if attrs.apply(i).name() == column:
+                        return True
+            for i in range(node.children().length()):
+                if walk(node.children().apply(i)):
+                    return True
+            inner = node.innerChildren()
+            for i in range(inner.length()):
+                if walk(inner.apply(i)):
+                    return True
+        except (Py4JError, Py4JJavaError):
+            pass
+        return False
+
+    return walk(plan)
+
+
+def pred_bounds() -> tuple[int, int]:
+    """Single source of truth for the range bounds, so the literal and subquery
+    modes are guaranteed to select the same rows."""
+    return int(ROWS * PRED_LO), int(ROWS * PRED_HI)
+
+
+def write_thresholds(spark: SparkSession, thr_path: str) -> None:
+    lo, hi = pred_bounds()
+    spark.sql(
+        f"SELECT CAST({lo} AS BIGINT) AS lo, CAST({hi} AS BIGINT) AS hi"
+    ).write.format("delta").mode("overwrite").save(thr_path)
+
+
+def run_query(spark: SparkSession, path: str, thr_path: str | None = None):
+    if thr_path is not None:
+        df = spark.sql(
+            f"SELECT count(*) AS n, sum(length(payload)) AS s FROM delta.`{path}` "
+            f"WHERE ts >= (SELECT lo FROM delta.`{thr_path}`) "
+            f"AND ts < (SELECT hi FROM delta.`{thr_path}`)"
+        )
+    else:
+        lo, hi = pred_bounds()
+        df = (
+            spark.read.format("delta")
+            .load(path)
+            .where((F.col("ts") >= lo) & (F.col("ts") < hi))
+            .agg(F.count("*").alias("n"), F.sum(F.length("payload")).alias("s"))
+        )
+    t0 = time.perf_counter()
+    row = df.collect()[0]
+    elapsed = time.perf_counter() - t0
+    plan = df._jdf.queryExecution().executedPlan()
+    mets = scan_metrics(plan)
+    main_scan_native = has_native_scan_with_column(plan, "payload")
+    return row, elapsed, mets, plan.toString(), main_scan_native
+
+
+def main():
+    if len(sys.argv) < 3 or sys.argv[1] not in ("stock", "comet", "contrib"):
+        print(__doc__)
+        sys.exit(2)
+    mode, workdir = sys.argv[1], sys.argv[2]
+    with_dv = "--dv" in sys.argv
+    with_subquery = "--subquery" in sys.argv
+    path = f"{workdir}/delta_bench{'_dv' if with_dv else ''}"
+    thr_path = f"{workdir}/delta_bench_thr" if with_subquery else None
+    spark = build_session(mode)
+    spark.sparkContext.setLogLevel("WARN")
+
+    if not os.path.exists(path + "/_delta_log"):
+        print(f"[bench] writing table to {path}")
+        write_table(spark, path, with_dv)
+    if thr_path is not None and not os.path.exists(thr_path + "/_delta_log"):
+        write_thresholds(spark, thr_path)
+
+    try:
+        # warm-up then measured run
+        run_query(spark, path, thr_path)
+        row, elapsed, mets, plan_str, main_scan_native = run_query(spark, path, thr_path)
+    except BaseException:
+        spark.stop()
+        raise
+
+    print(f"\n=== mode={mode} dv={with_dv} subquery={with_subquery} ===")
+    print(f"result: n={row['n']} sum={row['s']}")
+    print(f"wall_time_s: {elapsed:.3f}")
+    interesting = (
+        "output_rows",
+        "numOutputRows",
+        "bytes_scanned",
+        "page_index_rows_pruned",
+        "page_index_rows_matched",
+        "row_groups_pruned_statistics",
+        "row_groups_matched_statistics",
+        "numFiles",
+        "filesSize",
+    )
+    for (node, k), v in sorted(mets.items()):
+        if any(k == i for i in interesting):
+            print(f"metric: {node} :: {k} = {v}")
+    # rows materialized by the scan as fraction of table
+    scanned = [v for (n, k), v in mets.items() if k in ("output_rows", "numOutputRows")]
+    if scanned:
+        frac = max(scanned) / ROWS
+        print(f"scan_fraction: {frac:.4f}")
+    seen = {k for (_, k) in mets}
+    for key in ("output_rows", "numOutputRows"):
+        if key in seen:
+            break
+    else:
+        print("WARNING: no scan row metrics found; scan_fraction unavailable")
+    if mode == "contrib" and not main_scan_native:
+        print("WARNING: contrib mode but the main table's scan is not CometDeltaNativeScan!")
+    spark.stop()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/contrib/delta-spark/dev/run-delta-regression.sh b/contrib/delta-spark/dev/run-delta-regression.sh
new file mode 100755
index 0000000000..44cffb8d8a
--- /dev/null
+++ b/contrib/delta-spark/dev/run-delta-regression.sh
@@ -0,0 +1,176 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+# Run Delta Lake's own Spark test suites against a Comet build with the
+# native Delta scan enabled. Clones delta at $DELTA_VERSION into $WORKDIR,
+# injects Comet into the test SparkSession (DeltaSQLCommandTest) and the
+# test classpath (unmanagedJars), then runs the given testOnly selectors.
+#
+# Usage:
+#   COMET_JARS=/path/comet-spark.jar,/path/comet-contrib-delta.jar,/path/flatbuffers.jar \
+#   ./run-delta-regression.sh <workdir> 'org.apache.spark.sql.delta.DeletionVectorsSuite' [...]
+#
+# Env:
+#   DELTA_VERSION  delta tag to test against (default 3.3.2)
+#   COMET_JARS     comma-separated jars added to the test classpath (required)
+#   JAVA_HOME      JDK for sbt (17 recommended)
+set -euo pipefail
+
+DELTA_VERSION="${DELTA_VERSION:-3.3.2}"
+WORKDIR="${1:?usage: run-delta-regression.sh <workdir> <suite> [...suites]}"
+shift
+[ $# -ge 1 ] || { echo "no suites given" >&2; exit 2; }
+: "${COMET_JARS:?COMET_JARS must list the comet jars}"
+
+# Resolve to an absolute path before the cd below: the log path is built from
+# $WORKDIR after we're already inside the Delta checkout, so a relative
+# argument would otherwise be re-anchored under $DELTA_DIR.
+mkdir -p "$WORKDIR"
+WORKDIR=$(cd "$WORKDIR" && pwd)
+
+# Canonicalize each entry to an absolute path before the cd below, for the same
+# reason as the WORKDIR normalization above: the injected sbt `file(p)` resolves
+# a relative COMET_EXTRA_JARS entry beneath $DELTA_DIR, not the caller's directory,
+# once we've already changed into the Delta checkout.
+IFS=',' read -ra _jars <<< "$COMET_JARS"
+_jars_abs=()
+for j in "${_jars[@]}"; do
+  [ -f "$j" ] || { echo "COMET_JARS entry not found: $j" >&2; exit 2; }
+  _jars_abs+=("$(cd "$(dirname "$j")" && pwd)/$(basename "$j")")
+done
+COMET_JARS=$(IFS=','; echo "${_jars_abs[*]}")
+
+DELTA_DIR="$WORKDIR/delta-$DELTA_VERSION"
+if [ ! -d "$DELTA_DIR" ]; then
+  git clone --depth 1 --branch "v$DELTA_VERSION" https://github.com/delta-io/delta.git "$DELTA_DIR"
+elif [ ! -d "$DELTA_DIR/.git" ]; then
+  echo "stale/partial checkout at $DELTA_DIR; remove it (rm -rf) and rerun" >&2
+  exit 2
+fi
+cd "$DELTA_DIR"
+
+# Add COMET_EXTRA_JARS to every project's test classpath, plus the JDK-17
+# module-access flags Spark needs (both for forked test JVMs and sbt's own JVM).
+if ! grep -q "COMET_EXTRA_JARS" build.sbt; then
+  python3 - <<'EOF'
+s = open('build.sbt').read()
+marker = 'lazy val commonSettings = Seq('
+opens = [
+    "--add-opens=java.base/java.lang=ALL-UNNAMED",
+    "--add-opens=java.base/java.lang.invoke=ALL-UNNAMED",
+    "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED",
+    "--add-opens=java.base/java.io=ALL-UNNAMED",
+    "--add-opens=java.base/java.net=ALL-UNNAMED",
+    "--add-opens=java.base/java.nio=ALL-UNNAMED",
+    "--add-opens=java.base/java.util=ALL-UNNAMED",
+    "--add-opens=java.base/java.util.concurrent=ALL-UNNAMED",
+    "--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED",
+    "--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED",
+    "--add-opens=java.base/sun.nio.ch=ALL-UNNAMED",
+    "--add-opens=java.base/sun.nio.cs=ALL-UNNAMED",
+    "--add-opens=java.base/sun.security.action=ALL-UNNAMED",
+    "--add-opens=java.base/sun.util.calendar=ALL-UNNAMED",
+    "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",
+]
+opts = ", ".join('"%s"' % o for o in opens)
+inject = (
+    'lazy val commonSettings = Seq(\n'
+    '  Test / unmanagedJars ++= sys.env.get("COMET_EXTRA_JARS").toSeq\n'
+    '    .flatMap(_.split(",")).map(p => Attributed.blank(file(p))),\n'
+    '  Test / fork := true,\n'
+    '  Test / javaOptions ++= Seq(%s),\n' % opts
+)
+assert marker in s, 'commonSettings marker not found'
+open('build.sbt', 'w').write(s.replace(marker, inject, 1))
+EOF
+fi
+
+# Inject Comet into the shared test SparkSession when COMET_EXTRA_JARS is set.
+TEST_BASE=spark/src/test/scala/org/apache/spark/sql/delta/test/DeltaSQLCommandTest.scala
+if ! grep -q "CometSparkSessionExtensions" "$TEST_BASE"; then
+  python3 - "$TEST_BASE" <<'EOF'
+import sys
+p = sys.argv[1]
+s = open(p).read()
+old = '''  override protected def sparkConf: SparkConf = {
+    super.sparkConf
+      .set(StaticSQLConf.SPARK_SESSION_EXTENSIONS.key,
+        classOf[DeltaSparkSessionExtension].getName)
+      .set(SQLConf.V2_SESSION_CATALOG_IMPLEMENTATION.key,
+        classOf[DeltaCatalog].getName)
+  }'''
+new = '''  override protected def sparkConf: SparkConf = {
+    val conf = super.sparkConf
+      .set(StaticSQLConf.SPARK_SESSION_EXTENSIONS.key,
+        classOf[DeltaSparkSessionExtension].getName)
+      .set(SQLConf.V2_SESSION_CATALOG_IMPLEMENTATION.key,
+        classOf[DeltaCatalog].getName)
+    if (sys.env.contains("COMET_EXTRA_JARS")) {
+      conf
+        .set(StaticSQLConf.SPARK_SESSION_EXTENSIONS.key,
+          classOf[DeltaSparkSessionExtension].getName +
+            ",org.apache.comet.CometSparkSessionExtensions")
+        .set("spark.comet.enabled", "true")
+        .set("spark.comet.exec.enabled", "true")
+        .set("spark.comet.exec.shuffle.enabled", "true")
+        .set("spark.shuffle.manager",
+          "org.apache.spark.sql.comet.execution.shuffle.CometShuffleManager")
+        .set("spark.memory.offHeap.enabled", "true")
+        .set("spark.memory.offHeap.size", "2g")
+        .set("spark.comet.scan.delta.enabled", "true")
+    } else conf
+  }'''
+assert old in s, 'sparkConf block not found'
+open(p, 'w').write(s.replace(old, new))
+EOF
+fi
+
+# ScanReportHelper is a test-only trait that counts scans by pattern-matching
+# FileSourceScanExec in the executed plan. The Comet Delta scan replaces those
+# nodes, so claimed scans would go uncounted ("0 did not equal 2" in
+# MergeIntoSuiteBase's insert-only data-skipping test). Map the Comet node back
+# to the FileSourceScanExec it was built from: originalPlan carries the same
+# PreparedDeltaFileIndex, so the reported paths and skipping stats are identical.
+SCAN_HELPER=spark/src/test/scala/org/apache/spark/sql/delta/test/ScanReportHelper.scala
+if [ -f "$SCAN_HELPER" ] && ! grep -q "CometDeltaNativeScanExec" "$SCAN_HELPER"; then
+  python3 - "$SCAN_HELPER" <<'EOF'
+import sys
+p = sys.argv[1]
+s = open(p).read()
+old = "      case fs: FileSourceScanExec => Seq(fs)\n"
+new = ("      case fs: FileSourceScanExec => Seq(fs)\n"
+       "      case c: org.apache.spark.sql.comet.CometDeltaNativeScanExec =>\n"
+       "        Seq(c.originalPlan)\n")
+assert s.count(old) == 1, s.count(old)
+open(p, 'w').write(s.replace(old, new))
+EOF
+fi
+
+export COMET_EXTRA_JARS="$COMET_JARS"
+export SPARK_LOCAL_IP=127.0.0.1
+export RUST_BACKTRACE=1
+
+cmds=()
+for sel in "$@"; do
+  cmds+=("spark/testOnly $sel")
+done
+
+LOG="$WORKDIR/delta-regression-$(date +%Y%m%d-%H%M%S).log"
+echo "==> logging to $LOG"
+build/sbt "${cmds[@]}" 2>&1 | tee "$LOG" | grep -E "^\[info\] (Tests:|Suites:|All tests|.*\*\*\* FAILED| - )" | tail -80
diff --git a/contrib/delta-spark/pom.xml b/contrib/delta-spark/pom.xml
new file mode 100644
index 0000000000..172a04ed27
--- /dev/null
+++ b/contrib/delta-spark/pom.xml
@@ -0,0 +1,241 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.datafusion</groupId>
+    <artifactId>comet-parent-spark${spark.version.short}_${scala.binary.version}</artifactId>
+    <version>1.2.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+
+  <artifactId>comet-contrib-delta-spark${spark.version.short}_${scala.binary.version}</artifactId>
+  <name>comet-contrib-delta</name>
+
+  <properties>
+    <!-- This module sits one directory deeper than common/spark, so the default
+         jni.dir (basedir/../native) would point at contrib/native. -->
+    <jni.dir>${project.basedir}/../../native/target/debug</jni.dir>
+    <maven.deploy.skip>false</maven.deploy.skip>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.datafusion</groupId>
+      <artifactId>comet-spark-spark${spark.version.short}_${scala.binary.version}</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>io.delta</groupId>
+      <artifactId>${delta.artifact}_${scala.binary.version}</artifactId>
+      <version>${delta.spark.version}</version>
+      <scope>provided</scope>
+      <exclusions>
+        <!-- Spark provides jcl-over-slf4j; a transitive commons-logging would duplicate it
+             and trip the BanDuplicateClasses enforcer rule. -->
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.spark</groupId>
+      <artifactId>spark-sql_${scala.binary.version}</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <!-- The shaded comet-spark jar bundles+relocates org.apache.arrow:* but NOT its
+         com.google.flatbuffers dependency (it is excluded from relocation to keep JNI
+         lookups working), so consumers must supply it. -->
+    <dependency>
+      <groupId>com.google.flatbuffers</groupId>
+      <artifactId>flatbuffers-java</artifactId>
+      <version>25.2.10</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- Comet's parent excludes Arrow from Spark's transitive deps (its shaded jar carries a
+         relocated copy), but spark-sql's own columnar classes still reference unshaded Arrow
+         at runtime in tests. -->
+    <dependency>
+      <groupId>org.apache.arrow</groupId>
+      <artifactId>arrow-vector</artifactId>
+      <version>${arrow.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.arrow</groupId>
+      <artifactId>arrow-memory-unsafe</artifactId>
+      <version>${arrow.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.arrow</groupId>
+      <artifactId>arrow-c-data</artifactId>
+      <version>${arrow.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <!-- parquet is provided-scope repo-wide (parquet.maven.scope), so tests must bring it
+         explicitly, same as the spark module. -->
+    <dependency>
+      <groupId>org.apache.parquet</groupId>
+      <artifactId>parquet-column</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.parquet</groupId>
+      <artifactId>parquet-hadoop</artifactId>
+    </dependency>
+    <!-- Test dependencies -->
+    <dependency>
+      <groupId>org.apache.datafusion</groupId>
+      <artifactId>comet-spark-spark${spark.version.short}_${scala.binary.version}</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.scalatest</groupId>
+      <artifactId>scalatest_${scala.binary.version}</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <!-- MinIO-backed integration coverage for cross-bucket Delta scans (CometDeltaS3Suite),
+         same GAVs as the spark module's CometS3TestBase / ParquetReadFromS3Suite; versions and
+         the docker-java transitive override come from the root pom's dependencyManagement. -->
+    <dependency>
+      <groupId>org.testcontainers</groupId>
+      <artifactId>minio</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>software.amazon.awssdk</groupId>
+      <artifactId>s3</artifactId>
+    </dependency>
+    <!-- Provides the org.apache.hadoop.fs.s3a.S3AFileSystem class (via its hadoop-aws transitive
+         dependency) so s3a:// paths resolve on the test classpath; same GAV as the spark
+         module's own test dependency (spark/pom.xml), version/scope/exclusions from the root
+         pom's dependencyManagement. -->
+    <dependency>
+      <groupId>org.apache.spark</groupId>
+      <artifactId>spark-hadoop-cloud_${scala.binary.version}</artifactId>
+      <classifier>tests</classifier>
+    </dependency>
+    <!-- delta-spark 4.x uses guava caches at runtime; Spark 4.1's test classpath no longer
+         provides it transitively. -->
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>${guava.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.scalatestplus</groupId>
+      <artifactId>junit-4-13_${scala.binary.version}</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.spark</groupId>
+      <artifactId>spark-sql_${scala.binary.version}</artifactId>
+      <version>${spark.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.spark</groupId>
+      <artifactId>spark-core_${scala.binary.version}</artifactId>
+      <version>${spark.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+      <exclusions>
+        <!-- Spark provides jcl-over-slf4j; hadoop-client-runtime's commons-logging would
+             duplicate it and trip the BanDuplicateClasses enforcer rule. -->
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.spark</groupId>
+      <artifactId>spark-catalyst_${scala.binary.version}</artifactId>
+      <version>${spark.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>scala-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.scalatest</groupId>
+        <artifactId>scalatest-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>${maven-enforcer-plugin.version}</version>
+        <executions>
+          <execution>
+            <!-- Same execution id as the root pom so this configuration merges into the
+                 inherited rule instead of adding a second enforcer run. -->
+            <id>no-duplicate-declared-dependencies</id>
+            <configuration>
+              <rules>
+                <banDuplicateClasses>
+                  <dependencies combine.children="append">
+                    <dependency>
+                      <groupId>org.apache.datafusion</groupId>
+                      <artifactId>comet-common-spark${spark.version.short}_${scala.binary.version}</artifactId>
+                      <ignoreClasses>
+                        <!-- The comet-spark shaded jar bundles comet-common, so a reactor package
+                             build hands this module both copies of every comet-common class.
+                             Shade rewrites constant pools, so ignoreWhenIdentical cannot
+                             collapse them all. -->
+                        <ignoreClass>org.apache.comet.*</ignoreClass>
+                      </ignoreClasses>
+                    </dependency>
+                  </dependencies>
+                </banDuplicateClasses>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <!-- Mirror the root pom's "release" profile: the base jni.dir above is
+         path-adjusted for this module's extra directory depth, so it must be
+         re-adjusted here too, or activating -Prelease from the root would be
+         silently ignored and this module would keep loading the debug build. -->
+    <profile>
+      <id>release</id>
+      <properties>
+        <jni.dir>${project.basedir}/../../native/target/release</jni.dir>
+      </properties>
+    </profile>
+  </profiles>
+
+</project>
diff --git a/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.comet.CometConfigProvider b/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.comet.CometConfigProvider
new file mode 100644
index 0000000000..6db01e4b24
--- /dev/null
+++ b/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.comet.CometConfigProvider
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+org.apache.comet.contrib.delta.DeltaSparkConfigProvider
diff --git a/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.comet.rules.CometScanContrib b/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.comet.rules.CometScanContrib
new file mode 100644
index 0000000000..25a913e0cd
--- /dev/null
+++ b/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.comet.rules.CometScanContrib
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+org.apache.comet.contrib.delta.DeltaScanContrib
diff --git a/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.spark.sql.comet.PlanDataInjector b/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.spark.sql.comet.PlanDataInjector
new file mode 100644
index 0000000000..c26629ec37
--- /dev/null
+++ b/contrib/delta-spark/src/main/resources/META-INF/services/org.apache.spark.sql.comet.PlanDataInjector
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+org.apache.spark.sql.comet.DeltaPlanDataInjector
diff --git a/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/CometDeltaNativeScan.scala b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/CometDeltaNativeScan.scala
new file mode 100644
index 0000000000..3659ab4c33
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/CometDeltaNativeScan.scala
@@ -0,0 +1,599 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import scala.jdk.CollectionConverters._
+
+import org.apache.hadoop.fs.Path
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.catalyst.expressions.Literal
+import org.apache.spark.sql.comet.{CometScanExec, DeltaPlanDataInjector}
+import org.apache.spark.sql.delta.DeltaParquetFileFormat
+import org.apache.spark.sql.delta.RowIndexFilterType
+import org.apache.spark.sql.delta.actions.DeletionVectorDescriptor
+import org.apache.spark.sql.execution.{FileSourceScanExec, ScalarSubquery => ExecScalarSubquery}
+import org.apache.spark.sql.execution.datasources.{FilePartition, PartitionedFile}
+import org.apache.spark.sql.types.{ByteType, LongType, MetadataBuilder, StructField, StructType}
+
+import org.apache.comet.CometSparkSessionExtensions.withFallbackReason
+import org.apache.comet.objectstore.NativeConfig
+import org.apache.comet.serde.OperatorOuterClass
+import org.apache.comet.serde.OperatorOuterClass.Operator
+import org.apache.comet.serde.QueryPlanSerde.{exprToProto, serializeDataType}
+import org.apache.comet.serde.operator.{literalToProto, partition2Proto, schema2Proto, CometNativeScan}
+import org.apache.comet.shims.ShimFileFormat
+
+/**
+ * Serde for the native Delta scan. Two shapes:
+ *   - Plain reads reuse core's `NativeScanCommon` builder wholesale.
+ *   - Deletion-vector reads: Delta's planner appends `__delta_internal_is_row_deleted` (tinyint)
+ *     and Spark's row-index temp column (bigint) to the read schema and filters on is_row_deleted
+ *     above the scan. The native reader applies the DV as a row selection, so both internal
+ *     columns are emitted as per-file constants (0), the parquet read schema is stripped to the
+ *     real data columns, and the DV descriptor ships per file for native to fetch and decode.
+ */
+object CometDeltaNativeScan
+    extends Logging
+    with org.apache.spark.sql.catalyst.expressions.PredicateHelper {
+
+  val IsRowDeletedColumn: String = DeltaParquetFileFormat.IS_ROW_DELETED_COLUMN_NAME
+  val RowIndexColumn: String = ShimFileFormat.ROW_INDEX_TEMPORARY_COLUMN_NAME
+
+  private[delta] val internalColumnNames: Set[String] = Set(IsRowDeletedColumn, RowIndexColumn)
+
+  // Prefix for the internal columns' slots in the partition schema, mirroring core's
+  // _comet_metadata_ prefix rationale: DataFusion matches partition columns by name.
+  // [[allocateUniqueInternalFields]] additionally suffixes on collision with a real column.
+  private val deltaConstFieldPrefix = "_comet_delta_"
+
+  def isDvShape(scanExec: FileSourceScanExec): Boolean =
+    scanExec.requiredSchema.exists(f => internalColumnNames.contains(f.name))
+
+  private def deltaFormat(scanExec: FileSourceScanExec): DeltaParquetFileFormat =
+    scanExec.relation.fileFormat.asInstanceOf[DeltaParquetFileFormat]
+
+  private def columnMappingMode(scanExec: FileSourceScanExec): String =
+    deltaFormat(scanExec).metadata.columnMappingMode.name
+
+  /**
+   * Under column mapping, parquet files store physical column names (stable UUIDs / ids), so the
+   * schemas passed to the native parquet reader must be physical. Positions and structure are
+   * preserved, so output binding and projection are unaffected. The scan's internal DV columns
+   * are not part of the table schema and must be stripped before calling this.
+   *
+   * `private[delta]` (not `private`): [[DeltaScanSupport.declineReason]]'s non-ASCII
+   * case-insensitive name gate reuses this exact conversion to compute the names native sees
+   * under column mapping, rather than re-deriving physical names with separate logic.
+   */
+  private[delta] def toPhysical(scanExec: FileSourceScanExec, schema: StructType): StructType = {
+    val format = deltaFormat(scanExec)
+    if (format.metadata.columnMappingMode.name == "none") {
+      schema
+    } else {
+      // Name mode matches file columns by physical NAME. Strip the parquet.field.id metadata
+      // createPhysicalSchema also stamps: files written before the column-mapping upgrade have
+      // no field ids and would fail the reader's id expectations.
+      stripFieldIds(org.apache.spark.sql.delta.DeltaColumnMapping
+        .createPhysicalSchema(schema, format.metadata.schema, format.metadata.columnMappingMode))
+    }
+  }
+
+  private def stripFieldIds(schema: StructType): StructType = {
+    import org.apache.spark.sql.types._
+    def stripType(dt: DataType): DataType = dt match {
+      case s: StructType => stripFieldIds(s)
+      case a: ArrayType => a.copy(elementType = stripType(a.elementType))
+      case m: MapType =>
+        m.copy(keyType = stripType(m.keyType), valueType = stripType(m.valueType))
+      case other => other
+    }
+    StructType(schema.fields.map { f =>
+      val metadata = new MetadataBuilder()
+        .withMetadata(f.metadata)
+        .remove("parquet.field.id")
+        // Sibling key Delta stamps on array/map fields under IcebergCompat/Uniform.
+        .remove("parquet.field.nested.ids")
+        .build()
+      f.copy(dataType = stripType(f.dataType), metadata = metadata)
+    })
+  }
+
+  /**
+   * Build the planning-time `DeltaScan` operator (common data only; file partitions are injected
+   * lazily at execution). Returns None when an output data type cannot be serialized or the plan
+   * shape is not one we can translate faithfully, and tags `scanExec` with the reason when the
+   * data files need more than one ABFS store. `memo` is the same claim-memo instance
+   * [[DeltaScanSupport.declineReason]] populated on this claim; its `hadoopConf` and
+   * `dvDescriptors` are reused here rather than recomputed.
+   */
+  def convert(
+      scanExec: FileSourceScanExec,
+      scanHelper: CometScanExec,
+      memo: DeltaScanSupport.DeltaClaimMemo): Option[Operator] = {
+    val relation = scanExec.relation
+
+    val dataFileUris = scanHelper.selectedPartitions.view.flatMap(_.files).map(_.getPath.toUri)
+    val firstFileUri = dataFileUris.headOption
+
+    val hadoopConf = memo.hadoopConf
+
+    val objectStoreOptions =
+      NativeConfig.extractScanObjectStoreOptions(hadoopConf, dataFileUris) match {
+        case Right(options) => options
+        case Left(reason) =>
+          // declineReason already declines data files on more than one store; this only
+          // catches ABFS authorities that differ in case or percent-encoding alone.
+          withFallbackReason(scanExec, reason)
+          return None
+      }
+
+    val tableRootPath = relation.location.rootPaths.head
+    val tableRoot = tableRootPath.toString
+
+    val commonOpt = if (!isDvShape(scanExec)) {
+      // Under column mapping (name mode) the parquet reader must see physical names;
+      // positions are preserved so output binding and projection stay untouched.
+      CometNativeScan.buildNativeScanCommon(
+        source = scanExec.simpleStringWithNodeId(),
+        output = scanExec.output,
+        requiredSchema = toPhysical(scanExec, scanExec.requiredSchema),
+        dataSchema = toPhysical(scanExec, relation.dataSchema),
+        partitionSchema = toPhysical(scanExec, relation.partitionSchema),
+        fileConstantMetadataColumns = scanExec.fileConstantMetadataColumns,
+        dataFilters = scanHelper.supportedDataFilters,
+        objectStoreOptions = objectStoreOptions,
+        hadoopConf = hadoopConf,
+        conf = scanExec.conf)
+    } else {
+      buildDvScanCommon(scanExec, scanHelper, objectStoreOptions, hadoopConf)
+    }
+
+    commonOpt.map { commonBuilder =>
+      // Already forced by declineReason on this claim; reused rather than deserialized again.
+      val dvDescriptors = memo.dvDescriptors
+      // Union object-store options over every authority a partition of this scan may need a
+      // store for, not just the first data file's scheme.
+      commonBuilder.putAllObjectStoreOptions(
+        mergedObjectStoreOptions(
+          hadoopConf,
+          storeUris(dvDescriptors, tableRootPath, firstFileUri)).asJava)
+
+      val common = commonBuilder.build()
+      // Effective session rebase read modes, resolved through ParquetOptions exactly as
+      // ParquetFileFormat.buildReaderWithPartitionValues resolves them (per-relation
+      // `datetimeRebaseMode` / `int96RebaseMode` options win over the session conf, whose
+      // per-Spark-version default -- EXCEPTION on 3.x, CORRECTED on 4.0 -- SQLConf supplies).
+      // Native consults them only for files whose footer metadata does not decide the rebase
+      // policy on its own, mirroring DataSourceUtils.getRebaseSpec's modeByConfig fallback.
+      val parquetReadOptions =
+        new org.apache.spark.sql.execution.datasources.parquet.ParquetOptions(
+          relation.options,
+          scanExec.conf)
+      val deltaCommon = OperatorOuterClass.DeltaSparkScanCommon
+        .newBuilder()
+        .setTableRoot(tableRoot)
+        .setColumnMappingMode(columnMappingMode(scanExec))
+        .setSourceKey(DeltaPlanDataInjector.sourceKey(tableRoot, common))
+        .setDatetimeRebaseModeInRead(parquetReadOptions.datetimeRebaseModeInRead)
+        .setInt96RebaseModeInRead(parquetReadOptions.int96RebaseModeInRead)
+        .build()
+      val deltaScan = OperatorOuterClass.DeltaSparkScan
+        .newBuilder()
+        .setCommon(common)
+        .setDeltaCommon(deltaCommon)
+      Operator
+        .newBuilder()
+        .setPlanId(scanExec.id)
+        .setContribScan(DeltaSparkScanEnvelope.pack(deltaScan.build()))
+        .build()
+    }
+  }
+
+  /**
+   * One representative store URI per distinct object-store authority this scan's partitions may
+   * need options for: the data-file authority (`firstFileUri`), the table root unconditionally
+   * (UUID-relative DV sidecars resolve against it), and every distinct on-disk DV authority from
+   * `descriptors` (inline DVs carry no external URI and are filtered out). Deduping by authority
+   * rather than full URI keeps this O(distinct authorities) instead of O(files), keeping the
+   * FIRST URI seen per authority so `firstFileUri`/the table root win over a same-authority DV
+   * path.
+   */
+  private[delta] def storeUris(
+      descriptors: Seq[DeletionVectorDescriptor],
+      tableRootPath: Path,
+      firstFileUri: Option[java.net.URI]): Seq[java.net.URI] = {
+    val dvAuthorityUris = descriptors
+      .filter(_.storageType != DeletionVectorDescriptor.INLINE_DV_MARKER)
+      .map(_.absolutePath(tableRootPath).toUri)
+    val candidates = firstFileUri.toSeq ++ Seq(tableRootPath.toUri) ++ dvAuthorityUris
+    val byAuthority = scala.collection.mutable.LinkedHashMap.empty[String, java.net.URI]
+    candidates.foreach(uri =>
+      byAuthority.getOrElseUpdate(DeltaScanSupport.uriAuthority(uri), uri))
+    byAuthority.values.toSeq
+  }
+
+  /**
+   * Unions `NativeConfig.extractObjectStoreOptions` over every `uris` authority. Safe to union
+   * rather than pick one: S3 and GCS options sit under their own scheme's prefix, and
+   * re-extracting the same scheme from two URIs is idempotent. Azure options are not scoped to an
+   * account and overlap (WASB copies `fs.azure.*`; ABFS forwards `comet.azure.*` markers plus
+   * global `fs.azure.*` keys), but only the table root can bring an Azure authority here:
+   * `DeltaScanSupport.declineReason` declines Azure data files and deletion vectors, whose
+   * container is userinfo.
+   */
+  private[delta] def mergedObjectStoreOptions(
+      hadoopConf: org.apache.hadoop.conf.Configuration,
+      uris: Seq[java.net.URI]): Map[String, String] =
+    uris.foldLeft(Map.empty[String, String]) { (merged, uri) =>
+      merged ++ NativeConfig.extractObjectStoreOptions(hadoopConf, uri)
+    }
+
+  /**
+   * Harvest subquery-bearing predicates for this scan from its covering FilterExec. Spark 3.x
+   * strips them from a scan's `dataFilters` at planning (`FileSourceStrategy` routes them to the
+   * post-scan filter only), while Spark 4.x keeps them in `dataFilters`; collecting them here at
+   * claim time gives the execution-time resolve-and-push path the same inputs on every version,
+   * and the dedup below keeps Spark 4.x from carrying duplicates. Reference containment alone
+   * does not prove pushing a predicate down is semantics-preserving, so `spineToScan` also
+   * requires every intervening operator to commute with the push (an intervening
+   * LIMIT/Sort/Aggregate/join etc. stops the walk and leaves the filter where Spark placed it:
+   * missed pruning only).
+   */
+  def subqueryFiltersFromParent(
+      plan: org.apache.spark.sql.execution.SparkPlan,
+      scanExec: FileSourceScanExec): Seq[org.apache.spark.sql.catalyst.expressions.Expression] = {
+    import org.apache.spark.sql.catalyst.expressions.{PlanExpression, SubqueryExpression}
+    import org.apache.spark.sql.execution.{FilterExec, ProjectExec, SparkPlan}
+
+    // Whether every node from `node` down to `scanExec` is one pushdown can safely cross: a
+    // deterministic ProjectExec is 1:1 on rows and a deterministic FilterExec only removes rows,
+    // so moving a predicate over the scan's output through either preserves semantics -- mirroring
+    // Spark's own PushPredicateThroughNonJoin/CollapseProject rules. A nondeterministic node (or
+    // anything else: LIMIT/TopN, Sort, Aggregate, Window, joins, ...) can change which rows survive
+    // to matter, so it stops the walk and the filter is left uncollected (missed pruning only).
+    def spineToScan(node: SparkPlan): Boolean = node match {
+      case n if n eq scanExec => true
+      case p: ProjectExec if p.projectList.forall(_.deterministic) => spineToScan(p.child)
+      case f: FilterExec if f.condition.deterministic => spineToScan(f.child)
+      case _ => false
+    }
+
+    // Nearest FilterExec whose spine down to the scan is Project/Filter-only (the DV shape
+    // interposes such nodes between them, so do not require a direct parent-child edge).
+    val filtersAboveScan = plan.collect {
+      case f: FilterExec if spineToScan(f.child) => f
+    }
+    filtersAboveScan.lastOption
+      .map { f =>
+        splitConjunctivePredicates(f.condition)
+          .filter(_.deterministic)
+          .filter(_.references.subsetOf(scanExec.outputSet))
+          .filter(p =>
+            SubqueryExpression.hasSubquery(p) || p.exists(_.isInstanceOf[PlanExpression[_]]))
+          .filterNot(p => scanExec.dataFilters.exists(_.semanticEquals(p)))
+      }
+      .getOrElse(Seq.empty)
+  }
+
+  /**
+   * Execution-time scalar-subquery data filters of a scan. `hasResolvedFilters` is true whenever
+   * pushdown is enabled and such filters exist, whether or not they bind or serialize; `protos`
+   * holds only the ones that serialized.
+   */
+  case class ResolvedSubqueryFilters(
+      hasResolvedFilters: Boolean,
+      protos: Seq[org.apache.comet.serde.ExprOuterClass.Expr])
+
+  private val NoResolvedSubqueryFilters = ResolvedSubqueryFilters(false, Seq.empty)
+
+  /**
+   * Resolve scalar-subquery data filters at execution time and serialize them for native
+   * pushdown, mirroring `CometNativeScanExec.serializedPartitionData`. `supportedDataFilters`
+   * excludes PlanExpressions at planning time (subquery results do not exist yet), so these
+   * bounds reach the native reader only through this path. Filters that fail to serialize are
+   * skipped: Spark keeps a covering FilterExec above the scan, so this is missed pruning only.
+   * Their presence is still reported, since native keys the safe timestamp conversion on the scan
+   * being filtered at all, as the core scan does for its resolved filters.
+   *
+   * Known core-parity limitation: when fused under a parent native operator,
+   * `ensureSubqueriesResolved` has already called `updateResult()` on these subqueries and this
+   * path calls it again (`ScalarSubquery.updateResult` re-executes unconditionally); benign here
+   * since the subquery's snapshot is pinned at analysis, but wasteful. Fix belongs in core.
+   */
+  def resolvedSubqueryFilters(
+      dataFilters: Seq[org.apache.spark.sql.catalyst.expressions.Expression],
+      output: Seq[org.apache.spark.sql.catalyst.expressions.Attribute],
+      requiredSchema: StructType,
+      conf: org.apache.spark.sql.internal.SQLConf): ResolvedSubqueryFilters = {
+    if (!conf.getConf(org.apache.spark.sql.internal.SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED)) {
+      return NoResolvedSubqueryFilters
+    }
+    val subqueryFilters = dataFilters.filter(_.exists(_.isInstanceOf[ExecScalarSubquery]))
+    if (subqueryFilters.isEmpty) {
+      return NoResolvedSubqueryFilters
+    }
+    // Same binding guard as the DV shape's plan-time filters: references limited to the
+    // data-column prefix of the output, where positions agree with the native read schema.
+    // Guard BEFORE updateResult so discarded filters never execute their subqueries.
+    val strippedLen = requiredSchema.count(f => !internalColumnNames.contains(f.name))
+    val dataColIds = output.take(strippedLen).map(_.exprId).toSet
+    val pushableFilters =
+      subqueryFilters.filter(_.references.forall(r => dataColIds.contains(r.exprId)))
+    pushableFilters.foreach(_.foreach {
+      case s: ExecScalarSubquery => s.updateResult()
+      case _ =>
+    })
+    val protos = pushableFilters
+      .flatMap { filter =>
+        // MergeScalarSubqueries can fuse several scalar subqueries into one struct-returning
+        // subquery accessed via GetStructField; fold that whole subtree to a literal (a bare
+        // GetStructField-over-Literal would not serialize).
+        val resolved = filter.transform {
+          case g @ org.apache.spark.sql.catalyst.expressions
+                .GetStructField(_: ExecScalarSubquery, _, _) =>
+            Literal.create(g.eval(null), g.dataType)
+          case s: ExecScalarSubquery =>
+            Literal.create(s.eval(null), s.dataType)
+        }
+        val proto = exprToProto(resolved, output)
+        if (proto.isEmpty) {
+          logWarning(s"Could not serialize resolved scalar subquery filter: $resolved")
+        }
+        proto
+      }
+    ResolvedSubqueryFilters(hasResolvedFilters = true, protos)
+  }
+
+  /**
+   * Allocate the partition-schema slots for the DV shape's internal columns
+   * (`internalColumnNames`), with names collision-free against the physical data schema, the
+   * physical partition schema, and the constant-metadata slots already allocated for this scan
+   * (plus each other): DataFusion substitutes partition constants BY NAME, so an unprefixed,
+   * un-uniquified slot could collide with a real column and silently replace its data with the
+   * bookkeeping constant. `buildDvScanCommon` keys `internalIndexByName` by each field's ORIGINAL
+   * name from `requiredSchema`, so the renaming here only changes the proto's field name.
+   */
+  private[delta] def allocateUniqueInternalFields(
+      requiredSchema: StructType,
+      physicalDataSchema: StructType,
+      physicalPartitionSchema: StructType,
+      constantMetadataFields: Seq[StructField]): Seq[StructField] = {
+    val reserved = scala.collection.mutable.LinkedHashSet[String]()
+    reserved ++= physicalDataSchema.fields.map(_.name)
+    reserved ++= physicalPartitionSchema.fields.map(_.name)
+    reserved ++= constantMetadataFields.map(_.name)
+    requiredSchema.fields.toSeq
+      .filter(f => internalColumnNames.contains(f.name))
+      .map { f =>
+        var name = s"$deltaConstFieldPrefix${f.name}"
+        while (reserved.contains(name)) {
+          name = name + "_"
+        }
+        reserved += name
+        StructField(name, f.dataType, f.nullable)
+      }
+  }
+
+  /**
+   * DV shape common builder. Layout invariants (declined by DeltaScanSupport when violated): scan
+   * output = requiredSchema attrs (data columns, then the internal columns as a suffix) followed
+   * by partition and constant-metadata columns. The parquet read schema strips the internal
+   * columns; they are appended to the partition schema as per-file constants, so the projection
+   * vector routes them from the constants block.
+   */
+  private def buildDvScanCommon(
+      scanExec: FileSourceScanExec,
+      scanHelper: CometScanExec,
+      objectStoreOptions: Map[String, String],
+      hadoopConf: org.apache.hadoop.conf.Configuration)
+      : Option[OperatorOuterClass.NativeScanCommon.Builder] = {
+    val relation = scanExec.relation
+    val output = scanExec.output
+    val requiredSchema = scanExec.requiredSchema
+
+    val commonBuilder = OperatorOuterClass.NativeScanCommon.newBuilder()
+    commonBuilder.setSource(scanExec.simpleStringWithNodeId())
+
+    val scanTypes = output.flatMap(attr => serializeDataType(attr.dataType))
+    if (scanTypes.length != output.length) {
+      return None
+    }
+    commonBuilder.addAllFields(scanTypes.asJava)
+
+    val strippedRequired =
+      StructType(requiredSchema.filterNot(f => internalColumnNames.contains(f.name)))
+    val strippedLen = strippedRequired.length
+    val requiredLen = requiredSchema.length
+
+    // Keep only data filters that bind identically in the output and the native index space:
+    // references limited to the first strippedLen output attributes. Internal-column filters
+    // (is_row_deleted = 0) are trivially true after native DV application.
+    if (scanExec.conf.getConf(
+        org.apache.spark.sql.internal.SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED)) {
+      commonBuilder.setHasDataFilters(scanHelper.supportedDataFilters.nonEmpty)
+      val dataColIds = output.take(strippedLen).map(_.exprId).toSet
+      val filterProtos = scanHelper.supportedDataFilters
+        .filter(_.references.forall(r => dataColIds.contains(r.exprId)))
+        .flatMap(f => exprToProto(f, output))
+      commonBuilder.addAllDataFilters(filterProtos.asJava)
+    }
+
+    // Real partition columns carry physical names in the proto, same as the data/required
+    // schemas: a retained physical data name can otherwise collide with a partition column's
+    // LOGICAL name after a rename history, and DataFusion's by-name partition rewrite would then
+    // replace the data projection with the partition constant. constantMetadataFields/
+    // internalFields are synthetic slots, not table columns, so they are not physicalized.
+    val physicalDataSchema = toPhysical(scanExec, relation.dataSchema)
+    val physicalPartitionSchema = toPhysical(scanExec, relation.partitionSchema)
+    // Constant metadata and real partition columns follow the required schema in the output,
+    // exactly like the plain shape. Names are uniquified against the physical data/partition
+    // schemas for the same by-name-collision reason [[allocateUniqueInternalFields]] exists.
+    val constantMetadataFields = CometNativeScan.uniqueConstantMetadataFields(
+      scanExec.fileConstantMetadataColumns,
+      physicalDataSchema.fields.map(_.name).toSet ++ physicalPartitionSchema.fields
+        .map(_.name)
+        .toSet)
+    val internalFields = allocateUniqueInternalFields(
+      requiredSchema,
+      physicalDataSchema = physicalDataSchema,
+      physicalPartitionSchema = physicalPartitionSchema,
+      constantMetadataFields = constantMetadataFields)
+    val partitionSchemaFields =
+      physicalPartitionSchema.fields.toSeq ++ constantMetadataFields ++ internalFields
+
+    // Protos carry physical names (column mapping); index math below stays logical.
+    val partitionSchemaProto = schema2Proto(partitionSchemaFields)
+    val physicalRequired = toPhysical(scanExec, strippedRequired)
+    val requiredSchemaProto = schema2Proto(physicalRequired)
+    val dataSchemaProto = schema2Proto(physicalDataSchema)
+
+    // Projection: data columns from the (stripped) read schema; internal columns from their
+    // constants slots at the END of the partition fields; the output tail (real partitions +
+    // constant metadata) positionally from the head of the partition fields.
+    val dataSchema = relation.dataSchema
+    val internalBase = dataSchema.length + partitionSchemaFields.length - internalFields.length
+    val internalIndexByName = requiredSchema.fields.toSeq
+      .filter(f => internalColumnNames.contains(f.name))
+      .zipWithIndex
+      .map { case (f, i) => f.name -> (internalBase + i) }
+      .toMap
+    val projectionVector = output.zipWithIndex.map { case (attr, i) =>
+      val idx = if (internalColumnNames.contains(attr.name)) {
+        internalIndexByName(attr.name)
+      } else if (i < requiredLen) {
+        dataSchema.fieldIndex(attr.name)
+      } else {
+        dataSchema.length + (i - requiredLen)
+      }
+      idx.toLong.asInstanceOf[java.lang.Long]
+    }
+    commonBuilder.addAllProjectionVector(projectionVector.asJava)
+
+    commonBuilder.addAllDataSchema(dataSchemaProto.asJava)
+    commonBuilder.addAllRequiredSchema(requiredSchemaProto.asJava)
+    commonBuilder.addAllPartitionSchema(partitionSchemaProto.asJava)
+
+    // The physical schema, as in the plain shape: it is what DeltaParquetFileFormat hands
+    // Spark's ParquetReadSupport, so the field id flags match the ids Spark checks.
+    CometNativeScan.populateScanConfFlags(
+      commonBuilder,
+      physicalRequired,
+      objectStoreOptions,
+      hadoopConf,
+      scanExec.conf)
+
+    Some(commonBuilder)
+  }
+
+  /** Serialize one file partition into a DeltaSparkScan proto with per-file DV descriptors. */
+  def serializePartition(
+      filePartition: FilePartition,
+      scanExec: FileSourceScanExec,
+      tableRoot: String): Array[Byte] = {
+    val relation = scanExec.relation
+    val sparkPartition = partition2Proto(
+      filePartition,
+      relation.partitionSchema,
+      scanExec.fileConstantMetadataColumns,
+      ShimFileFormat.fileConstantMetadataExtractors(relation.fileFormat))
+
+    val dvShape = isDvShape(scanExec)
+
+    val deltaPartition = OperatorOuterClass.DeltaSparkFilePartition.newBuilder()
+    sparkPartition.getPartitionedFileList.asScala.zip(filePartition.files.toSeq).foreach {
+      case (fileProto, file) =>
+        val fileBuilder = fileProto.toBuilder
+        if (dvShape) {
+          // Append the internal-constant values after the real partition/constant-metadata
+          // values, matching the order of the appended partition-schema fields.
+          scanExec.requiredSchema.fields
+            .filter(f => internalColumnNames.contains(f.name))
+            .foreach { f =>
+              val lit = f.dataType match {
+                case ByteType => Literal(0.toByte, ByteType)
+                case LongType => Literal(0L, LongType)
+                case other =>
+                  // Fixed internal invariant (observed Delta 3.3 types); fail loudly on
+                  // drift rather than emit a plausible-looking constant.
+                  throw new IllegalStateException(
+                    s"Unexpected type $other for Delta internal column ${f.name}")
+              }
+              fileBuilder.addPartitionValues(
+                literalToProto(lit, s"delta internal constant ${f.name}"))
+            }
+        }
+        val dfb = OperatorOuterClass.DeltaSparkPartitionedFile
+          .newBuilder()
+          .setFile(fileBuilder.build())
+        extractDvDescriptor(file, tableRoot).foreach(dfb.setDv)
+        deltaPartition.addPartitionedFile(dfb.build())
+    }
+
+    OperatorOuterClass.DeltaSparkScan
+      .newBuilder()
+      .setFilePartition(deltaPartition.build())
+      .build()
+      .toByteArray
+  }
+
+  /**
+   * Pull the DV descriptor Delta attached to this file (base64 under
+   * `row_index_filter_id_encoded`), resolving UUID-relative paths to absolute URLs and
+   * Z85-decoding inline bitmaps here on the JVM where delta-spark's codecs live.
+   */
+  private def extractDvDescriptor(
+      file: PartitionedFile,
+      tableRoot: String): Option[OperatorOuterClass.DeltaSparkDvDescriptor] = {
+    val encoded = file.otherConstantMetadataColumnValues
+      .get(DeltaParquetFileFormat.FILE_ROW_INDEX_FILTER_ID_ENCODED)
+    val filterType = file.otherConstantMetadataColumnValues
+      .get(DeltaParquetFileFormat.FILE_ROW_INDEX_FILTER_TYPE)
+    encoded.map { enc =>
+      filterType match {
+        case Some(RowIndexFilterType.IF_CONTAINED) | None =>
+        case other =>
+          // DeltaScanSupport declines CDF reads, the only source of inverted filters;
+          // reaching here means a gate was bypassed -- fail loudly rather than corrupt.
+          throw new IllegalStateException(
+            s"Native Delta scan cannot apply row index filter type $other")
+      }
+      val desc = DeletionVectorDescriptor.deserializeFromBase64(enc.asInstanceOf[String])
+      val builder = OperatorOuterClass.DeltaSparkDvDescriptor
+        .newBuilder()
+        .setStorageType(desc.storageType)
+        .setSizeInBytes(desc.sizeInBytes)
+        .setCardinality(desc.cardinality)
+      if (desc.storageType == DeletionVectorDescriptor.INLINE_DV_MARKER) {
+        // Delegates to core, which owns the shaded/relocated dependency this field's setter
+        // is generated against, so this module's source never has to name that package.
+        CometNativeScan.setDvInlineData(builder, desc.inlineData)
+      } else {
+        // Same convention as data-file paths (SparkPath.urlEncoded): a raw Hadoop path
+        // with spaces or % characters would be mangled by the native URL parse.
+        builder.setAbsolutePath(
+          org.apache.spark.paths.SparkPath
+            .fromPath(desc.absolutePath(new Path(tableRoot)))
+            .urlEncoded)
+        desc.offset.foreach(builder.setOffset)
+      }
+      builder.build()
+    }
+  }
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanConf.scala b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanConf.scala
new file mode 100644
index 0000000000..c94e01493d
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanConf.scala
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import org.apache.comet.{ConfigBuilder, ConfigEntry}
+
+/**
+ * Configuration for the JVM-planned Delta Lake scan contrib. The support is experimental and
+ * explicitly opt-in: having the contrib jar on the classpath is not enough, the scan must also be
+ * enabled with `spark.comet.scan.delta.enabled`.
+ *
+ * This is the plain, user-facing flag for enabling native Delta scans, kept under the
+ * `spark.comet.scan.delta` namespace. The experimental Rust-kernel-backed scan path is a separate
+ * opt-in, defined by the kernel contrib's own `DeltaConf` under the
+ * `spark.comet.scan.deltaNative` namespace; the two jars define distinct keys and are not
+ * expected to coexist -- see the ownership contract in `CometScanContrib`. Entry construction
+ * self-registers with `CometConf.allConfs` via the `ConfigBuilder` machinery.
+ */
+object DeltaScanConf {
+
+  // Matches the kernel contrib's category so both group onto the same generated-docs table.
+  private[delta] val CATEGORY = "delta"
+
+  val COMET_DELTA_NATIVE_ENABLED: ConfigEntry[Boolean] =
+    ConfigBuilder("spark.comet.scan.delta.enabled")
+      .category(CATEGORY)
+      .doc(
+        "Whether to enable native Delta table scans. When enabled, DSv1 Delta table reads " +
+          "planned by delta-spark are executed through Comet's native Parquet scan, " +
+          "inheriting row-group pruning, page-index pruning, and filter pushdown, with " +
+          "deletion vectors applied inside the scan. Experimental: defaults to false, so " +
+          "adding the contrib jar does not by itself change how any query is read.")
+      .booleanConf
+      .createWithDefault(false)
+
+  val COMET_DELTA_MAX_DELETED_ROWS_PER_FILE: ConfigEntry[Long] =
+    ConfigBuilder("spark.comet.scan.delta.dv.maxDeletedRowsPerFile")
+      .category(CATEGORY)
+      .doc(
+        "Upper bound on a single file's deletion-vector cardinality (deleted row count) the " +
+          "native Delta scan will claim. Applying a deletion vector expands it into per-row " +
+          "selectors that are held in memory. This bound caps one file's selectors, not what a " +
+          "task holds: the selectors for every file in a partition stay held until the task " +
+          "finishes. The bound is a deliberately pessimistic planning-time proxy for that " +
+          "memory (deletion vector cardinality, not the exact selector count), so a large but " +
+          "contiguous deletion is declined the same as a large alternating one. Scans whose " +
+          "deletion vectors exceed this bound for any file fall back to Spark's reader.")
+      .longConf
+      .createWithDefault(1000000)
+
+  /**
+   * Every entry defined here, in docs order. Referencing this forces object initialisation, which
+   * registers the entries -- see `CometConfigProvider`.
+   */
+  def all: Seq[ConfigEntry[_]] =
+    Seq(COMET_DELTA_MAX_DELETED_ROWS_PER_FILE, COMET_DELTA_NATIVE_ENABLED)
+
+  def scanEnabled: Boolean = COMET_DELTA_NATIVE_ENABLED.get()
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanContrib.scala b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanContrib.scala
new file mode 100644
index 0000000000..f34bcaec11
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanContrib.scala
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.comet.CometDeltaNativeScanExec
+import org.apache.spark.sql.execution.{FileSourceScanExec, SparkPlan}
+import org.apache.spark.sql.execution.datasources.HadoopFsRelation
+
+import org.apache.comet.CometConf.COMET_EXEC_ENABLED
+import org.apache.comet.CometSparkSessionExtensions.{hasFallbackReason, withFallbackReason}
+import org.apache.comet.rules.CometScanContrib
+
+/**
+ * Claims DSv1 Delta Lake scans for native execution, discovered by core's ServiceLoader (see
+ * `META-INF/services/org.apache.comet.rules.CometScanContrib`). Scans this contrib owns but
+ * cannot handle are claimed with a tagged fallback reason (per the `CometScanContrib` ownership
+ * contract); Spark's Delta reader then handles them.
+ *
+ * The produced `CometDeltaNativeScanExec` is fully converted at claim time, so this contrib does
+ * NOT use `CometContribScanMarker` (which exists for planning-time nodes that `CometExecRule`
+ * converts later; mixing it in here would convert the node a second time).
+ */
+class DeltaScanContrib extends CometScanContrib with Logging {
+
+  override def tryTransformV1(
+      plan: SparkPlan,
+      session: SparkSession,
+      scanExec: FileSourceScanExec,
+      relation: HadoopFsRelation): Option[SparkPlan] = {
+    // Not a Delta scan: not ours; core handles it exactly as before.
+    if (!DeltaScanSupport.isDeltaScan(scanExec)) {
+      return None
+    }
+
+    // Contrib scans are native-exec nodes, so like core's own nativeScan they require
+    // COMET_EXEC_ENABLED. Our old core-side hook gated all extensions centrally; the
+    // CometScanContrib call site does not, so the gate lives here. Silent None (no tag)
+    // preserves the old "never consulted" behavior and avoids double-tagging next to
+    // core's own exec-disabled fallback reason.
+    if (!COMET_EXEC_ENABLED.get()) {
+      return None
+    }
+
+    if (!DeltaScanConf.scanEnabled) {
+      // Deliberate deviation from the "own but cannot handle => claim" contract: a
+      // user-disabled contrib must be fully inert (the jar alone changes nothing) and must
+      // not shadow another registered Delta contrib. Tag the opt-in hint for EXPLAIN, pass.
+      withFallbackReason(
+        scanExec,
+        "Native Delta scan not enabled: set " +
+          s"${DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key}=true to opt in")
+      return None
+    }
+
+    // Built before declineReason (rather than only on claim) so the multi-object-store gate
+    // can inspect the scan's selected files without listing them twice; convert reuses this
+    // same helper on a claim.
+    val scanHelper =
+      CometDeltaNativeScanExec.planningHelper(scanExec, scanExec.partitionFilters)
+    // Populated by declineReason on the claimable path only, and reused by convert below so a
+    // claimed scan does not recompute the Hadoop conf or the DV descriptors a second time.
+    val claimMemo = new DeltaScanSupport.DeltaClaimMemo
+    DeltaScanSupport.declineReason(plan, scanExec, scanHelper, claimMemo) match {
+      case Some(reason) =>
+        Some(withFallbackReason(scanExec, reason))
+      case None =>
+        CometDeltaNativeScan.convert(scanExec, scanHelper, claimMemo) match {
+          case Some(nativeOp) =>
+            logDebug(
+              s"COMET-DELTA-CLAIM required=${scanExec.requiredSchema.map(_.name).mkString(",")} " +
+                s"output=${scanExec.output.map(_.name).mkString(",")} " +
+                s"dvShape=${CometDeltaNativeScan.isDvShape(scanExec)} " +
+                s"planRoot=${plan.getClass.getSimpleName}")
+            val subqueryDataFilters =
+              CometDeltaNativeScan.subqueryFiltersFromParent(plan, scanExec)
+            Some(CometDeltaNativeScanExec(nativeOp, scanExec, subqueryDataFilters))
+          // convert tags its own reason when it declines the scan's object stores.
+          case None if hasFallbackReason(scanExec) =>
+            Some(scanExec)
+          case None =>
+            Some(
+              withFallbackReason(
+                scanExec,
+                "Native Delta scan does not support the scan's output data types"))
+        }
+    }
+  }
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanSupport.scala b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanSupport.scala
new file mode 100644
index 0000000000..91b9006af6
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaScanSupport.scala
@@ -0,0 +1,2026 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import java.io.IOException
+import java.net.{URI, URISyntaxException}
+import java.util.Locale
+
+import scala.collection.mutable.{ListBuffer, Map => MutableMap}
+import scala.jdk.CollectionConverters._
+
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.fs.Path
+import org.apache.spark.sql.catalyst.expressions.{Alias, ExprId, GenericInternalRow, InputFileBlockLength, InputFileBlockStart, InputFileName}
+import org.apache.spark.sql.catalyst.util.{ArrayBasedMapData, GenericArrayData}
+import org.apache.spark.sql.catalyst.util.ResolveDefaultColumns.getExistenceDefaultValues
+import org.apache.spark.sql.comet.CometScanExec
+import org.apache.spark.sql.delta.DeltaParquetFileFormat
+import org.apache.spark.sql.delta.actions.DeletionVectorDescriptor
+import org.apache.spark.sql.execution.{FileSourceScanExec, ProjectExec, SparkPlan}
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.types.{ArrayType, DataType, MapType, StructType}
+
+import org.apache.comet.CometConf
+import org.apache.comet.CometConf.COMET_LIBHDFS_SCHEMES
+import org.apache.comet.objectstore.NativeConfig
+import org.apache.comet.parquet.CometParquetUtils
+import org.apache.comet.rules.{CometScanRule, CometScanTypeChecker}
+import org.apache.comet.serde.operator.CometNativeScan
+import org.apache.comet.shims.ShimFileFormat
+
+/**
+ * Claim/decline gates for the native Delta scan. Correctness rule: when in doubt, decline,
+ * Spark's Delta reader handles the scan and results stay correct, just unaccelerated.
+ */
+object DeltaScanSupport {
+
+  /**
+   * Reader features the native path understands; anything else on the protocol declines the
+   * table. `deletionVectors`/`columnMapping` are declined separately below for specific reasons.
+   */
+  private val understoodReaderFeatures: Set[String] =
+    Set("columnMapping", "deletionVectors", "timestampNtz", "v2Checkpoint", "vacuumProtocolCheck")
+
+  /**
+   * Is this exactly Delta's DSv1 parquet format? Compared by class name, not `classOf`: a
+   * `classOf` reference would raise `NoClassDefFoundError` and break every parquet scan when
+   * delta-spark is absent from the classpath.
+   */
+  def isDeltaScan(scanExec: FileSourceScanExec): Boolean =
+    scanExec.relation.fileFormat.getClass.getName ==
+      "org.apache.spark.sql.delta.DeltaParquetFileFormat"
+
+  /**
+   * Claim-time artifacts [[declineReason]] already computes but [[CometDeltaNativeScan.convert]]
+   * also needs -- threaded through by reference (populated only on the claimable path, right
+   * before `declineReason` returns `None`) so a claimed scan does not pay to recompute either:
+   * the Hadoop conf ([[org.apache.spark.sql.internal.SessionState#newHadoopConfWithOptions]] is
+   * not cheap) and the deletion-vector descriptors (base64-decoded, non-trivial only for DV-shape
+   * scans). One instance is created per claim attempt in `DeltaScanContrib` and passed to both
+   * `declineReason` and `convert`.
+   */
+  private[delta] final class DeltaClaimMemo {
+    var hadoopConf: Configuration = _
+    var dvDescriptors: Seq[DeletionVectorDescriptor] = Seq.empty
+  }
+
+  /**
+   * First reason this Delta scan cannot go native, or None when claimable (in which case `memo`
+   * is populated for [[CometDeltaNativeScan.convert]] to reuse). Only called when [[isDeltaScan]]
+   * is true. `scanHelper` is the [[CometScanExec]] built to drive `convert` on a claim, reused
+   * for the multi-store gate below.
+   */
+  def declineReason(
+      plan: SparkPlan,
+      scanExec: FileSourceScanExec,
+      scanHelper: CometScanExec,
+      memo: DeltaClaimMemo): Option[String] = {
+    val format = scanExec.relation.fileFormat.asInstanceOf[DeltaParquetFileFormat]
+    val protocol = format.protocol
+    val metadata = format.metadata
+    // Name mode is supported via physical-name schemas; id mode needs the field-id path and
+    // stays declined until validated. Hoisted here since several gates below reuse it.
+    val cmMode = metadata.columnMappingMode.name
+    // Descriptor deserialization is expensive, so hoist it into a `lazy val`, forced at most
+    // once in this method; on the claimable path the result is handed to `convert` through
+    // `memo` below, so a claimed scan deserializes the descriptors exactly once end to end.
+    val tableRoot = scanExec.relation.location.rootPaths.head.toString
+    lazy val dvDescriptors: Seq[DeletionVectorDescriptor] =
+      selectedDvDescriptors(scanHelper, tableRoot)
+
+    // Mirrors core's CometScanRule.isSchemaSupported so scan-time type gates (unsigned-small-int
+    // fallback, collation, shredded-variant-struct) apply identically here. Pure in-memory check,
+    // so it runs first, ahead of every I/O-bearing gate below.
+    // Unlike core, a required Variant root stays declined: this path lacks core's Variant gates.
+    val schemaFallbackReasons = new ListBuffer[String]()
+    val typeChecker = CometScanTypeChecker()
+    val requiredSchemaSupported =
+      typeChecker.isSchemaSupported(scanExec.requiredSchema, schemaFallbackReasons)
+    val partitionSchemaSupported =
+      typeChecker.isSchemaSupported(scanExec.relation.partitionSchema, schemaFallbackReasons)
+    if (!requiredSchemaSupported || !partitionSchemaSupported) {
+      return Some(
+        "Native Delta scan does not support the schema: " + schemaFallbackReasons.mkString(", "))
+    }
+
+    if (format.isCDCRead) {
+      return Some("Native Delta scan does not support Change Data Feed reads")
+    }
+
+    // Delta's DML machinery (findTouchedFiles) disables reader optimizations and needs real
+    // row indexes from Spark's reader; claiming here would feed NULL indexes into DV construction.
+    if (!format.optimizationsEnabled) {
+      return Some("Native Delta scan does not support reads with reader optimizations disabled")
+    }
+    if (scanExec.requiredSchema.exists(_.name == DeltaParquetFileFormat.ROW_INDEX_COLUMN_NAME) ||
+      scanExec.relation.dataSchema.exists(
+        _.name == DeltaParquetFileFormat.ROW_INDEX_COLUMN_NAME)) {
+      return Some("Native Delta scan does not support Delta's generated row-index column")
+    }
+
+    if (cmMode != "none" && cmMode != "name") {
+      return Some(s"Native Delta scan does not support column mapping mode $cmMode")
+    }
+    // createPhysicalSchema wholesale-replaces field metadata, silently dropping EXISTS_DEFAULT.
+    if (cmMode == "name" &&
+      getExistenceDefaultValues(scanExec.requiredSchema).exists(_ != null)) {
+      return Some(
+        "Native Delta scan does not support column defaults together with column mapping")
+    }
+    // createPhysicalSchema rewrites nested StructField names too, and the native builder emits the
+    // required schema verbatim as output, so name-sensitive expressions (e.g. to_json) would leak
+    // physical names. Decline until a rename adapter exists.
+    if (cmMode == "name" &&
+      scanExec.requiredSchema.exists(f => containsNestedStruct(f.dataType))) {
+      return Some("Native Delta scan does not support column mapping with nested struct fields")
+    }
+
+    val readerFeatures = protocol.readerFeatureNames
+    val unknownFeatures = readerFeatures -- understoodReaderFeatures
+    if (unknownFeatures.nonEmpty) {
+      return Some(
+        s"Native Delta scan does not support reader feature(s) ${unknownFeatures.mkString(", ")}")
+    }
+
+    // file_block_start and file_block_length describe the split reading a row. For a split file,
+    // DataFusion keeps a row group in the split holding its first page while Spark's reader
+    // keeps it in the split holding its midpoint, so rows would report the wrong split. Core
+    // declines the same two columns (https://github.com/apache/datafusion-comet/issues/6505).
+    // A deletion-vector read carries Delta's whole _metadata struct, so the two columns can sit
+    // in the scan output unused; only a value consumed above the scan declines.
+    val consumedSplitDependentCols = scanExec.fileConstantMetadataColumns
+      .filter(a => Set("file_block_start", "file_block_length").contains(a.name))
+      .filterNot(a => attributesUnusedAbove(plan, scanExec, Set(a.exprId)))
+    if (consumedSplitDependentCols.nonEmpty) {
+      return Some(
+        "Native Delta scan does not support metadata column(s) " +
+          consumedSplitDependentCols.map(_.name).mkString(", "))
+    }
+
+    // Non-constant metadata columns are generated per-row by Spark's reader and unsupported,
+    // except Delta's DV bookkeeping columns, which the native path emits as constants.
+    val knownColNames =
+      scanExec.relation.dataSchema.map(_.name).toSet ++
+        scanExec.relation.partitionSchema.map(_.name).toSet ++
+        scanExec.fileConstantMetadataColumns.map(_.name).toSet ++
+        CometDeltaNativeScan.internalColumnNames
+    val unknownOutput = scanExec.output.map(_.name).filterNot(knownColNames.contains)
+    if (unknownOutput.nonEmpty) {
+      return Some(
+        s"Native Delta scan does not support generated column(s) ${unknownOutput.mkString(", ")}")
+    }
+
+    // Deletion-vector shape invariants (see CometDeltaNativeScan.buildDvScanCommon).
+    if (CometDeltaNativeScan.isDvShape(scanExec)) {
+      // A row-index column WITHOUT is_row_deleted is Delta DML bookkeeping (real row indexes),
+      // not a DV read; claiming it with a constant would corrupt the DVs being written.
+      val hasIsRowDeleted =
+        scanExec.requiredSchema.exists(_.name == CometDeltaNativeScan.IsRowDeletedColumn)
+      val hasRowIndex =
+        scanExec.requiredSchema.exists(_.name == CometDeltaNativeScan.RowIndexColumn)
+      if (hasRowIndex && !hasIsRowDeleted) {
+        return Some(
+          "Native Delta scan does not support row-index reads outside a deletion-vector scan")
+      }
+      // Internal columns must form a suffix of the read schema so data-column positions agree
+      // between Spark's output and the stripped native schema.
+      val names = scanExec.requiredSchema.fields.map(_.name)
+      val firstInternal = names.indexWhere(CometDeltaNativeScan.internalColumnNames.contains)
+      if (!names.drop(firstInternal).forall(CometDeltaNativeScan.internalColumnNames.contains)) {
+        return Some("Native Delta scan requires DV bookkeeping columns to trail the read schema")
+      }
+      // Native applies the DV itself and emits a dead constant for row-index, so the real value
+      // must be provably unused above the scan.
+      if (!rowIndexUnusedAbove(plan, scanExec)) {
+        return Some(
+          "Native Delta scan cannot supply _metadata.row_index values consumed by the query")
+      }
+      // The DV common builder does not serialize existence defaults yet.
+      if (getExistenceDefaultValues(scanExec.requiredSchema).exists(_ != null)) {
+        return Some(
+          "Native Delta scan does not support column defaults together with deletion vectors")
+      }
+      // Bounds native's memory for expanded DV row selectors (delta_dv.rs), pessimistically
+      // bounded by 2*cardinality + #row-groups; the conf below makes an over-pessimistic decline
+      // recoverable.
+      val maxDeletedRowsPerFile = DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.get()
+      val oversizedCardinalities = dvDescriptors
+        .map(_.cardinality)
+        .filter(_ > maxDeletedRowsPerFile)
+      if (oversizedCardinalities.nonEmpty) {
+        return Some(
+          "Native Delta scan does not support a deletion vector deleting " +
+            s"${oversizedCardinalities.max} rows in a single file, exceeding " +
+            s"${DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.key}=$maxDeletedRowsPerFile")
+      }
+    }
+
+    // input_file_name & friends read from a thread-local Spark's FileScanRDD sets; the native scan
+    // does not populate it, and Delta's DML find-touched-files scans use it (mirrors core's check
+    // in CometScanRule.nativeScan).
+    if (plan.exists(node =>
+        node.expressions.exists(_.exists {
+          case _: InputFileName | _: InputFileBlockStart | _: InputFileBlockLength => true
+          case _ => false
+        }))) {
+      return Some(
+        "Native Delta scan is not compatible with input_file_name, " +
+          "input_file_block_start, or input_file_block_length")
+    }
+
+    // Row-index metadata columns are generated per-row by Spark's reader (mirrors core); the DV
+    // shape's trailing row-index column is exempt since the gates above already proved it dead.
+    if (!CometDeltaNativeScan.isDvShape(scanExec) &&
+      ShimFileFormat.findRowIndexColumnIndexInSchema(scanExec.requiredSchema) >= 0) {
+      return Some("Native Delta scan does not support row index generation")
+    }
+
+    // Mirror core's vectorized-reader compatibility gate.
+    if (!SQLConf.get.getConf(SQLConf.PARQUET_VECTORIZED_READER_ENABLED) &&
+      !CometConf.COMET_SCAN_ALLOW_DISABLED_PARQUET_VECTORIZED_READER.get()) {
+      return Some(
+        "Native Delta scan is incompatible with " +
+          s"${SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key}=false")
+    }
+
+    // Decline ALL encrypted-parquet configurations (stricter than core): the exec node does not
+    // yet wire the decryption-key broadcast to executors.
+    val hadoopConf = scanExec.relation.sparkSession.sessionState
+      .newHadoopConfWithOptions(scanExec.relation.options)
+    // Populated now (rather than only at the very end) so it is available even though several
+    // early-return gates below still lie ahead: cheap to set, and every one of those gates
+    // declines the scan anyway, so `memo` is simply never read by `convert` in that case.
+    memo.hadoopConf = hadoopConf
+    if (CometParquetUtils.encryptionEnabled(hadoopConf)) {
+      return Some("Native Delta scan does not support encrypted parquet")
+    }
+
+    // Nested-type column defaults cannot be serialized; a dropped default would misalign the
+    // value/index lists consumed positionally on the native side. Mirrors core's
+    // transformV1Scan gate.
+    val possibleDefaultValues = getExistenceDefaultValues(scanExec.requiredSchema)
+    if (possibleDefaultValues.exists(d =>
+        d != null && (d.isInstanceOf[ArrayBasedMapData] || d
+          .isInstanceOf[GenericInternalRow] || d.isInstanceOf[GenericArrayData]))) {
+      return Some("Native Delta scan does not support default values for nested types")
+    }
+
+    // An opted-in S3-compliant alias scheme (fs.comet.s3Compliant.schemes) is declined before the
+    // generic scheme gate below so the reason says why: core's native scan reads it through the
+    // S3 client, but the S3 divergence gates further down model Hadoop's S3AFileSystem only.
+    val rootUris = scanExec.relation.location.rootPaths.map(_.toUri)
+    val aliasReason = s3CompliantAliasSchemeReason(hadoopConf, rootUris)
+    if (aliasReason.isDefined) {
+      return aliasReason
+    }
+
+    // Only claim scans whose root paths object_store (or the configured libhdfs schemes) can
+    // actually read (mirrors core's unsupportedFsSchemes gate).
+    val libhdfs = libhdfsSchemes
+    val unsupportedRootSchemes = unsupportedSchemes(rootUris, libhdfs)
+    if (unsupportedRootSchemes.nonEmpty) {
+      return Some(
+        "Native Delta scan does not support filesystem scheme(s) " +
+          s"${unsupportedRootSchemes.mkString(", ")}")
+    }
+
+    // A recognized scheme can still carry a path object_store rejects (a directory name with a
+    // newline surfaces as `%0A`), which native planning hard-fails on while Spark's reader opens
+    // it. Mirrors core's root-path gate; the complete selected paths are probed below.
+    val rejectedRoot = objectStoreRejectedPathReason(rootUris, libhdfs)
+    if (rejectedRoot.isDefined) {
+      return rejectedRoot
+    }
+
+    // A shallow clone can span multiple object-store authorities, but the native builder resolves
+    // ObjectStoreUrl from only the FIRST selected file; force file listing and decline rather than
+    // risk reading a later file through the wrong handle.
+    val dataFileUris =
+      scanHelper.selectedPartitions.iterator.flatMap(_.files).map(_.getPath.toUri).toSeq
+
+    // Both gates below need the DV absolute-path URIs; dvDescriptors is already memoized.
+    val dvUris = dvDescriptors
+      .filter(_.storageType != DeletionVectorDescriptor.INLINE_DV_MARKER)
+      .map(_.absolutePath(new Path(tableRoot)).toUri)
+
+    // The root-path gate above only inspects the table root(s); selected files can resolve
+    // through a different scheme (e.g. `viewfs:`). Checked before the authority gates below,
+    // which presume every URI is natively resolvable.
+    val unsupportedSelected = unsupportedSelectedSchemeReason(dataFileUris ++ dvUris, libhdfs)
+    if (unsupportedSelected.isDefined) {
+      return unsupportedSelected
+    }
+
+    // Same path probe for every complete selected path, not just its directory: a shallow
+    // clone's source can sit outside this root, and CONVERT TO DELTA keeps the source Parquet
+    // basenames, so the rejected character can be in the file name itself. The probe is a
+    // native URL parse with no I/O, so once per distinct URI costs less than the scan's own
+    // per-file parse.
+    val rejectedSelected = objectStoreRejectedPathReason(dataFileUris ++ dvUris, libhdfs)
+    if (rejectedSelected.isDefined) {
+      return rejectedSelected
+    }
+
+    // Checked before multiStoreReason, which presumes every URI resolves to a single store
+    // identity -- a userinfo-bearing authority provably does not (store keying drops userinfo).
+    val userInfoReason = userInfoBearingAuthorityReason(dataFileUris ++ dvUris)
+    if (userInfoReason.isDefined) {
+      return userInfoReason
+    }
+
+    val multiStore = multiStoreReason(dataFileUris)
+    if (multiStore.isDefined) {
+      return multiStore
+    }
+
+    // GCS's zero-I/O, conf-only credential-forwarding gate; ordered alongside the S3 credential
+    // gates below since all presume a single, well-formed store identity per URI.
+    val gcsAuthReason = gcsHadoopOnlyAuthReason(hadoopConf, dataFileUris ++ dvUris)
+    if (gcsAuthReason.isDefined) {
+      return gcsAuthReason
+    }
+
+    // Zero-I/O, conf-only, like the GCS gate above: decline any bucket configured for an
+    // encryption algorithm outside the allowlist (SSE-C, CSE-KMS, CSE-CUSTOM, or unknown) before
+    // the credential-divergence gates below, which do not otherwise notice this table is readable
+    // through Hadoop only because Hadoop's request factory (SSE-C) or SDK-level decryption layer
+    // (CSE-*) does something native never learns about.
+    //
+    // Shared across this gate and the ones below: propagateBucketOptions is a full Configuration
+    // deep copy, and each gate would otherwise recompute it independently for the same bucket(s).
+    // One cache, populated lazily per bucket on first use, makes it a single copy per bucket.
+    val propagatedConfCache = MutableMap.empty[String, Configuration]
+    val encryptionReason = unsupportedEncryptionAlgorithmReason(
+      hadoopConf,
+      dataFileUris ++ dvUris,
+      propagatedConfCache)
+    if (encryptionReason.isDefined) {
+      return encryptionReason
+    }
+
+    // Always zero-I/O (plain propagated-conf read, no keystore): native's S3 client has no
+    // HTTP proxy support at all (no fs.s3a.proxy.* key is read anywhere in s3.rs), so a bucket
+    // requiring a proxy for S3 egress must decline here rather than claim and then connect
+    // directly, bypassing whatever network-segmentation/firewall policy required the proxy.
+    val proxyReason = proxyGateReason(hadoopConf, dataFileUris ++ dvUris, propagatedConfCache)
+    if (proxyReason.isDefined) {
+      return proxyReason
+    }
+
+    // Zero-I/O, conf-only, like the proxy gate above: Hadoop's AssumedRoleCredentialProvider
+    // sends fs.s3a.assumed.role.policy as the session policy of its STS AssumeRole request,
+    // while native's assumed-role provider never reads the key -- a claimed scan would assume
+    // the role WITHOUT the configured session restriction, silently widening permissions.
+    val rolePolicyReason =
+      assumedRolePolicyGateReason(hadoopConf, dataFileUris ++ dvUris, propagatedConfCache)
+    if (rolePolicyReason.isDefined) {
+      return rolePolicyReason
+    }
+
+    // Zero-I/O, conf-only: Hadoop prefixes a scheme-less fs.s3a.endpoint with http:// when
+    // SSL is disabled, while native always prefixes https://, so the two sides would talk to
+    // different endpoints. Same shape for the STS endpoint keys, which native never reads.
+    val endpointReason =
+      hadoopOnlyEndpointGateReason(hadoopConf, dataFileUris ++ dvUris, propagatedConfCache)
+    if (endpointReason.isDefined) {
+      return endpointReason
+    }
+
+    // Every fs.s3a.* option native's get_config (s3.rs) resolves must agree between what Hadoop
+    // itself would use and what native would read from the forwarded, substituted conf (covers
+    // long-form bucket credentials, JCEKS/credential-provider shadowing, and any other
+    // short-vs-effective divergence in one mechanism); reuses hadoopConf from the encryption gate
+    // above.
+    val s3Reason =
+      s3ConfigDivergenceReason(hadoopConf, dataFileUris ++ dvUris, propagatedConfCache)
+    if (s3Reason.isDefined) {
+      return s3Reason
+    }
+
+    // A credential-provider class native's build_aws_credential_provider_metadata (s3.rs) does
+    // not recognize errors at scan EXECUTION time, after the scan was already claimed; decline
+    // eagerly instead.
+    val providerReason = providerClassGateReason(hadoopConf, dataFileUris ++ dvUris)
+    if (providerReason.isDefined) {
+      return providerReason
+    }
+
+    // Reuse core's generic native-scan gates (ignoreCorruptFiles/ignoreMissingFiles, AQE DPP on
+    // Spark 3.4, exec enabled, existence default values, the Variant read confs, and a proto
+    // representation for every serialized data and partition type); tags its own fallback
+    // reasons.
+    if (!CometNativeScan.isSupported(scanExec)) {
+      return Some("Core native scan gates rejected the scan (see reasons above)")
+    }
+
+    // Claimable: hand the already-forced descriptors to `convert` via `memo` so it does not
+    // deserialize them a second time.
+    memo.dvDescriptors = dvDescriptors
+    None
+  }
+
+  /**
+   * Deletion-vector descriptors for every file this DV-shape scan selected, normalized to
+   * absolute on-disk paths. Returns `Seq.empty` for the plain shape. Shared by the DV cardinality
+   * gate and [[CometDeltaNativeScan.convert]]'s object-store option merge.
+   */
+  private[delta] def selectedDvDescriptors(
+      scanHelper: CometScanExec,
+      tableRoot: String): Seq[DeletionVectorDescriptor] = {
+    if (!CometDeltaNativeScan.isDvShape(scanHelper.wrapped)) {
+      return Seq.empty
+    }
+    val tableRootPath = new Path(tableRoot)
+    scanHelper.selectedPartitions.iterator
+      .flatMap(_.files)
+      .flatMap { file =>
+        file.metadata
+          .get(DeltaParquetFileFormat.FILE_ROW_INDEX_FILTER_ID_ENCODED)
+          .map(enc => DeletionVectorDescriptor.deserializeFromBase64(enc.asInstanceOf[String]))
+      }
+      .map(_.copyWithAbsolutePath(tableRootPath))
+      .toSeq
+  }
+
+  /**
+   * The libhdfs scheme exemption set from [[org.apache.comet.CometConf.COMET_LIBHDFS_SCHEMES]],
+   * parsed exactly like core's scan gate (`NativeConfig.parseSchemeSet`: split on commas,
+   * trimmed, lowercased) and defaulting to `Set("hdfs")` when unset.
+   */
+  private[delta] def libhdfsSchemes: Set[String] = COMET_LIBHDFS_SCHEMES.get() match {
+    case Some(s) => NativeConfig.parseSchemeSet(s)
+    case None => Set("hdfs")
+  }
+
+  /**
+   * Decline reason when any of `uris` uses a scheme opted in as an S3-compliant alias through
+   * `fs.comet.s3Compliant.schemes` (e.g. `blob`), or `None`. Core's native Parquet scan admits
+   * such a scheme and reads it through its S3 client, with `NativeConfig` translating the vendor
+   * `fs.<scheme>.<authority>.*` keys into `fs.s3a.bucket.*` options. Spark, however, reads the
+   * same table through the vendor's own Hadoop FileSystem, not `S3AFileSystem`, and every S3
+   * divergence gate in this object ([[s3ConfigDivergenceReason]] and its siblings) is verified
+   * against `S3AFileSystem`'s consumers only. With no model of how the vendor filesystem resolves
+   * its configuration, whether native and Spark would agree cannot be decided, so the scan is
+   * declined rather than claimed on a guess. Selected data-file and deletion-vector URIs under an
+   * alias scheme are declined by the generic scheme gates, which never admit an alias (see
+   * [[unsupportedSchemes]]).
+   */
+  private[delta] def s3CompliantAliasSchemeReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI]): Option[String] = {
+    val aliases = NativeConfig.resolveS3CompliantSchemes(hadoopConf)
+    if (aliases.isEmpty) {
+      return None
+    }
+    val found = uris
+      .flatMap(uri => Option(uri.getScheme).map(_.toLowerCase(Locale.ROOT)))
+      .filter(aliases.contains)
+      .distinct
+    if (found.isEmpty) {
+      None
+    } else {
+      Some(
+        "Native Delta scan does not support S3-compliant alias filesystem scheme(s) " +
+          s"${found.sorted.mkString(", ")} (${CometConf.COMET_S3_COMPLIANT_SCHEMES_KEY}): " +
+          "Spark reads them through a vendor filesystem whose S3 configuration resolution the " +
+          "native scan's S3AFileSystem divergence model cannot verify")
+    }
+  }
+
+  /**
+   * The lowercased, deduplicated schemes among `uris` that neither `libhdfs` nor Comet's native
+   * object_store layer ([[CometScanRule.isNativelyReadableScheme]]) can read. A `null` scheme is
+   * tolerated, not flagged, since such a URI cannot come from a Hadoop-backed source. The alias
+   * set handed to core's gate is deliberately empty: an `fs.comet.s3Compliant.schemes` alias is
+   * never admitted here (see [[s3CompliantAliasSchemeReason]]), even though core admits it.
+   */
+  private[delta] def unsupportedSchemes(uris: Seq[URI], libhdfs: Set[String]): Set[String] = {
+    uris
+      .filter { uri =>
+        val sch = uri.getScheme
+        sch != null && {
+          val sl = sch.toLowerCase(Locale.ROOT)
+          !libhdfs.contains(sl) && !CometScanRule.isNativelyReadableScheme(uri, Set.empty)
+        }
+      }
+      .map(_.getScheme.toLowerCase(Locale.ROOT))
+      .toSet
+  }
+
+  /**
+   * Decline reason naming the first of `uris` whose path object_store rejects even though it
+   * recognizes the scheme ([[CometScanRule.objectStoreAcceptsPath]], e.g. a directory name
+   * containing a newline, `%0A` in the URI), or `None`. Schemes in `libhdfs` never reach
+   * object_store's path parser and are skipped, as is a `null` scheme (see
+   * [[unsupportedSchemes]]); an S3-compliant alias is declined before this gate runs. The probe
+   * is uncached but is a plain native URL parse with no I/O
+   * ([[CometScanRule.objectStoreAcceptsPath]]), so callers pass every complete selected path
+   * (root paths, data files and deletion vectors) once per distinct URI; a converted table can
+   * carry the rejected character in a file basename. The reason masks any userinfo in the named
+   * URI ([[redactedAuthority]]).
+   */
+  private[delta] def objectStoreRejectedPathReason(
+      uris: Seq[URI],
+      libhdfs: Set[String]): Option[String] = {
+    uris.distinct
+      .find { uri =>
+        val sch = uri.getScheme
+        sch != null && !libhdfs.contains(sch.toLowerCase(Locale.ROOT)) &&
+        !CometScanRule.objectStoreAcceptsPath(uri)
+      }
+      .map { uri =>
+        // Mask userinfo (see redactedAuthority); the raw path keeps its percent encoding so the
+        // reason shows the rejected sequence as written.
+        val shown =
+          if (uriUserInfo(uri).isEmpty) uri.toString
+          else s"${redactedAuthority(uri)}${Option(uri.getRawPath).getOrElse("")}"
+        s"Native Delta scan cannot open path '$shown': object_store rejects it " +
+          "(e.g. an unsupported character in the path)"
+      }
+  }
+
+  /**
+   * Decline reason when any of `uris` -- the scan's selected data-file and deletion-vector URIs
+   * -- use a scheme [[unsupportedSchemes]] flags, or `None` when every URI is natively readable
+   * (or libhdfs-exempt).
+   */
+  private[delta] def unsupportedSelectedSchemeReason(
+      uris: Seq[URI],
+      libhdfs: Set[String]): Option[String] = {
+    val schemes = unsupportedSchemes(uris, libhdfs)
+    if (schemes.isEmpty) {
+      None
+    } else {
+      Some(
+        "Native Delta scan does not support selected data file or deletion vector filesystem " +
+          s"scheme(s) ${schemes.mkString(", ")}")
+    }
+  }
+
+  /**
+   * Decline reason when `uris` span more than one object-store authority (scheme + lowercased raw
+   * authority, so e.g. `S3A://Bucket` and `s3a://bucket` collapse), or `None` when they share
+   * one. `file://` paths carry no authority, so local scans across many directories are
+   * unaffected.
+   */
+  private[delta] def multiStoreReason(uris: Seq[URI]): Option[String] = {
+    val authorities = uris.map(uriAuthority).distinct
+    if (authorities.size > 1) {
+      Some(
+        "Native Delta scan does not support data files spanning multiple object stores " +
+          s"(found: ${authorities.sorted.mkString(", ")})")
+    } else {
+      None
+    }
+  }
+
+  /**
+   * Normalizes `uri` to a lowercased `scheme://authority` string, keyed on the raw `getAuthority`
+   * rather than the parsed host/port/userinfo fields: `getHost` (and `getUserInfo`/`getPort`)
+   * return `null` for the whole authority when it fails RFC 3986 `reg-name` syntax (e.g. an
+   * underscore in a GCS bucket name, `gs://my_bucket`), which would silently collapse distinct
+   * buckets into one empty-host key. A `null` authority normalizes to the empty string.
+   */
+  private[delta] def uriAuthority(uri: URI): String = {
+    val scheme = Option(uri.getScheme).map(_.toLowerCase(Locale.ROOT)).getOrElse("")
+    val authority = Option(uri.getAuthority).map(_.toLowerCase(Locale.ROOT)).getOrElse("")
+    s"$scheme://$authority"
+  }
+
+  /**
+   * The raw userinfo component of `uri`'s authority, or empty when none. Splits at the LAST `@`
+   * rather than using `URI#getUserInfo`, which (like [[uriAuthority]]'s getters) returns `null`
+   * for the whole authority on an RFC 3986 `reg-name` violation. Never lowercased: userinfo is
+   * case-sensitive.
+   */
+  private[delta] def uriUserInfo(uri: URI): String = {
+    val authority = Option(uri.getAuthority).getOrElse("")
+    val at = authority.lastIndexOf('@')
+    if (at >= 0) authority.substring(0, at) else ""
+  }
+
+  /**
+   * Redacts `uri`'s authority to `scheme`, then `://`, then a literal `***` masking userinfo,
+   * then `@host[:port]`, for embedding in a decline reason. NEVER interpolate `uri.getAuthority`
+   * or [[uriUserInfo]] directly into a reason string: doing so would leak credentials embedded as
+   * URI userinfo into the SQL plan's explain output, fallback-reason logging, or the Spark UI.
+   */
+  private[delta] def redactedAuthority(uri: URI): String = {
+    val scheme = Option(uri.getScheme).map(_.toLowerCase(Locale.ROOT)).getOrElse("")
+    val authority = Option(uri.getAuthority).getOrElse("")
+    val at = authority.lastIndexOf('@')
+    val hostPort = if (at >= 0) authority.substring(at + 1) else authority
+    s"$scheme://***@$hostPort"
+  }
+
+  /**
+   * Decline reason when any of `uris` carries userinfo in its authority (e.g. the container in an
+   * abfss:// path), or `None` when none do. The native store cache, `ObjectStoreUrl`, and
+   * DataFusion registry all key on scheme/host/port only, dropping userinfo, so two authorities
+   * differing only in userinfo collide onto the same store handle.
+   */
+  private[delta] def userInfoBearingAuthorityReason(uris: Seq[URI]): Option[String] = {
+    val offending = uris.filter(uri => uriUserInfo(uri).nonEmpty).map(redactedAuthority).distinct
+    if (offending.isEmpty) {
+      None
+    } else {
+      Some("Native Delta scan does not support object-store paths whose authority carries " +
+        "userinfo (e.g. the container in an abfss:// path): the native object-store cache, " +
+        "ObjectStoreUrl and DataFusion registry all key on scheme, host and port only, so two " +
+        "containers on one storage account share a single store handle " +
+        s"(found: ${offending.sorted.mkString(", ")})")
+    }
+  }
+
+  /**
+   * String-literal Hadoop conf keys consulted below. `hadoop-aws` is NOT on this module's runtime
+   * classpath, so `org.apache.hadoop.fs.s3a.Constants` must never be referenced here (would raise
+   * `NoClassDefFoundError` for sessions with no S3 dependency).
+   */
+  private val HadoopCredentialProviderPathKey = "hadoop.security.credential.provider.path"
+  private val S3aCredentialProviderPathKey = "fs.s3a.security.credential.provider.path"
+
+  /**
+   * `CommonConfigurationKeysPublic.HADOOP_SECURITY_CREDENTIAL_CLEAR_TEXT_FALLBACK`, default
+   * `true`, verified via `javap` against `hadoop-common` 3.3.4's
+   * `Configuration#getPasswordFromConfig`: `getPassword` only falls back to reading a plaintext
+   * conf value once `getBoolean(<this key>, true)` holds -- with the flag off, a plaintext value
+   * is invisible to every `getPassword`-based resolver, even when no credential provider is
+   * configured at all.
+   */
+  private val ClearTextFallbackKey = "hadoop.security.credential.clear-text-fallback"
+
+  private def s3aBucketProviderPathKey(bucket: String): String =
+    s"fs.s3a.bucket.$bucket.security.credential.provider.path"
+
+  /**
+   * The LONG form of [[s3aBucketProviderPathKey]]: `S3AUtils#lookupPassword` resolves per-bucket
+   * overrides through both a long key (`fs.s3a.bucket.B.<full base key>`) and a short key; both
+   * must be covered here too.
+   */
+  private def s3aBucketLongProviderPathKey(bucket: String): String =
+    s"fs.s3a.bucket.$bucket.fs.s3a.security.credential.provider.path"
+
+  private def nonEmptyConf(hadoopConf: Configuration, key: String): Boolean =
+    Option(hadoopConf.get(key)).exists(_.nonEmpty)
+
+  /**
+   * The lowercase-scheme-checked S3/S3A bucket name from `uri`'s authority, or `None` when
+   * `uri`'s scheme is not `s3`/`s3a`. Parses the raw authority manually rather than
+   * `URI#getHost`, avoiding the same RFC 3986 `reg-name` pitfall as [[uriAuthority]].
+   */
+  private def s3Bucket(uri: URI): Option[String] = {
+    val scheme = Option(uri.getScheme).map(_.toLowerCase(Locale.ROOT))
+    if (scheme.contains("s3") || scheme.contains("s3a")) {
+      val authority = Option(uri.getAuthority).getOrElse("")
+      val at = authority.lastIndexOf('@')
+      val hostAndPort = if (at >= 0) authority.substring(at + 1) else authority
+      val colon = hostAndPort.lastIndexOf(':')
+      val host = if (colon >= 0) hostAndPort.substring(0, colon) else hostAndPort
+      if (host.isEmpty) None else Some(host)
+    } else {
+      None
+    }
+  }
+
+  private def plainValue(hadoopConf: Configuration, key: String): Option[String] =
+    Option(hadoopConf.get(key)).filter(_.nonEmpty)
+
+  /**
+   * How Hadoop's OWN consumer reads one of the keys compared by [[s3ConfigDivergenceReason]],
+   * which decides how [[s3KeyDivergenceReason]] computes the Hadoop-effective side of its
+   * equality check. Exactly two consumer families exist among [[AllS3ConfigKeys]] in `hadoop-aws`
+   * 3.3.4, each verified via `javap`/CFR against the real call sites (cited per key on
+   * [[S3ConfigKeyConsumers]]). The tier must mirror the key's ACTUAL consumer: resolving a
+   * [[PropagatedOptionConsumer]] key through the wider `lookupPassword` cascade is NOT fail-safe
+   * for a value-EQUALITY comparator -- a long-form alias value Hadoop itself never reads can
+   * EQUAL native's resolution while Hadoop's true propagate-then-plain-get value differs, turning
+   * a real divergence into a wrongly-claimed scan (the endpoint `${...}`-redirect shape pinned in
+   * `DeltaScanContribSuite`).
+   */
+  private[delta] sealed trait S3ConfigConsumer
+
+  /**
+   * Read via `S3AUtils#lookupPassword(bucket, conf, baseKey)`, verified via `javap` against
+   * `hadoop-aws` 3.3.4: builds `longBucketKey = "fs.s3a.bucket." + bucket + "." + baseKey` (the
+   * FULL, already-`fs.s3a`-prefixed base key appended after the bucket segment) and reads it via
+   * `Configuration#getPassword` BEFORE the short-bucket key, keeping the long value whenever
+   * `getPassword` returns non-empty and only falling through to short-then-global otherwise.
+   * `getPassword` is Hadoop-credential-provider-aware and skips plaintext conf entirely when
+   * [[ClearTextFallbackKey]] is false. Modeled by [[hadoopLookupPasswordEffective]].
+   */
+  private[delta] case object LookupPasswordConsumer extends S3ConfigConsumer
+
+  /**
+   * Read via `S3AUtils#propagateBucketOptions` followed by a plain `Configuration#get`-family
+   * call (`getTrimmed`/`getBoolean`/`getClasses`) against the propagated view: the short bucket
+   * form wins only by having overwritten the global key during propagation, the long bucket form
+   * folds into an unread `fs.s3a.fs.s3a.*` key, and neither a credential provider nor
+   * [[ClearTextFallbackKey]] is ever consulted. Modeled as a plain `Configuration#get` on the
+   * [[propagateBucketOptions]] result, which also expands `${...}` references under that
+   * propagated view exactly like the real consumer.
+   */
+  private[delta] case object PropagatedOptionConsumer extends S3ConfigConsumer
+
+  /**
+   * Every `fs.s3a.*` base key that governs whether a claimed native scan actually behaves like
+   * Hadoop's own reader would, paired with the consumer family Hadoop resolves it through -- ONE
+   * list, with each key's resolution tier declared beside it, so a key can never sit in the
+   * comparator without a deliberate classification (adding one without picking a tier does not
+   * compile). The entries are every per-bucket `fs.s3a.*` base key native's S3 client's
+   * `get_config` (s3.rs) resolves, verified directly against its call sites:
+   * `extract_s3_config_options` (endpoint.region, path.style.access, endpoint,
+   * requester.pays.enabled), `lookup_provider_class` (the Comet-specific
+   * credential-provider-class activation key), and
+   * `build_credential_provider`/`build_aws_credential_provider_metadata`/
+   * `build_assume_role_credential_provider_metadata` (aws.credentials.provider,
+   * assumed.role.credentials.provider, assumed.role.arn, assumed.role.session.name).
+   *
+   * Tier assignments, each verified via `javap`/CFR against `hadoop-aws` 3.3.4:
+   *   - access.key/secret.key/session.token: `S3AUtils#getAWSAccessKeys` and
+   *     `MarshalledCredentialBinding#fromFileSystem` (reached from
+   *     `TemporaryAWSCredentialsProvider`) resolve all three via `S3AUtils#lookupPassword` --
+   *     [[LookupPasswordConsumer]].
+   *   - aws.credentials.provider and assumed.role.credentials.provider:
+   *     `S3AUtils#buildAWSProviderList` -> `loadAWSProviderClasses` -> plain
+   *     `Configuration#getClasses` -- [[PropagatedOptionConsumer]].
+   *   - assumed.role.arn/session.name: `AssumedRoleCredentialProvider`'s constructor reads both
+   *     via plain `Configuration#getTrimmed` -- [[PropagatedOptionConsumer]].
+   *   - endpoint (`S3AFileSystem`: `getTrimmed`), endpoint.region (`DefaultS3ClientFactory`:
+   *     `getTrimmed`), path.style.access (`S3AFileSystem`: `getBoolean`) --
+   *     [[PropagatedOptionConsumer]].
+   *   - requester.pays.enabled: not read anywhere in `hadoop-aws` 3.3.4 (the constant does not
+   *     even exist in its `Constants` class); later releases read it via plain `getBoolean`
+   *     against the propagated conf, so the plain tier is both the faithful forward model and
+   *     inert on 3.3.4 -- [[PropagatedOptionConsumer]].
+   *   - comet.credential.provider.class: Comet's own activation key, plain conf read on both
+   *     sides, never a Hadoop key at all -- [[PropagatedOptionConsumer]].
+   *
+   * SYNC NOTE: the key list must stay a superset of native's `NATIVE_S3A_CONFIG_PROPERTIES`
+   * constant (`native/core/src/parquet/objectstore/s3.rs`, property suffixes without the
+   * `fs.s3a.` prefix) -- `DeltaScanContribSuite`'s discovery-harness test asserts this
+   * mechanically against [[AllS3ConfigKeys]]. A Rust test in `s3.rs` also parses this `Seq(`
+   * block as text, so each entry must stay a single `"fs.s3a.<key>" -> <Tier>` literal pair.
+   * Literal strings, not the [[AwsCredentialsProviderKey]] /
+   * [[AssumedRoleCredentialsProviderKey]] vals declared below, purely to avoid a forward
+   * reference inside this `object` body; kept textually identical to those two constants.
+   */
+  private[delta] val S3ConfigKeyConsumers: Seq[(String, S3ConfigConsumer)] = Seq(
+    "fs.s3a.access.key" -> LookupPasswordConsumer,
+    "fs.s3a.secret.key" -> LookupPasswordConsumer,
+    "fs.s3a.session.token" -> LookupPasswordConsumer,
+    "fs.s3a.aws.credentials.provider" -> PropagatedOptionConsumer,
+    "fs.s3a.assumed.role.arn" -> PropagatedOptionConsumer,
+    "fs.s3a.assumed.role.session.name" -> PropagatedOptionConsumer,
+    "fs.s3a.assumed.role.credentials.provider" -> PropagatedOptionConsumer,
+    "fs.s3a.endpoint" -> PropagatedOptionConsumer,
+    "fs.s3a.endpoint.region" -> PropagatedOptionConsumer,
+    "fs.s3a.path.style.access" -> PropagatedOptionConsumer,
+    "fs.s3a.requester.pays.enabled" -> PropagatedOptionConsumer,
+    "fs.s3a.comet.credential.provider.class" -> PropagatedOptionConsumer)
+
+  /** The compared keys alone, in [[S3ConfigKeyConsumers]] order (discovery-harness surface). */
+  private[delta] val AllS3ConfigKeys: Seq[String] = S3ConfigKeyConsumers.map(_._1)
+
+  /**
+   * The short-bucket-then-global value resolved for `baseKey` under `bucket` from `hadoopConf`,
+   * skipping an empty value at either alias exactly like [[plainValue]]. NOT used by
+   * [[s3ConfigDivergenceReason]]/[[s3KeyDivergenceReason]] any more -- every key checked there
+   * resolves per its declared [[S3ConfigKeyConsumers]] tier (see [[s3KeyDivergenceReason]]),
+   * neither of which matches this function's read. This function's one remaining caller is
+   * [[shortThenGlobalOrReason]], which reads provider-CLASS strings (from the ORIGINAL,
+   * unpropagated conf) for name-support validation in [[providerClassReason]]/
+   * [[assumedRoleProviderClassReason]] -- by the time those run, [[s3ConfigDivergenceReason]] has
+   * already proven Hadoop's and native's effective values agree for the same key, so whichever of
+   * the two (equal) values this narrower read returns does not affect correctness there. NEVER
+   * used to compute native's own effective value -- see [[nativeShortThenGlobal]] for that.
+   */
+  private def shortThenGlobal(
+      hadoopConf: Configuration,
+      bucket: String,
+      baseKey: String): Option[String] = {
+    val shortKey = s"fs.s3a.bucket.$bucket." + baseKey.stripPrefix("fs.s3a.")
+    plainValue(hadoopConf, shortKey).orElse(plainValue(hadoopConf, baseKey))
+  }
+
+  /**
+   * The short-bucket-then-global value native's `get_config` (s3.rs) resolves for `baseKey` under
+   * `bucket` from the ORIGINAL, unpropagated `hadoopConf` -- `NativeConfig
+   * .extractObjectStoreOptions` forwards `Configuration#get`'s substituted value for every
+   * `fs.s3a.*` entry with no bucket-option propagation step of its own, so the original conf is
+   * the right input here. Unlike [[shortThenGlobal]]/[[plainValue]], this mirrors `get_config`
+   * faithfully: PRESENCE of the short-bucket key alone -- never its emptiness -- decides whether
+   * native falls back to the global key (`get_config` is a plain `HashMap::get`, which returns
+   * `Some` for a key explicitly set to `""`), so an explicitly empty or whitespace-only
+   * short-bucket value resolves to `Some("")` here and never falls through to global -- the
+   * OPPOSITE of Hadoop's own `getPassword`/`lookupPassword` semantics (see
+   * [[hadoopLookupPasswordEffective]]), which treat empty as absent and keep trying the next
+   * alias. The ONLY function used to compute native's effective value in
+   * [[s3KeyDivergenceReason]].
+   *
+   * Deliberately does NOT apply `get_config_trimmed`'s `.trim()` here: [[s3KeyDivergenceReason]]
+   * trims both this value and Hadoop's effective value together, symmetrically, at the point they
+   * are compared, rather than one-sidedly here -- trimming only the native side would flag a
+   * spurious divergence for a value neither side's whitespace actually changes the behavior of
+   * once each side's own downstream parsing normalizes it (e.g. Hadoop's own multi-line
+   * `fs.s3a.aws.credentials.provider` default, which both Hadoop and native additionally trim per
+   * comma-separated entry after splitting), while a one-sided trim would make an
+   * otherwise-identical default value look diverged for every bucket, never claiming natively at
+   * all.
+   */
+  private def nativeShortThenGlobal(
+      hadoopConf: Configuration,
+      bucket: String,
+      baseKey: String): Option[String] = {
+    val shortKey = s"fs.s3a.bucket.$bucket." + baseKey.stripPrefix("fs.s3a.")
+    Option(hadoopConf.get(shortKey)).orElse(Option(hadoopConf.get(baseKey)))
+  }
+
+  /**
+   * Faithful in-memory replica of `S3AUtils#propagateBucketOptions` (`hadoop-aws`), which
+   * `S3AFileSystem#initialize` calls FIRST, before any option or credential is read:
+   * `Configuration conf = propagateBucketOptions(originalConf, bucket); ...; setConf(conf);` --
+   * every subsequent `conf.get`/`getPassword` call in that filesystem instance, including
+   * `${...}` variable substitution, resolves against this propagated view, not the original conf.
+   * `hadoop-aws` is not on this module's runtime classpath (see the string-literal-keys note
+   * above), so `S3AUtils#propagateBucketOptions` cannot be called directly; this reproduces its
+   * logic verbatim using only `hadoop-common`'s `Configuration`:
+   * {{{
+   * public static Configuration propagateBucketOptions(Configuration source, String bucket) {
+   *   final String bucketPrefix = FS_S3A_BUCKET_PREFIX + bucket + '.';
+   *   final Configuration dest = new Configuration(source);
+   *   for (Map.Entry<String, String> entry : source) {
+   *     final String key = entry.getKey();
+   *     final String value = entry.getValue(); // the (unexpanded) value
+   *     if (!key.startsWith(bucketPrefix) || bucketPrefix.equals(key)) continue;
+   *     final String stripped = key.substring(bucketPrefix.length());
+   *     if (stripped.startsWith("bucket.") || "impl".equals(stripped)) {
+   *       // ignored
+   *     } else {
+   *       final String generic = FS_S3A_PREFIX + stripped;
+   *       dest.set(generic, value, ...); // overwrites any existing global value
+   *     }
+   *   }
+   *   return dest;
+   * }
+   * }}}
+   * Note the LONG bucket form (`fs.s3a.bucket.B.fs.s3a.<key>`) folds to an unread
+   * `fs.s3a.fs.s3a.<key>` key here too, exactly like the real method -- `stripped` already starts
+   * with `fs.s3a.` in that case, so prepending `fs.s3a.` again produces a key nothing ever reads.
+   */
+  private def propagateBucketOptions(hadoopConf: Configuration, bucket: String): Configuration = {
+    val bucketPrefix = s"fs.s3a.bucket.$bucket."
+    val dest = new Configuration(hadoopConf)
+    hadoopConf.iterator().asScala.foreach { entry =>
+      val key = entry.getKey
+      if (key.startsWith(bucketPrefix) && key != bucketPrefix) {
+        val stripped = key.substring(bucketPrefix.length)
+        if (!stripped.startsWith("bucket.") && stripped != "impl") {
+          dest.set(s"fs.s3a.$stripped", entry.getValue)
+        }
+      }
+    }
+    dest
+  }
+
+  /**
+   * Canonical and deprecated Hadoop S3A encryption-algorithm config keys, verified via `javap`
+   * against `hadoop-aws` 3.3.4's `org.apache.hadoop.fs.s3a.Constants`: `S3_ENCRYPTION_ALGORITHM =
+   * "fs.s3a.encryption.algorithm"` (canonical) and `SERVER_SIDE_ENCRYPTION_ALGORITHM =
+   * "fs.s3a.server-side-encryption-algorithm"` (DEPRECATED -- note the hyphen before "algorithm",
+   * unlike the corresponding `*.key` constants below, which both use a `.key` suffix).
+   * `hadoop-aws` is NOT on this module's runtime classpath, so these stay string literals, same
+   * rationale as [[HadoopCredentialProviderPathKey]].
+   */
+  private val S3EncryptionAlgorithmKey = "fs.s3a.encryption.algorithm"
+  private val DeprecatedS3EncryptionAlgorithmKey = "fs.s3a.server-side-encryption-algorithm"
+
+  /**
+   * The exact strings `S3AEncryptionMethods#getMethod` accepts, verified via `javap`/CFR against
+   * `hadoop-aws` 3.3.4's `S3AEncryptionMethods` enum: `NONE("")`, `SSE_S3("AES256", serverSide =
+   * true, requiresSecret = false)`, `SSE_KMS("SSE-KMS", serverSide = true, requiresSecret =
+   * false)`, `SSE_C("SSE-C", serverSide = true, requiresSecret = true)`, `CSE_KMS("CSE-KMS",
+   * serverSide = false, requiresSecret = true)`, `CSE_CUSTOM("CSE-CUSTOM", serverSide = false,
+   * requiresSecret = true)`. `getMethod` parses case-insensitively
+   * (`values().find(_.getMethod.equalsIgnoreCase(algorithm))`), matched below the same way.
+   *
+   * ALLOWLIST, not a blocklist (replaces the former SSE-C-only blocklist): only the algorithms S3
+   * decrypts transparently on GET/HEAD given read permission alone, with NO extra request header
+   * and NO client-side step, are safe for a native scan that forwards none of Hadoop's
+   * `fs.s3a.encryption.*`/`fs.s3a.server-side-encryption*` options --
+   *   - `AES256` (SSE_S3, `serverSide = true`): plain server-side encryption, transparent on GET.
+   *   - `SSE-KMS` (SSE_KMS, `serverSide = true`): server-side, KMS-managed key, transparent on
+   *     GET given KMS decrypt permission (no header).
+   *   - `DSSE-KMS`: NOT present in this enum on `hadoop-aws` 3.3.4 (confirmed by the six values
+   *     listed above) -- `S3AEncryptionMethods.getMethod("DSSE-KMS")` throws
+   *     `IOException("Unknown encryption algorithm DSSE-KMS")` on this version, so
+   *     `S3AUtils#buildEncryptionSecrets` (and therefore Hadoop's own reader) already fails
+   *     before ever reading such a table under 3.3.4, meaning this string can never actually be
+   *     the resolved value on the declared target version -- admitting it here is inert there.
+   *     Included anyway, forward-compatible, for a newer `hadoop-aws` on the runtime classpath (a
+   *     later Hadoop release; this module has no compile-time `hadoop-aws` dependency, see the
+   *     string-literal-keys note above) where DSSE-KMS is a real, dual-layer, server-side
+   *     algorithm decrypted transparently on GET the same way SSE-KMS is. Every other value
+   *     declines: `SSE-C` (SSE_C is `serverSide = true` in Hadoop's own enum, but `requiresSecret
+   *     \= true` -- S3 rejects a GET/HEAD for an SSE-C object outright (400 Bad Request) unless
+   *     the customer key is resent as a request header on every call, so a native scan that never
+   *     learns the key cannot succeed at all, where Hadoop's own reader -- whose request factory
+   *     attaches the key -- would), `CSE-KMS`/`CSE-CUSTOM` (`serverSide = false`: client-side
+   *     encryption decrypts object bytes locally in the SDK layer, which the native Parquet
+   *     reader has no equivalent of -- it would read raw ciphertext), and any future/unknown
+   *     value (a value `S3AEncryptionMethods.getMethod` itself would reject is certainly not one
+   *     of the three confirmed-transparent algorithms above; declining is the only safe default
+   *     for anything this gate cannot positively confirm).
+   */
+  private val AllowedEncryptionAlgorithms: Set[String] = Set("AES256", "SSE-KMS", "DSSE-KMS")
+
+  /**
+   * `bucket`'s effective encryption-algorithm key and value under `hadoopConf`, or `None` when
+   * neither the canonical nor deprecated key is set anywhere consulted. Mirrors
+   * `S3AUtils#buildEncryptionSecrets`'s real resolution order, verified via `javap`/CFR
+   * decompilation of `hadoop-aws` 3.3.4's `S3AUtils.class`:
+   * {{{
+   * String algorithm = lookupBucketSecret(bucket, conf, "fs.s3a.encryption.algorithm");
+   * if (algorithm == null)
+   *   algorithm = lookupBucketSecret(bucket, conf, "fs.s3a.server-side-encryption-algorithm");
+   * if (algorithm == null)
+   *   algorithm = lookupPassword(null, conf, "fs.s3a.encryption.algorithm");
+   * if (algorithm == null)
+   *   algorithm = lookupPassword(null, conf, "fs.s3a.server-side-encryption-algorithm");
+   * }}}
+   * i.e. bucket-tier (canonical, then deprecated), THEN global-tier (canonical, then deprecated)
+   * -- the two tiers are never interleaved key-by-key, so this must stay two explicit bucket-tier
+   * lookups followed by two explicit global-tier lookups, not a single
+   * [[hadoopLookupPasswordEffective]] call per key (which would let an unset canonical bucket key
+   * fall through straight to the canonical GLOBAL value ahead of a SET deprecated bucket key, the
+   * wrong answer).
+   *
+   * The three-argument `lookupPassword` defaults to `""`, not `null`, so the last call in the
+   * block above never runs: Hadoop reads the deprecated global key only through `Configuration`'s
+   * deprecation alias of the canonical one. This function still reads it as a fourth lookup,
+   * which can only add a decline.
+   *
+   * THE FIX for the SSE-C long-bucket-alias gap is entirely inside the bucket tier:
+   * `lookupBucketSecret` itself is long-then-short, decompiled from `hadoop-aws` 3.3.4's
+   * `S3AUtils.class`:
+   * {{{
+   * // longBucketKey  = fs.s3a.bucket.B.fs.s3a.<key>
+   * String longBucketKey = String.format(BUCKET_PATTERN, bucket, baseKey);
+   * String initialVal = getPassword(conf, longBucketKey, null, null);
+   * // shortBucketKey = fs.s3a.bucket.B.<key>
+   * String shortBucketKey = String.format(BUCKET_PATTERN, bucket, subkey);
+   * // keeps initialVal (the LONG value) if non-empty
+   * return getPassword(conf, shortBucketKey, initialVal, null);
+   * }}}
+   * i.e. the SAME long-bucket-key construction and long-wins-if-nonempty semantics as
+   * `S3AUtils#lookupPassword` (see [[LookupPasswordConsumer]]/[[hadoopLookupPasswordEffective]]).
+   * `buildEncryptionSecrets` runs on the [[propagateBucketOptions]] view, so
+   * [[unsupportedEncryptionAlgorithmReason]] calls this on that view (and on the raw conf, which
+   * can only add a decline). An earlier version of this function modeled the bucket tier as
+   * SHORT-only, documented as "the LONG bucket form is genuinely never consulted for this key" --
+   * that documentation was wrong (this decompilation supersedes it): a bucket configured only via
+   * `fs.s3a.bucket.B.fs.s3a.encryption.algorithm=SSE-C` bypassed the SSE-C gate entirely, because
+   * Hadoop's own reader DOES read that long form (and picks SSE-C), while this function reported
+   * `None` (nothing set) and the allowlist check below never even ran.
+   *
+   * The canonical-vs-deprecated distinction below is frequently moot in practice: `hadoop-aws`'s
+   * `S3AFileSystem.addDeprecatedKeys()` statically registers `fs.s3a.server-side-encryption-*` as
+   * `Configuration`-level deprecated aliases of `fs.s3a.encryption.*` (verified via `javap`), a
+   * registration that lives in a static field on Hadoop's `Configuration` class -- process-wide
+   * once `S3AFileSystem`'s class has loaded anywhere in the JVM, which a real scan has always
+   * already done by the time this gate runs, since reading the S3 table at all requires loading
+   * that class. Once active, `Configuration#get` resolves either literal key to the identical
+   * value transparently, making the two-key cascade below redundant (but harmless) for that case;
+   * it remains the operative path only when nothing else in the process has loaded
+   * `S3AFileSystem` yet.
+   *
+   * ALSO walks the Hadoop-credential-provider (JCEKS) path via [[resolveViaCredentialAliases]]
+   * for each of the four lookups below, matching `lookupBucketSecret`/`lookupPassword`'s real
+   * per-alias `getPassword` calls (quoted above) exactly: both are `getPassword`, not plain
+   * `Configuration#get`, so a bucket storing the algorithm name ONLY in a JCEKS keystore is
+   * exactly as real a Hadoop deployment shape for this key as it is for the credential keys
+   * [[hadoopLookupPasswordEffective]] already covers -- there is nothing algorithm-specific that
+   * makes JCEKS storage implausible here, so an earlier version of this function skipping it
+   * (documented at the time as "the algorithm NAME is not credential-sensitive data, so storing
+   * it in a keystore is not a realistic Hadoop deployment pattern") was an unjustified, narrower
+   * read than Hadoop's own resolver actually performs, under-declining a bucket whose algorithm
+   * is keystore-only. [[resolveViaCredentialAliases]]'s Arm B/C split still means this is zero
+   * extra I/O for the common case: keystore I/O only happens when a Hadoop credential-provider
+   * path is actually configured for the bucket, contained in that function's own try/catch.
+   * `bucketTier`/`globalTier` return `Left` (propagated straight through by [[orElseTier]]) when
+   * [[resolveViaCredentialAliases]] cannot safely verify a tier at all (an S3A-scoped provider
+   * path, or a corrupt/unreadable global keystore) -- correctly short-circuiting the whole
+   * cascade with a decline rather than silently falling through to a later tier that might look
+   * unset only because the true value was unverifiable.
+   */
+  private def effectiveEncryptionAlgorithm(
+      hadoopConf: Configuration,
+      bucket: String): Either[String, Option[(String, String)]] = {
+    def bucketTier(baseKey: String): Either[String, Option[(String, String)]] = {
+      val longKey = s"fs.s3a.bucket.$bucket.$baseKey"
+      val shortKey = s"fs.s3a.bucket.$bucket." + baseKey.stripPrefix("fs.s3a.")
+      resolveViaCredentialAliases(hadoopConf, bucket, Seq(longKey, shortKey))
+        .map(_.map(baseKey -> _))
+    }
+    def globalTier(baseKey: String): Either[String, Option[(String, String)]] =
+      resolveViaCredentialAliases(hadoopConf, bucket, Seq(baseKey))
+        .map(_.map(baseKey -> _))
+
+    // Short-circuits on Left (unverifiable tier) or Right(Some(_)) (resolved); only Right(None)
+    // (tier definitively unset) falls through to `next`, mirroring buildEncryptionSecrets's
+    // sequential `if (algorithm == null) algorithm = ...` cascade exactly.
+    def orElseTier(
+        current: Either[String, Option[(String, String)]],
+        next: => Either[String, Option[(String, String)]])
+        : Either[String, Option[(String, String)]] =
+      current match {
+        case Left(reason) => Left(reason)
+        case Right(Some(value)) => Right(Some(value))
+        case Right(None) => next
+      }
+
+    orElseTier(
+      bucketTier(S3EncryptionAlgorithmKey),
+      orElseTier(
+        bucketTier(DeprecatedS3EncryptionAlgorithmKey),
+        orElseTier(
+          globalTier(S3EncryptionAlgorithmKey),
+          // Hadoop reaches this key only through the deprecation alias (see above); reading
+          // it directly can only over-decline.
+          globalTier(DeprecatedS3EncryptionAlgorithmKey))))
+  }
+
+  /**
+   * The only algorithm values a decline reason may print. Any other resolved value is withheld,
+   * since a `${...}` reference can expand the algorithm key to a customer key or token.
+   */
+  private val PrintableEncryptionAlgorithms: Seq[String] =
+    Seq("AES256", "SSE-S3", "SSE-KMS", "DSSE-KMS", "SSE-C", "CSE-KMS", "CSE-CUSTOM")
+
+  private def unsupportedEncryptionAlgorithmDeclineReason(
+      bucket: String,
+      algorithmKey: String,
+      algorithm: String): String = {
+    val setting = PrintableEncryptionAlgorithms
+      .find(_.equalsIgnoreCase(algorithm))
+      .map(name => s"$algorithmKey=$name")
+      .getOrElse(s"$algorithmKey set to a value that is not a recognised S3 encryption algorithm")
+    s"Native Delta scan does not support $setting for $bucket " +
+      "(the native S3 client only supports unencrypted objects and S3's transparent " +
+      "server-side algorithms -- AES256/SSE-S3, SSE-KMS, and DSSE-KMS decrypt on GET/HEAD given " +
+      "read permission alone, with no extra request header; SSE-C additionally requires the " +
+      "customer-provided key resent as a header on every GET/HEAD request, which the native S3 " +
+      "client's extract_s3_config_options never forwards, and CSE-KMS/CSE-CUSTOM decrypt object " +
+      "bytes client-side, a layer the native Parquet reader does not have -- any of these would " +
+      "fail outright or silently read ciphertext where Hadoop's own reader succeeds)"
+  }
+
+  /**
+   * First reason any bucket among `uris` is configured for an encryption algorithm the native S3
+   * client cannot safely read, or `None` when claimable. Allowlist-based (see
+   * [[AllowedEncryptionAlgorithms]]): only `AES256`/`SSE-KMS`/`DSSE-KMS` (and unset/empty) pass;
+   * every other resolved value -- `SSE-C`, `CSE-KMS`, `CSE-CUSTOM`, or any unrecognized future
+   * algorithm string -- declines. Deliberately NOT a blocklist keyed on `SSE-C` alone: an
+   * allowlist is safe by construction against a Hadoop release adding a new encryption method
+   * this gate has never heard of, where a blocklist would silently admit it. Never interpolates a
+   * resolved key value, only key names, the bucket, and the (non-secret) algorithm name. Declines
+   * on a `Left` from [[effectiveEncryptionAlgorithm]] too (an unverifiable credential-provider
+   * arm, e.g. an S3A-scoped provider path or a corrupt/unreadable global keystore) -- the
+   * algorithm cannot be ruled safe when it cannot be read at all.
+   */
+  private[delta] def unsupportedEncryptionAlgorithmReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI],
+      propagatedConfCache: MutableMap[String, Configuration] = MutableMap.empty)
+      : Option[String] = {
+    val buckets = uris.flatMap(s3Bucket).distinct
+    buckets.foldLeft(Option.empty[String]) { (declined, bucket) =>
+      if (declined.isDefined) {
+        declined
+      } else {
+        try {
+          // Hadoop resolves the algorithm on the propagated view, where a bucket override can
+          // change what a `${...}` reference expands to. The raw view is checked as well, so a
+          // disagreement between the two can only decline.
+          val propagatedConf =
+            propagatedConfCache.getOrElseUpdate(
+              bucket,
+              propagateBucketOptions(hadoopConf, bucket))
+          encryptionAlgorithmReason(propagatedConf, bucket)
+            .orElse(encryptionAlgorithmReason(hadoopConf, bucket))
+        } catch {
+          case e @ (_: IOException | _: RuntimeException) =>
+            Some(unverifiableValueReason(bucket, S3EncryptionAlgorithmKey, e))
+        }
+      }
+    }
+  }
+
+  private def encryptionAlgorithmReason(conf: Configuration, bucket: String): Option[String] =
+    effectiveEncryptionAlgorithm(conf, bucket) match {
+      case Left(reason) => Some(reason)
+      case Right(None) => None
+      case Right(Some((key, value))) =>
+        if (!AllowedEncryptionAlgorithms.exists(_.equalsIgnoreCase(value))) {
+          Some(unsupportedEncryptionAlgorithmDeclineReason(bucket, key, value))
+        } else {
+          None
+        }
+    }
+
+  /**
+   * Canonical Hadoop S3A HTTP-proxy host config key, verified via CFR decompilation of
+   * `hadoop-aws` 3.3.4's `S3AUtils.class` (`initProxySupport`):
+   * {{{
+   * String proxyHost = conf.getTrimmed("fs.s3a.proxy.host", "");
+   * int proxyPort = conf.getInt("fs.s3a.proxy.port", -1);
+   * if (!proxyHost.isEmpty()) {
+   *   ...
+   *   String proxyUsername =
+   *       S3AUtils.lookupPassword(bucket, conf, "fs.s3a.proxy.username", null, null);
+   *   String proxyPassword =
+   *       S3AUtils.lookupPassword(bucket, conf, "fs.s3a.proxy.password", null, null);
+   *   ...
+   * }
+   * }}}
+   * `fs.s3a.proxy.host`/`fs.s3a.proxy.port` resolve via a PLAIN, non-bucket-scoped, non-JCEKS
+   * `Configuration#getTrimmed`/`getInt` call -- NOT `lookupPassword` -- against whatever conf
+   * `S3AFileSystem#initialize` already ran through `propagateBucketOptions` before
+   * `createAwsConf`/`initProxySupport` ever runs; only the SIBLING `fs.s3a.proxy.username`/
+   * `fs.s3a.proxy.password` keys go through `lookupPassword` (bucket long/short/global,
+   * JCEKS-aware). So the host is bucket-aware only via `propagateBucketOptions`'s short-bucket-
+   * form folding, never the long-bucket form, and never a credential-provider read -- the SAME
+   * shape as `endpoint`/`path.style.access` ([[PropagatedOptionConsumer]], see
+   * [[S3ConfigKeyConsumers]]'s doc), not the credential family. `hadoop-aws` 3.4.x (the Spark 4.x
+   * profiles' version) moves this code to `AWSClientConfig#createProxyConfiguration`/
+   * `#createAsyncProxyConfiguration` but keeps the exact same reads, verified via `javap` against
+   * 3.4.2: `conf.getTrimmed("fs.s3a.proxy.host", "")` for the host, `S3AUtils.lookupPassword` for
+   * username/password only.
+   *
+   * [[proxyGateReason]] therefore resolves the host EXACTLY like its real consumer -- plain
+   * `Configuration#getTrimmed` on the [[propagateBucketOptions]] result, no provider arms, no
+   * [[ClearTextFallbackKey]] handling -- rather than through the wider `lookupPassword` cascade
+   * an earlier version reused here. The wider cascade was wrong in BOTH directions for this key:
+   * with only the GLOBAL Hadoop provider path set and [[ClearTextFallbackKey]] false,
+   * `getPassword` hides a plaintext host that `getTrimmed` serves to Hadoop anyway (a missed
+   * decline, the exact bypass this gate exists to close -- native has NO HTTP-proxy support of
+   * any kind, no `fs.s3a.proxy.*` key is read anywhere in `s3.rs`); and an S3A-scoped provider
+   * path or a lone long-form bucket alias declined a bucket whose real consumer can never see a
+   * host from either source (pure over-refusal -- no keystore can supply the host to a plain
+   * `getTrimmed`, and the long form folds into the unread `fs.s3a.fs.s3a.proxy.host`).
+   */
+  private val S3ProxyHostKey = "fs.s3a.proxy.host"
+
+  private def unsupportedProxyReason(bucket: String, key: String): String =
+    s"Native Delta scan does not support $key configured for $bucket (the native S3 client has " +
+      "no HTTP proxy support at all -- no fs.s3a.proxy.* key is read anywhere in its object " +
+      "store layer -- so a claimed scan would connect to S3 directly instead of routing through " +
+      "the configured proxy, either bypassing an egress/network-segmentation policy or simply " +
+      "failing to reach the endpoint)"
+
+  /**
+   * First reason any bucket among `uris` has an HTTP proxy configured via [[S3ProxyHostKey]], or
+   * `None` when claimable. Reads the host EXACTLY like its real consumer (see
+   * [[S3ProxyHostKey]]'s doc): plain `Configuration#getTrimmed` on the [[propagateBucketOptions]]
+   * result, so this gate is always zero-I/O -- no credential provider is ever consulted for the
+   * host, because none ever supplies it to Hadoop either. Ordered alongside
+   * [[unsupportedEncryptionAlgorithmReason]] among the conf-only gates, ahead of
+   * [[s3ConfigDivergenceReason]]. The try/catch guards `Configuration#get`'s
+   * `IllegalStateException` on a `${...}` substitution cycle, same as [[s3KeyDivergenceReason]].
+   * Never interpolates a resolved value: the proxy HOST is not secret, but naming it here would
+   * be a strange place to first surface it, and proxy CREDENTIALS
+   * (`fs.s3a.proxy.username`/`fs.s3a.proxy.password`, not read by this gate at all -- the whole
+   * point of gating on the host is that a non-empty host declines before any proxy credential
+   * would ever need to be forwarded) must never appear in a decline reason regardless.
+   */
+  private[delta] def proxyGateReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI],
+      propagatedConfCache: MutableMap[String, Configuration] = MutableMap.empty)
+      : Option[String] = {
+    val buckets = uris.flatMap(s3Bucket).distinct
+    buckets.foldLeft(Option.empty[String]) { (declined, bucket) =>
+      if (declined.isDefined) {
+        declined
+      } else {
+        try {
+          val propagatedConf =
+            propagatedConfCache.getOrElseUpdate(
+              bucket,
+              propagateBucketOptions(hadoopConf, bucket))
+          if (propagatedConf.getTrimmed(S3ProxyHostKey, "").nonEmpty) {
+            Some(unsupportedProxyReason(bucket, S3ProxyHostKey))
+          } else {
+            None
+          }
+        } catch {
+          case e @ (_: IOException | _: RuntimeException) =>
+            Some(unverifiableValueReason(bucket, S3ProxyHostKey, e))
+        }
+      }
+    }
+  }
+
+  /**
+   * Canonical Hadoop S3A assumed-role session-policy key. `AssumedRoleCredentialProvider`'s
+   * constructor reads it via a plain `Configuration#getTrimmed` against the
+   * [[propagateBucketOptions]]-propagated conf (verified via `javap` against `hadoop-aws` 3.3.4
+   * and 3.4.1: `conf.getTrimmed("fs.s3a.assumed.role.policy", "")` -- the same consumer shape as
+   * `assumed.role.arn`/`session.name`, see [[S3ConfigKeyConsumers]]) and, when non-empty,
+   * attaches it as the session policy of its STS AssumeRole request.
+   */
+  private val S3AssumedRolePolicyKey = "fs.s3a.assumed.role.policy"
+
+  private def assumedRolePolicyReason(bucket: String, key: String): String =
+    s"Native Delta scan does not support $key configured for $bucket (Hadoop sends the " +
+      "configured session policy in its STS AssumeRole request, but the native S3 client's " +
+      "assumed-role provider never reads or forwards this key, so a claimed scan would " +
+      "assume the role WITHOUT the configured session restriction -- silently widening the " +
+      "effective permissions instead of failing)"
+
+  /**
+   * First reason any bucket among `uris` configures an assumed-role session policy via
+   * [[S3AssumedRolePolicyKey]], or `None` when claimable. Hadoop's
+   * `AssumedRoleCredentialProvider` includes the policy in its AssumeRole request; native's
+   * assumed-role provider does not, so a configured policy must decline until native supports it.
+   * Resolved exactly like the key's real consumer (plain `getTrimmed` on the propagated conf,
+   * mirroring [[proxyGateReason]]); declined whenever set, whether or not the current provider
+   * chain names the assumed-role provider -- a policy that is dead config today can become live
+   * through a provider-chain change native never re-validates. Never interpolates the policy
+   * document itself, only the key and bucket.
+   */
+  private[delta] def assumedRolePolicyGateReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI],
+      propagatedConfCache: MutableMap[String, Configuration] = MutableMap.empty)
+      : Option[String] = {
+    val buckets = uris.flatMap(s3Bucket).distinct
+    buckets.foldLeft(Option.empty[String]) { (declined, bucket) =>
+      if (declined.isDefined) {
+        declined
+      } else {
+        try {
+          val propagatedConf =
+            propagatedConfCache.getOrElseUpdate(
+              bucket,
+              propagateBucketOptions(hadoopConf, bucket))
+          if (propagatedConf.getTrimmed(S3AssumedRolePolicyKey, "").nonEmpty) {
+            Some(assumedRolePolicyReason(bucket, S3AssumedRolePolicyKey))
+          } else {
+            None
+          }
+        } catch {
+          case e @ (_: IOException | _: RuntimeException) =>
+            Some(unverifiableValueReason(bucket, S3AssumedRolePolicyKey, e))
+        }
+      }
+    }
+  }
+
+  /** Hadoop's S3A SSL switch; `S3AFileSystem` reads it via `Configuration#getBoolean`. */
+  private val S3SslEnabledKey = "fs.s3a.connection.ssl.enabled"
+  private val S3EndpointKey = "fs.s3a.endpoint"
+
+  /**
+   * Hadoop's assumed-role STS endpoint keys; `AssumedRoleCredentialProvider` sends AssumeRole to
+   * the configured endpoint, while native builds its provider with SDK defaults.
+   */
+  private val S3StsEndpointKeys =
+    Seq("fs.s3a.assumed.role.sts.endpoint", "fs.s3a.assumed.role.sts.endpoint.region")
+
+  private def insecureEndpointReason(bucket: String): String =
+    s"Native Delta scan does not support a scheme-less $S3EndpointKey with " +
+      s"$S3SslEnabledKey=false for $bucket (Hadoop addresses that endpoint over http://, " +
+      "while the native S3 client always assumes https://, so a claimed scan would fail at " +
+      "execution where Spark reads fine)"
+
+  private def stsEndpointReason(bucket: String, key: String): String =
+    s"Native Delta scan does not support $key configured for $bucket (Hadoop sends its " +
+      "AssumeRole request to the configured STS endpoint, while the native S3 client's " +
+      "assumed-role provider uses the SDK defaults, so the two sides would authenticate " +
+      "against different endpoints)"
+
+  /**
+   * First reason any bucket among `uris` configures an endpoint native would address differently
+   * from Hadoop: a scheme-less `fs.s3a.endpoint` with SSL disabled, or an assumed-role STS
+   * endpoint. Resolved like the keys' real consumers (plain reads on the propagated conf,
+   * mirroring [[proxyGateReason]]); the STS keys decline whenever set, since dead config can
+   * become live through a provider-chain change native never re-validates.
+   */
+  private[delta] def hadoopOnlyEndpointGateReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI],
+      propagatedConfCache: MutableMap[String, Configuration] = MutableMap.empty)
+      : Option[String] = {
+    val buckets = uris.flatMap(s3Bucket).distinct
+    buckets.foldLeft(Option.empty[String]) { (declined, bucket) =>
+      if (declined.isDefined) {
+        declined
+      } else {
+        try {
+          val propagatedConf =
+            propagatedConfCache.getOrElseUpdate(
+              bucket,
+              propagateBucketOptions(hadoopConf, bucket))
+          val endpoint = propagatedConf.getTrimmed(S3EndpointKey, "")
+          val schemeless = endpoint.nonEmpty && !endpoint.contains("://")
+          if (schemeless && !propagatedConf.getBoolean(S3SslEnabledKey, true)) {
+            Some(insecureEndpointReason(bucket))
+          } else {
+            S3StsEndpointKeys
+              .find(key => propagatedConf.getTrimmed(key, "").nonEmpty)
+              .map(key => stsEndpointReason(bucket, key))
+          }
+        } catch {
+          case e @ (_: IOException | _: RuntimeException) =>
+            Some(unverifiableValueReason(bucket, S3EndpointKey, e))
+        }
+      }
+    }
+  }
+
+  /**
+   * `baseKey`'s long, short, then global per-bucket aliases, in Hadoop's own resolution order.
+   */
+  private def longThenShortThenGlobalAliases(bucket: String, baseKey: String): Seq[String] = {
+    val suffix = baseKey.stripPrefix("fs.s3a.")
+    Seq(s"fs.s3a.bucket.$bucket.fs.s3a.$suffix", s"fs.s3a.bucket.$bucket.$suffix", baseKey)
+  }
+
+  private def s3aScopedProviderPathReason(bucket: String, providerPathKey: String): String =
+    "Native Delta scan cannot forward Hadoop credential-provider aliases for " +
+      s"$bucket ($providerPathKey configures an S3A-scoped Hadoop credential provider that " +
+      "Configuration#getPassword does not consult, so the native S3 client's credentials " +
+      "cannot be verified)"
+
+  private def unverifiableCredentialProviderReason(bucket: String, error: Throwable): String =
+    "Native Delta scan cannot verify Hadoop credential-provider aliases for " +
+      s"$bucket (reading $HadoopCredentialProviderPathKey raised " +
+      s"${error.getClass.getName}), declining rather than risk missing credentials"
+
+  /**
+   * Three-way Hadoop credential-provider-path precheck shared by every `getPassword`-based
+   * resolution below, a property of the bucket alone. An S3A- or bucket-scoped provider path,
+   * which `Configuration#getPassword` never consults, yields [[UnverifiableProvider]] with no
+   * keystore I/O. A global path with any entry that is not a local keystore yields
+   * [[NonLocalGlobalProvider]], also with no I/O (see [[globalProviderPathHasNonLocalEntry]]).
+   * Only a global path of local entries yields [[GlobalProviderOnly]], the one arm whose callers
+   * do real keystore I/O and must wrap their own `getPassword` calls in try/catch. No provider
+   * path anywhere yields [[NoProvider]], zero-I/O plain conf reads only.
+   */
+  private sealed trait CredentialProviderArm
+  private case class UnverifiableProvider(offendingKey: String) extends CredentialProviderArm
+  private case object NonLocalGlobalProvider extends CredentialProviderArm
+  private case object GlobalProviderOnly extends CredentialProviderArm
+  private case object NoProvider extends CredentialProviderArm
+
+  /**
+   * True when the global provider path has an entry other than a local keystore or a
+   * filesystem-free provider. An entry passes only as `jceks`, `localjceks`, `bcfks` or
+   * `localbcfks` with nested scheme `file` (as in `jceks://file/...`) while `fs.file.impl` is
+   * unset or `org.apache.hadoop.fs.LocalFileSystem`, or as `user` with no authority (`user:///`).
+   * Any other entry would run a third-party provider or open a filesystem during planning, and
+   * S3AFileSystem drops entries whose filesystem class is S3A-compatible before it resolves
+   * anything (`ProviderUtils.excludeIncompatibleCredentialProviders`), so reading one could also
+   * disagree with Hadoop. An unparseable or empty entry counts as non-local. The nested scheme is
+   * the part of the authority before `@`, as in `ProviderUtils.unnestUri`.
+   */
+  private def globalProviderPathHasNonLocalEntry(hadoopConf: Configuration): Boolean =
+    Option(hadoopConf.get(HadoopCredentialProviderPathKey)).filter(_.nonEmpty).exists { path =>
+      val isLocalFileSystem = Option(hadoopConf.get("fs.file.impl"))
+        .forall(_ == "org.apache.hadoop.fs.LocalFileSystem")
+      path.split(",").exists(entry => !isLocalOrFilesystemFreeProvider(entry, isLocalFileSystem))
+    }
+
+  private val KeystoreProviderSchemes = Set("jceks", "localjceks", "bcfks", "localbcfks")
+
+  private def isLocalOrFilesystemFreeProvider(
+      entry: String,
+      isLocalFileSystem: Boolean): Boolean =
+    try {
+      val uri = new URI(entry)
+      Option(uri.getAuthority) match {
+        case Some(authority) =>
+          KeystoreProviderSchemes.contains(uri.getScheme) && isLocalFileSystem &&
+          authority.split("@", 2)(0) == "file"
+        case None => uri.getScheme == "user"
+      }
+    } catch {
+      case _: URISyntaxException => false
+    }
+
+  private def nonLocalProviderPathReason(bucket: String): String =
+    s"Native Delta scan cannot verify the S3 settings for $bucket " +
+      s"($HadoopCredentialProviderPathKey names a credential keystore that is not on the local " +
+      "filesystem, and the settings cannot be verified without reading it)"
+
+  private def credentialProviderArm(
+      hadoopConf: Configuration,
+      bucket: String): CredentialProviderArm = {
+    val bucketPathKey = s3aBucketProviderPathKey(bucket)
+    val bucketLongPathKey = s3aBucketLongProviderPathKey(bucket)
+    val s3aPathSet = nonEmptyConf(hadoopConf, S3aCredentialProviderPathKey)
+    val bucketPathSet = nonEmptyConf(hadoopConf, bucketPathKey)
+    val bucketLongPathSet = nonEmptyConf(hadoopConf, bucketLongPathKey)
+    if (s3aPathSet || bucketPathSet || bucketLongPathSet) {
+      val offendingKey =
+        if (s3aPathSet) S3aCredentialProviderPathKey
+        else if (bucketPathSet) bucketPathKey
+        else bucketLongPathKey
+      UnverifiableProvider(offendingKey)
+    } else if (globalProviderPathHasNonLocalEntry(hadoopConf)) {
+      NonLocalGlobalProvider
+    } else if (nonEmptyConf(hadoopConf, HadoopCredentialProviderPathKey)) {
+      GlobalProviderOnly
+    } else {
+      NoProvider
+    }
+  }
+
+  /**
+   * Resolves `aliases` in order under `hadoopConf`/`bucket`, keeping the first non-empty value,
+   * or `Left(reason)` when the value cannot be safely verified. Dispatches on
+   * [[credentialProviderArm]]: [[UnverifiableProvider]] and [[NonLocalGlobalProvider]] decline
+   * with zero I/O; [[GlobalProviderOnly]] resolves each alias via `Configuration#getPassword`,
+   * keystore I/O contained in try/catch so a corrupt store declines this bucket rather than
+   * aborting planning; [[NoProvider]] resolves each alias via zero-I/O [[plainValue]] reads,
+   * which honor [[ClearTextFallbackKey]] the way a real `getPassword` consumer would. Callers
+   * such as [[hadoopLookupPasswordEffective]] and [[effectiveEncryptionAlgorithm]] supply the
+   * alias lists that match their consumer's real per-tier `getPassword` calls.
+   */
+  private def resolveViaCredentialAliases(
+      hadoopConf: Configuration,
+      bucket: String,
+      aliases: Seq[String]): Either[String, Option[String]] =
+    credentialProviderArm(hadoopConf, bucket) match {
+      case UnverifiableProvider(offendingKey) =>
+        Left(s3aScopedProviderPathReason(bucket, offendingKey))
+      case NonLocalGlobalProvider =>
+        Left(nonLocalProviderPathReason(bucket))
+      case GlobalProviderOnly =>
+        try {
+          Right(
+            aliases.iterator
+              .map(alias =>
+                Option(hadoopConf.getPassword(alias)).map(new String(_)).filter(_.nonEmpty))
+              .collectFirst { case Some(v) => v })
+        } catch {
+          case e @ (_: IOException | _: RuntimeException) =>
+            Left(unverifiableCredentialProviderReason(bucket, e))
+        }
+      case NoProvider =>
+        if (!hadoopConf.getBoolean(ClearTextFallbackKey, true)) {
+          Right(None)
+        } else {
+          Right(aliases.flatMap(plainValue(hadoopConf, _)).headOption)
+        }
+    }
+
+  /**
+   * `bucket`'s effective value for `baseKey` in Hadoop's own `S3AUtils#lookupPassword` resolution
+   * order -- long bucket alias, then short bucket alias, then global, each tried through a Hadoop
+   * credential provider before falling back to plain conf (see [[resolveViaCredentialAliases]]
+   * for the Arm A/B/C dispatch this delegates to) -- or `Left(reason)` when the value cannot be
+   * safely verified.
+   *
+   * USED ONLY for keys whose real consumer IS `lookupPassword` -- the [[LookupPasswordConsumer]]
+   * entries of [[S3ConfigKeyConsumers]], via [[s3KeyDivergenceReason]]. An earlier version ran
+   * EVERY compared key through this function, reasoning that a wider read could only ever
+   * over-decline; for a value-EQUALITY comparator that reasoning is half-true: the long-form
+   * alias this function consults FIRST can hold exactly the value native resolves while Hadoop's
+   * true propagate-then-plain-get value differs (e.g. a `${...}` reference whose referent
+   * propagation redirects), producing a false EQUALITY that admits a really-diverging scan. A
+   * [[PropagatedOptionConsumer]] key must therefore resolve like its actual consumer instead --
+   * see [[s3KeyDivergenceReason]].
+   *
+   * Honors [[ClearTextFallbackKey]] (via [[resolveViaCredentialAliases]]'s [[NoProvider]] arm),
+   * matching `getPassword`'s real refusal to read plaintext conf when the flag is off.
+   *
+   * `hadoopConf` must be a [[propagateBucketOptions]] result (the caller,
+   * [[s3KeyDivergenceReason]], always passes one) so that `${...}` references embedded in any
+   * alias resolve exactly like `S3AFileSystem#initialize`'s real propagate-then-resolve order.
+   */
+  private def hadoopLookupPasswordEffective(
+      hadoopConf: Configuration,
+      bucket: String,
+      baseKey: String): Either[String, Option[String]] =
+    resolveViaCredentialAliases(
+      hadoopConf,
+      bucket,
+      longThenShortThenGlobalAliases(bucket, baseKey))
+
+  private def effectiveValueDivergenceReason(bucket: String, key: String): String =
+    s"Native Delta scan cannot forward $key for $bucket (Hadoop's effective value for this key " +
+      "differs from what the native S3 client resolves, so its credentials or configuration " +
+      "would differ from Hadoop's)"
+
+  private def unverifiableValueReason(bucket: String, key: String, error: Throwable): String =
+    s"Native Delta scan cannot verify $key for $bucket (Configuration#get raised " +
+      s"${error.getClass.getName}), declining rather than risk forwarding a stale or " +
+      "diverging value"
+
+  /**
+   * `None` when `baseKey`'s Hadoop-effective and native-effective values under `bucket` agree, or
+   * a decline reason naming `baseKey` and `bucket` (never a value) when they diverge or either
+   * side cannot be safely computed.
+   *
+   * Hadoop's effective value is computed against [[propagateBucketOptions]]'s result, mirroring
+   * `S3AFileSystem#initialize`'s actual order (propagate bucket options into the conf FIRST, only
+   * THEN read/substitute options against it), through the resolution `consumer` declares for the
+   * key in [[S3ConfigKeyConsumers]]: [[LookupPasswordConsumer]] keys via
+   * [[hadoopLookupPasswordEffective]] (long-then-short-then-global, keystore- and
+   * [[ClearTextFallbackKey]]-aware), [[PropagatedOptionConsumer]] keys via a plain
+   * `Configuration#get` on the propagated view (short-form wins by propagation alone; the long
+   * form and any keystore/fallback handling are ignored, exactly like the key's real consumer).
+   * Resolving a plain-consumer key through the wider `lookupPassword` cascade instead would let a
+   * long-form alias value Hadoop never reads EQUAL native's resolution while Hadoop's true
+   * plain-get value differs -- a false equality admitting a diverging scan, not merely an extra
+   * decline. Native's effective value is always `nativeShortThenGlobal(hadoopConf, ...)` on the
+   * ORIGINAL, unpropagated conf, matching `NativeConfig.extractObjectStoreOptions`'s actual
+   * forwarding semantics (no propagation step) AND native's `get_config` presence-based (not
+   * emptiness-based) short-vs-global fallback -- see [[nativeShortThenGlobal]]. Both values are
+   * trimmed together, symmetrically, right before the equality check below (mirroring
+   * `get_config_trimmed`'s `.trim()`, which native applies regardless of which alias it read)
+   * rather than trimming [[nativeShortThenGlobal]]'s result on its own -- see
+   * [[nativeShortThenGlobal]]'s doc for why a one-sided trim there would flag a spurious
+   * divergence. Comparing against the propagated view (rather than the original conf, as an
+   * earlier version of this check did) matters because propagation can change what a `${...}`
+   * reference inside one bucket-scoped value resolves to: e.g.
+   * `fs.s3a.bucket.B.access.key=${fs.s3a.custom.ref}` with `fs.s3a.bucket.B.custom.ref=X` and
+   * global `fs.s3a.custom.ref=Y` propagates to `fs.s3a.custom.ref=X` (overwriting the global `Y`)
+   * before the access key's `${...}` reference is ever substituted, so Hadoop resolves `X` while
+   * a check against the unpropagated conf would (wrongly) also see `Y`, the same value native
+   * forwards -- masking a real divergence. Wrapped in try/catch: `Configuration#get` raises
+   * `IllegalStateException` once `${...}` substitution recurses past Hadoop's `MAX_SUBST` bound
+   * (e.g. a two-key mutual reference cycle); declining is safer than crashing planning or
+   * comparing a partially-substituted value.
+   */
+  private def s3KeyDivergenceReason(
+      hadoopConf: Configuration,
+      propagatedConf: Configuration,
+      bucket: String,
+      baseKey: String,
+      consumer: S3ConfigConsumer): Option[String] = {
+    try {
+      val hadoopEffective: Either[String, Option[String]] = consumer match {
+        case LookupPasswordConsumer =>
+          hadoopLookupPasswordEffective(propagatedConf, bucket, baseKey)
+        case PropagatedOptionConsumer =>
+          Right(Option(propagatedConf.get(baseKey)))
+      }
+      hadoopEffective match {
+        case Left(reason) => Some(reason)
+        case Right(hadoopValue) =>
+          val nativeValue = nativeShortThenGlobal(hadoopConf, bucket, baseKey)
+          if (hadoopValue.map(_.trim) != nativeValue.map(_.trim)) {
+            Some(effectiveValueDivergenceReason(bucket, baseKey))
+          } else {
+            None
+          }
+      }
+    } catch {
+      case e @ (_: IOException | _: RuntimeException) =>
+        Some(unverifiableValueReason(bucket, baseKey, e))
+    }
+  }
+
+  /**
+   * First reason any bucket among `uris` cannot faithfully forward every [[AllS3ConfigKeys]]
+   * option to native, or `None` when every key's Hadoop-effective and native-effective value
+   * agrees for every S3/S3A bucket referenced. Only `s3`/`s3a` authorities matter here (ABFS/WASB
+   * mooted by the userinfo gate, GCS handled by [[gcsHadoopOnlyAuthReason]]). One comparator
+   * replaces the former per-case gate family (long-form bucket credentials, JCEKS/provider
+   * shadowing, Hadoop `${...}` variable references): [[s3KeyDivergenceReason]] computes Hadoop's
+   * effective value against a per-bucket [[propagateBucketOptions]] replica (matching
+   * `S3AFileSystem#initialize`'s real propagate-then-resolve order), so a `${...}` reference that
+   * resolves identically under that propagated view and under native's unpropagated forwarding is
+   * no longer a divergence at all, while one that resolves differently (e.g. because propagation
+   * shadowed a referenced key with a per-bucket override) IS still caught.
+   * [[s3KeyDivergenceReason]] resolves each key through the consumer family
+   * [[S3ConfigKeyConsumers]] declares for it, right beside the key itself: the SSE-C
+   * long-bucket-alias bypass came from a key's resolution being decided implicitly, scattered
+   * across call sites, so the classification is now a single visible list -- and the tier must
+   * MATCH the key's real consumer in both directions, because an equality comparator resolving a
+   * plain-get key through the wider `lookupPassword` cascade can manufacture a false EQUALITY
+   * (long-form alias equal to native's value, true propagated plain value different) just as
+   * readily as a false divergence. Never interpolates a resolved value, only key names.
+   */
+  private[delta] def s3ConfigDivergenceReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI],
+      propagatedConfCache: MutableMap[String, Configuration] = MutableMap.empty)
+      : Option[String] = {
+    val buckets = uris.flatMap(s3Bucket).distinct
+    buckets.foldLeft(Option.empty[String]) { (declined, bucket) =>
+      if (declined.isDefined) {
+        declined
+      } else {
+        try {
+          val propagatedConf =
+            propagatedConfCache.getOrElseUpdate(
+              bucket,
+              propagateBucketOptions(hadoopConf, bucket))
+          S3ConfigKeyConsumers.foldLeft(Option.empty[String]) {
+            case (keyDeclined, (key, consumer)) =>
+              if (keyDeclined.isDefined) {
+                keyDeclined
+              } else {
+                s3KeyDivergenceReason(hadoopConf, propagatedConf, bucket, key, consumer)
+              }
+          }
+        } catch {
+          case e @ (_: IOException | _: RuntimeException) =>
+            Some(unverifiableValueReason(bucket, AllS3ConfigKeys.head, e))
+        }
+      }
+    }
+  }
+
+  /**
+   * String-literal mirror of every credential-provider class name s3.rs's
+   * `build_aws_credential_provider_metadata` recognizes (Hadoop S3A plus AWS SDK v1/v2 names).
+   * `hadoop-aws` is NOT on this module's runtime classpath, so these stay string literals, never
+   * `classOf` references.
+   */
+  private val SupportedCredentialProviderClasses: Set[String] = Set(
+    "org.apache.hadoop.fs.s3a.auth.IAMInstanceCredentialsProvider",
+    "org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider",
+    "org.apache.hadoop.fs.s3a.TemporaryAWSCredentialsProvider",
+    "org.apache.hadoop.fs.s3a.auth.AssumedRoleCredentialProvider",
+    "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider",
+    "software.amazon.awssdk.auth.credentials.ContainerCredentialsProvider",
+    "com.amazonaws.auth.ContainerCredentialsProvider",
+    "com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper",
+    "software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider",
+    "com.amazonaws.auth.InstanceProfileCredentialsProvider",
+    "software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider",
+    "com.amazonaws.auth.EnvironmentVariableCredentialsProvider",
+    "software.amazon.awssdk.auth.credentials.WebIdentityTokenFileCredentialsProvider",
+    "com.amazonaws.auth.WebIdentityTokenCredentialsProvider",
+    "software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider",
+    "com.amazonaws.auth.profile.ProfileCredentialsProvider",
+    "software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider",
+    "com.amazonaws.auth.AnonymousAWSCredentials")
+
+  private val AnonymousCredentialProviderClasses: Set[String] = Set(
+    "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider",
+    "software.amazon.awssdk.auth.credentials.AnonymousCredentialsProvider",
+    "com.amazonaws.auth.AnonymousAWSCredentials")
+
+  private val HadoopAssumedRoleProviderClass =
+    "org.apache.hadoop.fs.s3a.auth.AssumedRoleCredentialProvider"
+
+  private val AwsCredentialsProviderKey = "fs.s3a.aws.credentials.provider"
+  private val AssumedRoleCredentialsProviderKey = "fs.s3a.assumed.role.credentials.provider"
+
+  /** Splits a comma-separated credential-provider-class list the same way s3.rs's parser does. */
+  private def parseProviderClassNames(value: String): Seq[String] =
+    value.split(",").map(_.trim).filter(_.nonEmpty).toSeq
+
+  // The class name is withheld: an unsupported value is never one of the known classes, and a
+  // `${...}` reference can expand the key to a credential.
+  private def unsupportedProviderReason(bucket: String, key: String): String =
+    "Native Delta scan does not support a credential provider class " +
+      s"configured via $key for $bucket (the native S3 client only supports a fixed set of " +
+      "provider classes; an unsupported class would fail at scan execution time, after the " +
+      "scan was already claimed, rather than at planning time)"
+
+  private def mixedAnonymousProviderReason(bucket: String, key: String): String =
+    s"Native Delta scan does not support $key for $bucket naming an anonymous credential " +
+      "provider together with any other provider (the native S3 client rejects this " +
+      "combination at scan execution time)"
+
+  private def anonymousAssumedRoleProviderReason(bucket: String, key: String): String =
+    s"Native Delta scan does not support an anonymous credential provider in $key for " +
+      s"$bucket (the native S3 client does not allow an anonymous provider as the base " +
+      "credentials for an assumed-role chain)"
+
+  private def unsupportedProviderNameReason(
+      bucket: String,
+      key: String,
+      names: Seq[String]): Option[String] =
+    if (names.exists(name => !SupportedCredentialProviderClasses.contains(name))) {
+      Some(unsupportedProviderReason(bucket, key))
+    } else {
+      None
+    }
+
+  /**
+   * [[shortThenGlobal]] for `key` under `bucket`, or `Left(reason)` when `Configuration#get`
+   * itself raises: Hadoop throws `IllegalStateException` once `${...}` expansion recurses past
+   * its `MAX_SUBST` bound, e.g. a mutual reference cycle between two provider keys. Every
+   * provider-class read below goes through this wrapper so the exception is caught here,
+   * whichever entry point runs first. Reuses [[unverifiableValueReason]]'s message shape (names
+   * the key and the exception class, never a value).
+   */
+  private def shortThenGlobalOrReason(
+      hadoopConf: Configuration,
+      bucket: String,
+      key: String): Either[String, Option[String]] =
+    try {
+      Right(shortThenGlobal(hadoopConf, bucket, key))
+    } catch {
+      case e @ (_: IOException | _: RuntimeException) =>
+        Left(unverifiableValueReason(bucket, key, e))
+    }
+
+  /**
+   * Decline reason when `bucket`'s effective `assumed.role.credentials.provider` names an
+   * unsupported class, or an anonymous one (native rejects ANY anonymous entry here, not just a
+   * mix), or when reading it raises (see [[shortThenGlobalOrReason]]). Unset defaults to native's
+   * own always-supported fallback, so `None` is safe.
+   */
+  private def assumedRoleProviderClassReason(
+      hadoopConf: Configuration,
+      bucket: String): Option[String] = {
+    shortThenGlobalOrReason(hadoopConf, bucket, AssumedRoleCredentialsProviderKey) match {
+      case Left(reason) => Some(reason)
+      case Right(None) => None
+      case Right(Some(value)) =>
+        val names = parseProviderClassNames(value)
+        unsupportedProviderNameReason(bucket, AssumedRoleCredentialsProviderKey, names).orElse {
+          if (names.exists(AnonymousCredentialProviderClasses.contains)) {
+            Some(anonymousAssumedRoleProviderReason(bucket, AssumedRoleCredentialsProviderKey))
+          } else {
+            None
+          }
+        }
+    }
+  }
+
+  /**
+   * Decline reason when `bucket`'s effective `aws.credentials.provider` names an unrecognized
+   * class, mixes an anonymous provider with any other, a nested `AssumedRoleCredentialProvider`
+   * sub-chain has the same problem, or reading either key raises (see
+   * [[shortThenGlobalOrReason]]). Unset/empty falls back to native's default chain.
+   */
+  private def providerClassReason(hadoopConf: Configuration, bucket: String): Option[String] = {
+    shortThenGlobalOrReason(hadoopConf, bucket, AwsCredentialsProviderKey) match {
+      case Left(reason) => Some(reason)
+      case Right(None) => None
+      case Right(Some(value)) =>
+        val names = parseProviderClassNames(value)
+        unsupportedProviderNameReason(bucket, AwsCredentialsProviderKey, names)
+          .orElse {
+            if (names.length > 1 && names.exists(AnonymousCredentialProviderClasses.contains)) {
+              Some(mixedAnonymousProviderReason(bucket, AwsCredentialsProviderKey))
+            } else {
+              None
+            }
+          }
+          .orElse {
+            if (names.contains(HadoopAssumedRoleProviderClass)) {
+              assumedRoleProviderClassReason(hadoopConf, bucket)
+            } else {
+              None
+            }
+          }
+    }
+  }
+
+  /**
+   * First reason any bucket among `uris` names an unsupported credential-provider class, or
+   * `None` when every named class is supported (or the key is unset). `NativeConfig` forwards
+   * `Configuration#get`'s substituted value for every entry, the same read [[shortThenGlobal]]
+   * performs here, so a `${...}` reference resolves identically for native and for this check.
+   */
+  private[delta] def providerClassGateReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI]): Option[String] = {
+    val buckets = uris.flatMap(s3Bucket).distinct
+    buckets.foldLeft(Option.empty[String]) { (declined, bucket) =>
+      if (declined.isDefined) declined else providerClassReason(hadoopConf, bucket)
+    }
+  }
+
+  /**
+   * True when `key` names a GCS authentication option under either Hadoop conf namespace the
+   * `gcs-connector` reads (`fs.gs.*` or the legacy `google.cloud.*`) AND the key itself concerns
+   * authentication. The connector's own `HadoopCredentialConfiguration` builds each auth setting
+   * from a prefix crossed with a suffix (service-account keyfile/email/private-key, OAuth client
+   * id/secret, impersonation, workload identity, and so on), including reversed-word-order
+   * deprecated forms (`fs.gs.service.account.auth.keyfile`) alongside the modern ones
+   * (`fs.gs.auth.service.account.json.keyfile`) -- enumerating every current and future suffix as
+   * a fixed prefix list is a losing game the connector itself does not play; matching on
+   * "namespace + contains auth" tracks the connector's own auth-vs-non-auth boundary instead of
+   * chasing its naming history. `gcs-connector` is NOT on this module's runtime classpath by
+   * default, so referencing an actual GCS auth class would risk `NoClassDefFoundError`, same
+   * rationale as the S3A literals above.
+   */
+  private def isGcsAuthKey(key: String): Boolean =
+    (key.startsWith("fs.gs.") || key.startsWith("google.cloud.")) && key.contains("auth")
+
+  /**
+   * True when `uri`'s scheme is `gs` (case-insensitive) -- the ONLY scheme object_store's
+   * `ObjectStoreScheme::parse` (parquet_support.rs) routes to `GoogleCloudStorage`; `gcs` is not
+   * recognized there and is deliberately excluded.
+   */
+  private def isGcsScheme(uri: URI): Boolean =
+    Option(uri.getScheme).exists(_.equalsIgnoreCase("gs"))
+
+  /**
+   * The lowercase-scheme-checked GCS bucket name from `uri`'s authority (host, minus any userinfo
+   * or port), or `None` when `uri`'s scheme is not `gs`. Parses the raw authority manually,
+   * mirroring [[s3Bucket]]'s `URI#getHost`/RFC 3986 `reg-name` reasoning.
+   */
+  private def gcsBucket(uri: URI): Option[String] = {
+    if (!isGcsScheme(uri)) {
+      None
+    } else {
+      val authority = Option(uri.getAuthority).getOrElse("")
+      val at = authority.lastIndexOf('@')
+      val hostAndPort = if (at >= 0) authority.substring(at + 1) else authority
+      val colon = hostAndPort.lastIndexOf(':')
+      val host = if (colon >= 0) hostAndPort.substring(0, colon) else hostAndPort
+      if (host.isEmpty) None else Some(host)
+    }
+  }
+
+  /**
+   * The non-empty Hadoop conf keys set on `hadoopConf` for which [[isGcsAuthKey]] holds, full key
+   * names only -- NEVER their values, which are credential material and must never enter a
+   * decline reason. Iterates the conf map directly: no provider resolution, no I/O.
+   */
+  private def gcsAuthKeys(hadoopConf: Configuration): Seq[String] =
+    hadoopConf
+      .iterator()
+      .asScala
+      .collect {
+        case entry
+            if isGcsAuthKey(entry.getKey) && entry.getValue != null &&
+              entry.getValue.nonEmpty =>
+          entry.getKey
+      }
+      .toSeq
+      .distinct
+      .sorted
+
+  /**
+   * Decline reason when any of `uris` resolves to a `gs://` authority AND `hadoopConf` sets any
+   * key [[isGcsAuthKey]] flags, or `None` when claimable. Native forwards none of `fs.gs.*` (nor
+   * any of the legacy/deprecated `google.cloud.*` namespaces) to the object store, so a scan
+   * relying solely on Hadoop-side GCS credentials would claim here but then fail authentication
+   * natively. Application Default Credentials work identically in both engines and need no Hadoop
+   * conf key, so an ADC-only configuration still claims. Never interpolates a resolved value,
+   * only key names.
+   */
+  private[delta] def gcsHadoopOnlyAuthReason(
+      hadoopConf: Configuration,
+      uris: Seq[URI]): Option[String] = {
+    val gcsUris = uris.filter(isGcsScheme)
+    if (gcsUris.isEmpty) {
+      return None
+    }
+    val authKeys = gcsAuthKeys(hadoopConf)
+    if (authKeys.isEmpty) {
+      return None
+    }
+    val buckets = gcsUris.flatMap(gcsBucket).distinct.sorted
+    Some(
+      "Native Delta scan does not support GCS authentication configured only via Hadoop conf " +
+        s"key(s) ${authKeys.mkString(", ")} for gs://${buckets.mkString(", gs://")} " +
+        "(the native GCS client does not forward fs.gs.* options; only Application Default " +
+        "Credentials -- environment or metadata-server -- are available natively)")
+  }
+
+  /**
+   * True when `dataType` is, or structurally contains (through array elements or map keys/
+   * values), a [[StructType]]. Only [[StructType]] fields carry Delta's physical, column-mapped
+   * names; array/map labels themselves are never column-mapped.
+   */
+  private def containsNestedStruct(dataType: DataType): Boolean = dataType match {
+    case _: StructType => true
+    case ArrayType(elementType, _) => containsNestedStruct(elementType)
+    case MapType(keyType, valueType, _) =>
+      containsNestedStruct(keyType) || containsNestedStruct(valueType)
+    case _ => false
+  }
+
+  /**
+   * True when `node` is a positional-output union -- `UnionExec` or `CometUnionExec`. Both
+   * compute output positionally from the FIRST child's attributes, so a value carried only by a
+   * LATER branch needs an explicit positional walk below. Compared by class name (the
+   * [[isDeltaScan]] idiom) to avoid a compile-time dependency; an unmatched name is still safe,
+   * caught by the generic child-output safety net below.
+   */
+  private def isPositionalUnion(node: SparkPlan): Boolean = {
+    val name = node.getClass.getSimpleName
+    name == "UnionExec" || name == "CometUnionExec"
+  }
+
+  /**
+   * True when the scan's row-index column value is provably dead above the scan. The standard DV
+   * plan shape routes it only into a `named_struct(... row_index ...) AS _metadata` projection
+   * whose result the final projection discards; anything else (a query actually selecting
+   * `_metadata.row_index`, OR a write sink -- `DataWritingCommandExec`, `WriteFilesExec`, a DSv2
+   * `V2TableWriteExec` -- persisting it) makes the value live and must decline. Conservative: any
+   * unrecognized consumption pattern returns false.
+   */
+  private def rowIndexUnusedAbove(plan: SparkPlan, scanExec: FileSourceScanExec): Boolean =
+    attributesUnusedAbove(
+      plan,
+      scanExec,
+      scanExec.output.filter(_.name == CometDeltaNativeScan.RowIndexColumn).map(_.exprId).toSet)
+
+  /**
+   * True when the values of the scan output attributes `attrIds` are provably dead above the
+   * scan, by the analysis described on [[rowIndexUnusedAbove]].
+   */
+  private def attributesUnusedAbove(
+      plan: SparkPlan,
+      scanExec: FileSourceScanExec,
+      attrIds: Set[ExprId]): Boolean = {
+    if (attrIds.isEmpty) {
+      return true
+    }
+    // Transitive taint analysis: everything derived from the seed attributes within the
+    // visible plan, via Project aliases or positionally across a union. The plan may be an AQE
+    // stage fragment, so tainted values escaping to the fragment's own output must decline too.
+    var tainted = attrIds
+    var changed = true
+    while (changed) {
+      changed = false
+      plan.foreach {
+        case p: ProjectExec =>
+          p.projectList.foreach {
+            case a: Alias
+                if !tainted.contains(a.exprId) &&
+                  a.references.exists(r => tainted.contains(r.exprId)) =>
+              tainted += a.exprId
+              changed = true
+            case _ =>
+          }
+        case u if isPositionalUnion(u) =>
+          // Output attributes carry the FIRST child's expression IDs, so a value tainted only in
+          // a LATER branch is otherwise invisible; walk it forward positionally instead.
+          // `children` can be re-parented by AQE after `output` is frozen, so an arity mismatch on
+          // ANY child (which would make a positional zip silently truncate) forces a decline.
+          if (u.children.exists(_.output.length != u.output.length)) {
+            return false
+          }
+          u.children.foreach { child =>
+            child.output.zip(u.output).foreach {
+              case (from, to) if tainted.contains(from.exprId) && !tainted.contains(to.exprId) =>
+                tainted += to.exprId
+                changed = true
+              case _ =>
+            }
+          }
+        case _ =>
+      }
+    }
+    val nonProjectConsumer = plan.exists {
+      case _: ProjectExec => false
+      case n if n ne scanExec =>
+        n.expressions.exists(_.references.exists(r => tainted.contains(r.exprId)))
+      case _ => false
+    }
+    val escapes = plan.output.exists(a => tainted.contains(a.exprId))
+    // Generic safety net for every OTHER node, of ANY arity (joins and other multi-child
+    // shapes, but also plain one-child nodes; positional unions and Project are exempt, already
+    // handled precisely above -- Project's own output legitimately omits a tainted attribute it
+    // dropped, which is not a leak). A tainted attribute a child contributes must either survive
+    // into the node's own output under the SAME expression ID or be consumed by one of the
+    // node's own expressions; otherwise decline. This catches two shapes: a multi-child node
+    // dropping the side carrying the tainted attribute (e.g. a LEFT SEMI/ANTI join), and a
+    // one-child WRITE SINK -- DataWritingCommandExec, WriteFilesExec, and the DSv2
+    // AppendDataExec/OverwriteByExpressionExec/... family (V2TableWriteExec) -- that executes
+    // its child purely for the side effect of persisting its rows and so has an EMPTY output of
+    // its own. Such a sink neither preserves the tainted attribute (nothing survives into an
+    // empty output) nor references it in an expression, so without this check it looks like an
+    // inert pass-through even though the write persists whatever value the reader returned,
+    // including a DV scan's dead synthetic row-index constant.
+    val childOutputLeak = plan.exists {
+      case u if isPositionalUnion(u) => false
+      case _: ProjectExec => false
+      case n if n.children.nonEmpty =>
+        n.children.exists { c =>
+          c.output.exists { attr =>
+            tainted.contains(attr.exprId) &&
+            !n.output.exists(_.exprId == attr.exprId) &&
+            !n.expressions.exists(_.references.exists(_.exprId == attr.exprId))
+          }
+        }
+      case _ => false
+    }
+    !nonProjectConsumer && !escapes && !childOutputLeak
+  }
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaSparkConfigProvider.scala b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaSparkConfigProvider.scala
new file mode 100644
index 0000000000..c0a4f5e0fd
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaSparkConfigProvider.scala
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import org.apache.comet.{CometConfigProvider, ConfigEntry}
+
+/**
+ * Exposes this contrib's config entries to `GenerateDocs`. Note: with the current module layout
+ * (`contrib/delta-spark` depends on `comet-spark`) the doc build cannot see this provider; it
+ * exists to satisfy the contrib-conf contract and becomes active if the module is ever folded
+ * into the spark build like `contrib/delta` is.
+ */
+class DeltaSparkConfigProvider extends CometConfigProvider {
+  override def configs: Seq[ConfigEntry[_]] = DeltaScanConf.all
+  override def docPage: String = "delta.md"
+  override def docCategory: String = "delta"
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaSparkScanEnvelope.scala b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaSparkScanEnvelope.scala
new file mode 100644
index 0000000000..5bfad727b2
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/comet/contrib/delta/DeltaSparkScanEnvelope.scala
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import org.apache.comet.serde.OperatorOuterClass
+import org.apache.comet.serde.OperatorOuterClass.Operator
+
+/**
+ * Packs and unpacks the JVM-planned `DeltaSparkScan` message in core's generic `ContribScan`
+ * envelope (`contrib_scan` on `Operator`). The native dispatcher routes by `type_url`, so this
+ * contrib's identifier is the only coupling between the JVM and native sides; core names no Delta
+ * type.
+ */
+object DeltaSparkScanEnvelope {
+
+  /**
+   * Contrib-owned identifier for the message, mirrored by `DELTA_SPARK_SCAN_TYPE_NAME` in
+   * native's `delta_spark_scan.rs`. Distinct from the kernel path's
+   * `comet.contrib.delta.DeltaScan`.
+   */
+  val TypeUrl = "type.googleapis.com/comet.contrib.delta_spark.DeltaSparkScan"
+
+  def pack(scan: OperatorOuterClass.DeltaSparkScan): OperatorOuterClass.ContribScan =
+    OperatorOuterClass.ContribScan
+      .newBuilder()
+      .setTypeUrl(TypeUrl)
+      .setValue(scan.toByteString)
+      .build()
+
+  /** Whether this operator carries this contrib's scan (and not some other contrib's). */
+  def matches(op: Operator): Boolean =
+    op.hasContribScan && op.getContribScan.getTypeUrl == TypeUrl
+
+  /** Callers must check `matches` first. */
+  def unpack(op: Operator): OperatorOuterClass.DeltaSparkScan =
+    OperatorOuterClass.DeltaSparkScan.parseFrom(op.getContribScan.getValue)
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/spark/sql/comet/CometDeltaNativeScanExec.scala b/contrib/delta-spark/src/main/scala/org/apache/spark/sql/comet/CometDeltaNativeScanExec.scala
new file mode 100644
index 0000000000..c1737172dd
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/spark/sql/comet/CometDeltaNativeScanExec.scala
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.spark.sql.comet
+
+import org.apache.spark.rdd.RDD
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.catalyst.plans.QueryPlan
+import org.apache.spark.sql.catalyst.plans.physical.{Partitioning, UnknownPartitioning}
+import org.apache.spark.sql.execution.{FileSourceScanExec, InSubqueryExec, ReusedSubqueryExec, ScalarSubquery, SparkPlan, SubqueryAdaptiveBroadcastExec}
+import org.apache.spark.sql.execution.datasources.HadoopFsRelation
+import org.apache.spark.sql.execution.metric.SQLMetric
+import org.apache.spark.sql.types.StructType
+import org.apache.spark.sql.vectorized.ColumnarBatch
+
+import org.apache.comet.contrib.delta.DeltaSparkScanEnvelope
+import org.apache.comet.serde.OperatorOuterClass
+import org.apache.comet.serde.OperatorOuterClass.Operator
+
+/**
+ * Native scan node for Delta Lake tables (contrib). Delta's own planning (log replay, snapshot
+ * resolution, partition pruning) has already run inside delta-spark by the time this node is
+ * created from the DSv1 [[FileSourceScanExec]]; file listing and split planning are delegated to
+ * a [[CometScanExec]] helper, and data reads execute through Comet's native DataFusion parquet
+ * machinery, inheriting row-group and page-index pruning.
+ *
+ * DPP: `runtimeFilters` is a constructor field included in equality, so its rewrite (via
+ * [[CometScanWithPlanData]]) survives plan copies -- a transient field would be dropped by
+ * `TreeNode.makeCopy` on MERGE re-planning (the CometIcebergNativeScanExec lesson).
+ */
+case class CometDeltaNativeScanExec(
+    override val nativeOp: Operator,
+    override val output: Seq[Attribute],
+    requiredSchema: StructType,
+    runtimeFilters: Seq[Expression],
+    dataFilters: Seq[Expression],
+    @transient relation: HadoopFsRelation,
+    originalPlan: FileSourceScanExec,
+    override val serializedPlanOpt: SerializedPlan,
+    sourceKey: String)
+    extends CometLeafExec
+    with CometScanWithPlanData {
+
+  override val nodeName: String = s"CometDeltaNativeScan $relation"
+
+  override def sparkFallback(newChildren: Seq[SparkPlan]): SparkPlan = {
+    // AQE rewrites DPP placeholders in runtimeFilters, not in originalPlan, so restore the scan
+    // with the live partition filters. dataFilters stays as Spark planned it: the live list also
+    // carries subquery filters harvested from the parent FilterExec.
+    val restoredScan = originalPlan.copy(partitionFilters = runtimeFilters)
+    originalPlan.logicalLink.foreach(restoredScan.setLogicalLink)
+    restoredScan
+  }
+
+  // Derived from (originalPlan, runtimeFilters), never stored: any copy of this node
+  // automatically gets a helper consistent with ITS runtimeFilters, avoiding the #3510 class of
+  // bug where a stored helper field desyncs from rewritten filters. Costs one extra file listing
+  // per executed instance; correctness over the duplicate driver-side listing.
+  //
+  // Forcing invariant: this lazy val is forced by the `metrics` override below, and AQE's UI
+  // plan-walk calls `.metrics` on every node MID-PLANNING, including while a DPP subquery is
+  // still an adaptive placeholder or a partition filter holds an unresolved ScalarSubquery (see
+  // `hasUnevaluableSubqueryFilter` below). That's safe ONLY because constructing `scanHelper` is a
+  // cheap case-class build with no file listing, and core's `CometScanExec.metrics` touches only
+  // `wrapped.driverMetrics` (populated by Spark's own planning) plus a static metric-node
+  // constructor -- neither file listing nor subquery resolution. If core's `metrics` ever touches
+  // either, forcing `scanHelper` here would resurrect the AQE mid-planning crashes this invariant
+  // prevents.
+  @transient private lazy val scanHelper: CometScanExec =
+    CometDeltaNativeScanExec.planningHelper(originalPlan, runtimeFilters)
+
+  // NOT lazy val: while a DPP subquery is still an adaptive placeholder, or a partition filter
+  // holds an unresolved scalar subquery, this returns a temporary value that must not be
+  // memoized -- after CometPlanAdaptiveDynamicPruningFilters rewrites the filters (DPP case) or
+  // AQE resolves the subquery (scalar case), later reads must see the real post-pruning
+  // partition count.
+  override def outputPartitioning: Partitioning =
+    if (hasUnevaluableSubqueryFilter) UnknownPartitioning(0)
+    else UnknownPartitioning(perPartitionData.length)
+
+  // runtimeFilters IS scanHelper.partitionFilters element-for-element, so checking runtimeFilters
+  // here avoids constructing/forcing the derived scanHelper just to read partitioning. The
+  // InSubqueryExec placeholder shapes mirror
+  // CometPlanAdaptiveDynamicPruningFilters.extractSABData + hasWrappedSAB -- keep in sync. The
+  // ScalarSubquery case is probed rather than treated as permanently unevaluable: Spark exposes no
+  // public finished/updated flag on ExecSubqueryExpression, but `eval()` doubles as one -- it only
+  // reads the cached `result` behind a `require(updated, ...)` guard, while the subquery is
+  // actually run by `updateResult()` (invoked separately during prepare/AQE), never by `eval()`.
+  // Once resolved, outputPartitioning below reports the real perPartitionData.length instead of
+  // staying at zero -- a fused native parent's buildNativeContext requires that count to match.
+  private def hasUnevaluableSubqueryFilter: Boolean =
+    runtimeFilters.exists(_.exists {
+      // Match `e: InSubqueryExec` and dispatch on e.plan rather than unapplying InSubqueryExec
+      // directly: its unapply arity differs across Spark versions and this module ships no
+      // version shim.
+      case e: InSubqueryExec => isAdaptivePlaceholder(e.plan)
+      case s: ScalarSubquery => !isScalarSubqueryResolved(s)
+      case _ => false
+    })
+
+  // `eval()` never triggers the subquery's execution: on a resolved subquery it is a pure cached
+  // read of `result` (verified against bytecode: `Predef.require(updated(), ...)` then a plain
+  // field read), so this probe is safe to call repeatedly, including from AQE's mid-planning plan
+  // walks. Pre-resolution, the ONLY throw is `require`'s `IllegalArgumentException`; catch exactly
+  // that, since anything else escaping is a genuine bug we must not mask as unpartitioned.
+  private def isScalarSubqueryResolved(s: ScalarSubquery): Boolean =
+    try {
+      s.eval()
+      true
+    } catch {
+      case _: IllegalArgumentException => false
+    }
+
+  private def isAdaptivePlaceholder(p: SparkPlan): Boolean = p match {
+    case ReusedSubqueryExec(inner) => isAdaptivePlaceholder(inner)
+    case _: CometSubqueryAdaptiveBroadcastExec => true
+    case _: SubqueryAdaptiveBroadcastExec => true
+    case _ => false
+  }
+
+  override lazy val outputOrdering: Seq[SortOrder] = originalPlan.outputOrdering
+
+  override def dynamicPruningFilters: Seq[Expression] = runtimeFilters
+
+  override def withDynamicPruningFilters(filters: Seq[Expression]): SparkPlan = {
+    // A real copy: runtimeFilters is a constructor field included in equality, so the copy
+    // survives enclosing-block rebuilds, and the derived scanHelper picks up the rewritten
+    // filters automatically.
+    copy(runtimeFilters = filters)
+  }
+
+  /**
+   * Lazy split-mode serialization, mirroring CometNativeScanExec: common data was serialized at
+   * planning; per-partition file lists serialize here, at execution time.
+   */
+  @transient private lazy val serializedPartitionData
+      : (Array[Byte], Array[Array[Byte]], Array[Seq[String]]) = {
+    // Resolve the helper's DPP subqueries: it holds its own InSubqueryExec instances that
+    // Spark's expressions walk does not see (the helper is derived, not a child).
+    scanHelper.partitionFilters.foreach {
+      case DynamicPruningExpression(e: InSubqueryExec) if e.values().isEmpty =>
+        e.updateResult()
+      case _ =>
+    }
+
+    val commonBytes = {
+      val deltaScan = DeltaSparkScanEnvelope.unpack(nativeOp)
+      // Scalar subqueries in dataFilters were unresolved at planning; resolve them now and
+      // append them as pushed filters, as CometNativeScanExec.serializedPartitionData does.
+      // has_data_filters follows their presence, not the serialized count: a filter that fails
+      // to serialize still keeps native on the safe timestamp conversion for a filtered scan.
+      val resolved = org.apache.comet.contrib.delta.CometDeltaNativeScan
+        .resolvedSubqueryFilters(dataFilters, output, requiredSchema, conf)
+      val common = if (!resolved.hasResolvedFilters) {
+        deltaScan.getCommon
+      } else {
+        val builder = deltaScan.getCommon.toBuilder
+        builder.setHasDataFilters(true)
+        resolved.protos.foreach(builder.addDataFilters)
+        builder.build()
+      }
+      OperatorOuterClass.DeltaSparkScan
+        .newBuilder()
+        .setCommon(common)
+        .setDeltaCommon(deltaScan.getDeltaCommon)
+        .build()
+        .toByteArray
+    }
+
+    val filePartitions = scanHelper.getFilePartitions()
+
+    val tableRoot = DeltaSparkScanEnvelope.unpack(nativeOp).getDeltaCommon.getTableRoot
+    val perPartitionBytes = filePartitions.map { filePartition =>
+      org.apache.comet.contrib.delta.CometDeltaNativeScan
+        .serializePartition(filePartition, originalPlan, tableRoot)
+    }.toArray
+
+    val perPartitionPaths = filePartitions.map(_.files.map(_.filePath.toString).toSeq).toArray
+
+    (commonBytes, perPartitionBytes, perPartitionPaths)
+  }
+
+  override def commonData: Array[Byte] = serializedPartitionData._1
+
+  override def perPartitionData: Array[Array[Byte]] = serializedPartitionData._2
+
+  def perPartitionFilePaths: Array[Seq[String]] = serializedPartitionData._3
+
+  override def doExecuteColumnar(): RDD[ColumnarBatch] = {
+    val nativeMetrics = CometMetricNode.fromCometPlan(this)
+    val serializedPlan = CometExec.serializeNativePlan(nativeOp)
+
+    new CometExecRDD(
+      sparkContext,
+      Seq.empty,
+      Map(sourceKey -> commonData),
+      Map(sourceKey -> perPartitionData),
+      serializedPlan,
+      PlanDataInjector.planFingerprint(serializedPlan),
+      perPartitionData.length,
+      output.length,
+      nativeMetrics,
+      Seq.empty,
+      None,
+      Seq.empty,
+      perPartitionFilePaths = perPartitionFilePaths,
+      outputTypes = output.map(_.dataType),
+      reportScanInputMetrics = true)
+  }
+
+  override def doCanonicalize(): CometDeltaNativeScanExec = {
+    val canonOriginal = if (originalPlan != null) {
+      val stripped = originalPlan.copy(partitionFilters =
+        CometScanUtils.filterUnusedDynamicPruningExpressions(originalPlan.partitionFilters))
+      stripped.doCanonicalize()
+    } else {
+      null
+    }
+    CometDeltaNativeScanExec(
+      nativeOp,
+      output.map(QueryPlan.normalizeExpressions(_, output)),
+      requiredSchema,
+      QueryPlan.normalizePredicates(
+        CometScanUtils.filterUnusedDynamicPruningExpressions(runtimeFilters),
+        output),
+      QueryPlan.normalizePredicates(dataFilters, output),
+      relation,
+      canonOriginal,
+      SerializedPlan(None),
+      "")
+  }
+
+  override def stringArgs: Iterator[Any] = Iterator(output, runtimeFilters)
+
+  override def equals(obj: Any): Boolean = obj match {
+    case other: CometDeltaNativeScanExec =>
+      this.originalPlan == other.originalPlan &&
+      this.serializedPlanOpt == other.serializedPlanOpt &&
+      this.runtimeFilters == other.runtimeFilters &&
+      this.dataFilters == other.dataFilters
+    case _ => false
+  }
+
+  override def hashCode(): Int =
+    java.util.Objects.hash(originalPlan, serializedPlanOpt, runtimeFilters, dataFilters)
+
+  private val driverMetricKeys =
+    Set(
+      "numFiles",
+      "filesSize",
+      "numPartitions",
+      "metadataTime",
+      "staticFilesNum",
+      "staticFilesSize",
+      "pruningTime")
+
+  // Forces `scanHelper` (see its doc above for why that -- and reading `.metrics` off it -- is
+  // safe even when AQE calls `.metrics` mid-planning against an unresolved DPP/scalar subquery).
+  override lazy val metrics: Map[String, SQLMetric] = {
+    CometMetricNode.nativeScanMetrics(session.sparkContext) ++
+      scanHelper.metrics.filter { case (k, _) => driverMetricKeys.contains(k) }
+  }
+}
+
+object CometDeltaNativeScanExec {
+
+  /**
+   * File-planning helper: reuses CometScanExec's listing/splitting/DPP machinery. Files with a
+   * deletion vector are split like any other file: a claimed scan requires Delta's reader
+   * optimizations to be enabled, which is exactly what DeltaParquetFileFormat.isSplitable
+   * returns, and Spark's row-index split gate does not apply to a claimed scan. Each split then
+   * fetches and decodes the whole deletion vector, reads the footer and admits memory against a
+   * bound for the whole file, but builds row selectors only for the row groups that start inside
+   * the split, which are the row groups the reader keeps, and shrinks the reservation it holds to
+   * those selectors plus the whole-file page-index allowance.
+   */
+  def planningHelper(
+      scanExec: FileSourceScanExec,
+      partitionFilters: Seq[Expression]): CometScanExec =
+    CometScanExec(
+      scanExec.relation,
+      scanExec.output,
+      scanExec.requiredSchema,
+      partitionFilters,
+      scanExec.optionalBucketSet,
+      scanExec.optionalNumCoalescedBuckets,
+      scanExec.dataFilters,
+      scanExec.tableIdentifier,
+      scanExec.disableBucketedScan,
+      scanExec)
+
+  def apply(
+      nativeOp: Operator,
+      scanExec: FileSourceScanExec,
+      subqueryDataFilters: Seq[Expression] = Seq.empty): CometDeltaNativeScanExec = {
+    // subqueryDataFilters: subquery predicates harvested from the covering FilterExec at claim
+    // time (Spark 3.x keeps them out of scanExec.dataFilters; see
+    // CometDeltaNativeScan.subqueryFiltersFromParent). Carried in dataFilters so the
+    // execution-time resolve-and-push path sees them; correctness never depends on them.
+    val exec = CometDeltaNativeScanExec(
+      nativeOp,
+      scanExec.output,
+      scanExec.requiredSchema,
+      scanExec.partitionFilters,
+      scanExec.dataFilters ++ subqueryDataFilters,
+      scanExec.relation,
+      scanExec,
+      SerializedPlan(None),
+      DeltaSparkScanEnvelope.unpack(nativeOp).getDeltaCommon.getSourceKey)
+    scanExec.logicalLink.foreach(exec.setLogicalLink)
+    exec
+  }
+}
diff --git a/contrib/delta-spark/src/main/scala/org/apache/spark/sql/comet/DeltaPlanDataInjector.scala b/contrib/delta-spark/src/main/scala/org/apache/spark/sql/comet/DeltaPlanDataInjector.scala
new file mode 100644
index 0000000000..6697b57bde
--- /dev/null
+++ b/contrib/delta-spark/src/main/scala/org/apache/spark/sql/comet/DeltaPlanDataInjector.scala
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.spark.sql.comet
+
+import scala.jdk.CollectionConverters._
+
+import org.apache.comet.contrib.delta.DeltaSparkScanEnvelope
+import org.apache.comet.serde.{OperatorOuterClass, QueryContextInterner}
+import org.apache.comet.serde.OperatorOuterClass.Operator
+
+/**
+ * PlanDataInjector for the Delta contrib scan, discovered by core's ServiceLoader (see the
+ * `META-INF/services` resource). Lives in this package because [[PlanDataInjector]] is
+ * `private[comet]`.
+ */
+class DeltaPlanDataInjector extends PlanDataInjector {
+
+  // The partition-invariant half of a DeltaSparkScan: common + delta_common, no file partition.
+  override type Prepared = OperatorOuterClass.DeltaSparkScan
+
+  override val opStructCase: Operator.OpStructCase = Operator.OpStructCase.CONTRIB_SCAN
+
+  override def canInject(op: Operator): Boolean =
+    DeltaSparkScanEnvelope.matches(op) && {
+      val scan = DeltaSparkScanEnvelope.unpack(op)
+      scan.hasCommon && !scan.hasFilePartition
+    }
+
+  override def getKey(op: Operator): Option[String] =
+    Some(DeltaSparkScanEnvelope.unpack(op).getDeltaCommon.getSourceKey)
+
+  // commonBytes is a DeltaSparkScan proto carrying common + delta_common (no file partition).
+  // Parsing it dominates inject() on wide schemas; injectPlanData memoizes the result per stage.
+  override def prepareCommon(commonBytes: Array[Byte]): Prepared =
+    OperatorOuterClass.DeltaSparkScan.parseFrom(commonBytes)
+
+  override def inject(op: Operator, common: Prepared, partitionBytes: Array[Byte]): Operator = {
+    // partitionBytes is a DeltaSparkScan proto carrying only this partition's file list.
+    val partitionOnly = OperatorOuterClass.DeltaSparkScan.parseFrom(partitionBytes)
+
+    val scanBuilder = OperatorOuterClass.DeltaSparkScan
+      .newBuilder()
+      .setCommon(common.getCommon)
+      .setDeltaCommon(common.getDeltaCommon)
+      .setFilePartition(partitionOnly.getFilePartition)
+
+    op.toBuilder.setContribScan(DeltaSparkScanEnvelope.pack(scanBuilder.build())).build()
+  }
+}
+
+object DeltaPlanDataInjector {
+
+  /**
+   * The key under which a Delta scan's planning data is stored and looked up. Written into
+   * `DeltaSparkScanCommon.source_key` on the driver and read back by
+   * [[DeltaPlanDataInjector.getKey]] on the executor, so both sides agree by construction.
+   * Mirrors `NativeScanPlanDataInjector.sourceKey` (source string carries the plan node id, so
+   * two scans of the same table in one plan, self-join, MERGE, get distinct keys), plus the table
+   * root for extra safety across tables with identical projections.
+   */
+  def sourceKey(tableRoot: String, common: OperatorOuterClass.NativeScanCommon): String = {
+    val dataFilters = common.getDataFiltersList.asScala
+      .map(QueryContextInterner.stripQueryContexts(_).toString)
+    val keyComponents = Seq(
+      tableRoot,
+      common.getRequiredSchemaList.toString,
+      dataFilters.mkString("[", ", ", "]"),
+      common.getProjectionVectorList.toString,
+      common.getFieldsList.toString)
+    s"delta_${common.getSource}_${keyComponents.mkString("|").hashCode}"
+  }
+}
diff --git a/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaDmlReproSuite.scala b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaDmlReproSuite.scala
new file mode 100644
index 0000000000..8aa1c0643e
--- /dev/null
+++ b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaDmlReproSuite.scala
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import scala.collection.mutable.ListBuffer
+
+import org.apache.spark.CometListenerBusUtils
+import org.apache.spark.sql.delta.DeltaLog
+import org.apache.spark.sql.execution.{FileSourceScanExec, QueryExecution, SparkPlan}
+import org.apache.spark.sql.util.QueryExecutionListener
+
+import org.apache.comet.ExtendedExplainInfo
+
+/**
+ * Repro for Delta's own DeletionVectorsSuite expectation: DELETE on a DV-enabled table must WRITE
+ * deletion vectors (not rewrite files) with Comet active. Mirrors "DELETE with DVs - on a table
+ * with no prior DVs".
+ */
+class CometDeltaDmlReproSuite extends CometDeltaTestBase {
+
+  /**
+   * Every [[SparkPlan]] Delta's own internal DataFrame actions executed during `body`, captured
+   * via a [[QueryExecutionListener]] rather than the outer statement's own plan: Delta's DML
+   * commands (DELETE/UPDATE/MERGE) drive `findTouchedFiles` through separate internal
+   * `collect`/`count` actions on their own [[QueryExecution]]s, invisible to `df.queryExecution`
+   * on the outer SQL statement.
+   */
+  private def capturePlansDuring(body: => Unit): Seq[SparkPlan] = {
+    val plans = ListBuffer.empty[SparkPlan]
+    val listener = new QueryExecutionListener {
+      override def onSuccess(funcName: String, qe: QueryExecution, durationNs: Long): Unit = {
+        plans += qe.executedPlan
+      }
+      override def onFailure(
+          funcName: String,
+          qe: QueryExecution,
+          exception: Exception): Unit = {}
+    }
+    spark.listenerManager.register(listener)
+    try {
+      body
+      // The listener bus delivers asynchronously, so the plans are not all in hand until it has
+      // drained.
+      CometListenerBusUtils.waitUntilEmpty(spark.sparkContext)
+    } finally {
+      spark.listenerManager.unregister(listener)
+    }
+    plans.toSeq
+  }
+
+  test(
+    "DELETE's internal deletion-vector-generating scan declines the row-index-outside-a-DV-" +
+      "scan reason (the read-side counterpart of the DV-write repro above)") {
+    withSQLConf("spark.databricks.delta.properties.defaults.enableDeletionVectors" -> "true") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        spark.range(0, 1000, 1, 4).write.format("delta").save(path)
+
+        val capturedPlans = capturePlansDuring {
+          spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0 AND id < 200")
+        }
+
+        // Before writing a deletion vector, DELETE must first learn WHICH rows matched the
+        // predicate, so it reads each candidate file's `_metadata.row_index` directly (a bare
+        // row-index column, with no `is_row_deleted` alongside it -- unlike a normal DV-applying
+        // read, no existing DV is applied to this scan, since the very DV being computed does not
+        // exist yet). DeltaScanSupport.declineReason's hasRowIndex-without-hasIsRowDeleted gate
+        // exists precisely to keep this bookkeeping scan on Spark's reader: claiming it with a
+        // dead constant row-index would feed wrong (constant) row indexes into the DV this DELETE
+        // is trying to build. This must remain a plain Spark FileSourceScanExec here, never a
+        // CometDeltaNativeScanExec.
+        val declinedRowIndexScans = capturedPlans.flatMap { plan =>
+          collectWithSubqueries(stripAQEPlan(plan)) {
+            case f: FileSourceScanExec
+                if DeltaScanSupport.isDeltaScan(f) &&
+                  f.requiredSchema.exists(_.name == CometDeltaNativeScan.RowIndexColumn) &&
+                  !f.requiredSchema.exists(_.name == CometDeltaNativeScan.IsRowDeletedColumn) =>
+              f
+          }
+        }
+        assert(
+          declinedRowIndexScans.nonEmpty,
+          "expected to observe at least one internal row-index-only scan while DELETE " +
+            "computed which rows to mark in the new deletion vector")
+
+        val reasons =
+          declinedRowIndexScans.flatMap(f => new ExtendedExplainInfo().getFallbackReasons(f))
+        assert(
+          reasons.exists(_.contains("row-index reads outside a deletion-vector scan")),
+          "expected the internal row-index scan to carry the row-index-outside-a-DV-scan " +
+            s"decline reason, got: ${reasons.mkString(", ")}")
+
+        val log = DeltaLog.forTable(spark, path)
+        val withDvs = log.update().allFiles.collect().count(_.deletionVector != null)
+        assert(withDvs > 0, s"expected at least one file to have a DV written, got $withDvs")
+        assert(spark.read.format("delta").load(path).count() == 900)
+      }
+    }
+  }
+
+  test("DELETE writes DVs with useMetadataRowIndex=true (metadata row-index DML shape)") {
+    withSQLConf(
+      "spark.databricks.delta.properties.defaults.enableDeletionVectors" -> "true",
+      "spark.databricks.delta.deletionVectors.useMetadataRowIndex" -> "true") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        spark.range(0, 1000, 1, 500).write.format("delta").save(path)
+        spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0 AND id < 200")
+
+        val log = DeltaLog.forTable(spark, path)
+        val withDvs = log.update().allFiles.collect().count(_.deletionVector != null)
+        assert(withDvs == 100, s"expected 100 files with DVs, got $withDvs")
+        assert(spark.read.format("delta").load(path).count() == 900)
+      }
+    }
+  }
+
+  test("DELETE writes DVs rather than rewriting files") {
+    withSQLConf(
+      "spark.databricks.delta.properties.defaults.enableDeletionVectors" -> "true",
+      "spark.databricks.delta.delete.deletionVectors.persistent" -> "true") {
+      withTempDir { base =>
+        // Mirror Delta's DeletionVectorsTestUtils: paths with spaces and a literal %2a.
+        val dir = new java.io.File(base, "s p a r k %2a")
+        val path = dir.getAbsolutePath
+        spark.range(0, 1000, 1, 500).write.format("delta").save(path)
+        spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0 AND id < 200")
+
+        val log = DeltaLog.forTable(spark, path)
+        val files = log.update().allFiles.collect()
+        val withDvs = files.count(_.deletionVector != null)
+        assert(files.length == 500, s"expected 500 files, got ${files.length}")
+        assert(withDvs == 100, s"expected 100 files with DVs, got $withDvs")
+        assert(spark.read.format("delta").load(path).count() == 900)
+      }
+    }
+  }
+}
diff --git a/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaNativeScanSuite.scala b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaNativeScanSuite.scala
new file mode 100644
index 0000000000..3b82cb3265
--- /dev/null
+++ b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaNativeScanSuite.scala
@@ -0,0 +1,3952 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import java.io.File
+
+import scala.collection.mutable
+import scala.collection.mutable.ListBuffer
+
+import org.apache.spark.CometListenerBusUtils
+import org.apache.spark.scheduler.{SparkListener, SparkListenerTaskEnd}
+import org.apache.spark.sql.{DataFrame, Row}
+import org.apache.spark.sql.catalyst.expressions.{AttributeReference, DynamicPruningExpression, Expression, NamedExpression, StructsToJson}
+import org.apache.spark.sql.comet.{CometDeltaNativeScanExec, CometSubqueryBroadcastExec}
+import org.apache.spark.sql.execution.{FileSourceScanExec, InSubqueryExec, QueryExecution, ReusedSubqueryExec, ScalarSubquery, SparkPlan, SubqueryBroadcastExec, SubqueryExec}
+import org.apache.spark.sql.execution.datasources.v2.V2TableWriteExec
+import org.apache.spark.sql.functions.{col, lit, to_json}
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.sql.types.{ByteType, LongType, StringType, StructField, StructType}
+import org.apache.spark.sql.util.QueryExecutionListener
+
+import org.apache.comet.CometConf
+import org.apache.comet.CometSparkSessionExtensions.{isSpark35Plus, isSpark40Plus}
+import org.apache.comet.ExtendedExplainInfo
+import org.apache.comet.serde.OperatorOuterClass
+import org.apache.comet.serde.operator.CometNativeScan
+
+/**
+ * Differential suite: append-only Delta tables read through the native Delta scan must produce
+ * results identical to Spark's Delta reader, engage the native operator, and prune at row-group
+ * and page level.
+ */
+class CometDeltaNativeScanSuite extends CometDeltaTestBase {
+
+  test("plain delta table reads natively with identical results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 1000)
+        .selectExpr("id", "id * 2 as v", "cast(id as string) as s")
+        .write
+        .format("delta")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path).filter(col("id") > 500)
+      checkDeltaNativeScanAnswer(df)
+    }
+  }
+
+  test("projection and filter on delta table") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 1000)
+        .selectExpr("id", "id % 10 as bucket", "cast(id as double) as d")
+        .write
+        .format("delta")
+        .save(path)
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .select("bucket", "d")
+        .filter(col("d") < 100.0)
+      checkDeltaNativeScanAnswer(df)
+    }
+  }
+
+  test("partitioned delta table with partition filter") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 1000)
+        .selectExpr("id", "id % 7 as p")
+        .write
+        .format("delta")
+        .partitionBy("p")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path).filter(col("p") === 3)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() > 0)
+    }
+  }
+
+  test("multi-file delta table after several appends") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      for (i <- 0 until 4) {
+        spark
+          .range(i * 100L, (i + 1) * 100L)
+          .selectExpr("id", "id * 3 as v")
+          .write
+          .format("delta")
+          .mode("append")
+          .save(path)
+      }
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 400)
+    }
+  }
+
+  test("time travel VERSION AS OF reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+      spark.range(100, 200).write.format("delta").mode("append").save(path)
+
+      val v0 = spark.read.format("delta").option("versionAsOf", 0).load(path)
+      checkDeltaNativeScanAnswer(v0)
+      assert(v0.count() == 100)
+    }
+  }
+
+  test("selective predicate prunes row groups and pages") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // Small row groups + page-level stats: sorted data so min/max stats are tight. The Delta
+      // writer ignores parquet.* DataFrameWriter options, so set them on the Hadoop conf.
+      val hadoopConf = spark.sparkContext.hadoopConfiguration
+      val oldBlockSize = hadoopConf.get("parquet.block.size")
+      val oldPageSize = hadoopConf.get("parquet.page.size")
+      hadoopConf.setInt("parquet.block.size", 256 * 1024)
+      hadoopConf.setInt("parquet.page.size", 16 * 1024)
+      try {
+        spark
+          .range(0, 500000)
+          .selectExpr("id", "id * 2 as v")
+          .sort("id")
+          .coalesce(1)
+          .write
+          .format("delta")
+          .save(path)
+      } finally {
+        if (oldBlockSize == null) hadoopConf.unset("parquet.block.size")
+        else hadoopConf.set("parquet.block.size", oldBlockSize)
+        if (oldPageSize == null) hadoopConf.unset("parquet.page.size")
+        else hadoopConf.set("parquet.page.size", oldPageSize)
+      }
+
+      def query = spark.read
+        .format("delta")
+        .load(path)
+        .filter(col("id") >= 100 && col("id") < 200)
+      checkDeltaNativeScanAnswer(query)
+
+      // checkSparkAnswer re-plans the query, so read metrics from a DataFrame we execute
+      // ourselves (collect() runs THIS Dataset's queryExecution; count() would plan a new one):
+      // its executed plan holds the metric objects native execution updated.
+      val df = query
+      assert(df.collect().length == 100)
+      val scans = deltaNativeScans(df)
+      assert(scans.size == 1)
+      val metrics = scans.head.metrics
+      val rowGroupsPruned = metrics.get("row_groups_pruned_statistics").map(_.value).getOrElse(0L)
+      val pagesPruned = metrics.get("page_index_rows_pruned").map(_.value).getOrElse(0L)
+      assert(
+        rowGroupsPruned > 0,
+        s"expected row-group pruning; metrics: ${metrics.map { case (k, v) => s"$k=${v.value}" }}")
+      assert(
+        pagesPruned > 0,
+        s"expected page-index pruning; metrics: ${metrics.map { case (k, v) =>
+            s"$k=${v.value}"
+          }}")
+    }
+  }
+
+  test("scalar subquery data filter is pushed down and prunes row groups and pages") {
+    withTempPath { dir =>
+      val path = s"${dir.getAbsolutePath}/data"
+      val thresholds = s"${dir.getAbsolutePath}/thresholds"
+      // Same layout as the selective-predicate test: small row groups + tight page stats.
+      val hadoopConf = spark.sparkContext.hadoopConfiguration
+      val oldBlockSize = hadoopConf.get("parquet.block.size")
+      val oldPageSize = hadoopConf.get("parquet.page.size")
+      hadoopConf.setInt("parquet.block.size", 256 * 1024)
+      hadoopConf.setInt("parquet.page.size", 16 * 1024)
+      try {
+        spark
+          .range(0, 500000)
+          .selectExpr("id", "id * 2 as v")
+          .sort("id")
+          .coalesce(1)
+          .write
+          .format("delta")
+          .save(path)
+      } finally {
+        if (oldBlockSize == null) hadoopConf.unset("parquet.block.size")
+        else hadoopConf.set("parquet.block.size", oldBlockSize)
+        if (oldPageSize == null) hadoopConf.unset("parquet.page.size")
+        else hadoopConf.set("parquet.page.size", oldPageSize)
+      }
+      spark
+        .sql("SELECT CAST(100 AS BIGINT) AS lo, CAST(200 AS BIGINT) AS hi")
+        .write
+        .format("delta")
+        .save(thresholds)
+
+      // Scalar subqueries are PlanExpressions: unresolved at planning, so the bounds can
+      // only reach the native reader via the execution-time resolve-and-append path.
+      def query = spark.sql(
+        s"SELECT * FROM delta.`$path` WHERE id >= (SELECT lo FROM delta.`$thresholds`) " +
+          s"AND id < (SELECT hi FROM delta.`$thresholds`)")
+      checkDeltaNativeScanAnswer(query)
+
+      val df = query
+      assert(df.collect().length == 100)
+      // The thresholds table inside the subquery is also claimed natively; pick the
+      // main data-table scan by its output.
+      assertSubqueryFilterPushed(df, dataColumn = "v")
+      val scans = deltaNativeScans(df).filter(_.output.exists(_.name == "v"))
+      assert(scans.size == 1)
+      val metrics = scans.head.metrics
+      val rowGroupsPruned = metrics.get("row_groups_pruned_statistics").map(_.value).getOrElse(0L)
+      val pagesPruned = metrics.get("page_index_rows_pruned").map(_.value).getOrElse(0L)
+      assert(
+        rowGroupsPruned > 0,
+        s"expected row-group pruning from the resolved subquery bounds; metrics: ${metrics.map {
+            case (k, v) => s"$k=${v.value}"
+          }}")
+      assert(
+        pagesPruned > 0,
+        s"expected page-index pruning from the resolved subquery bounds; metrics: ${metrics.map {
+            case (k, v) => s"$k=${v.value}"
+          }}")
+    }
+  }
+
+  test("deletion vectors: scalar subquery filter composes with DV application") {
+    withTempPath { dir =>
+      val path = s"${dir.getAbsolutePath}/data"
+      val thresholds = s"${dir.getAbsolutePath}/thresholds"
+      createDvTable(path, rows = 10000)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+      spark
+        .sql("SELECT CAST(5000 AS BIGINT) AS lo")
+        .write
+        .format("delta")
+        .save(thresholds)
+
+      def query =
+        spark.sql(s"SELECT * FROM delta.`$path` WHERE id >= (SELECT lo FROM delta.`$thresholds`)")
+      checkDeltaNativeScanAnswer(query)
+      // Deleted rows must stay deleted with the pushed bound applied in-scan.
+      val df = query
+      val rows = df.collect()
+      assert(rows.length == 2500)
+      assert(rows.forall(r => r.getLong(0) % 2 == 1 && r.getLong(0) >= 5000))
+      assertSubqueryFilterPushed(df, dataColumn = "v")
+    }
+  }
+
+  test("column mapping: scalar subquery filter on a renamed column") {
+    withTempPath { dir =>
+      val path = s"${dir.getAbsolutePath}/data"
+      val thresholds = s"${dir.getAbsolutePath}/thresholds"
+      spark.range(0, 1000).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      enableColumnMapping(path)
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN v TO w")
+      spark
+        .sql("SELECT CAST(900 AS BIGINT) AS lo")
+        .write
+        .format("delta")
+        .save(thresholds)
+
+      // The pushed filter references the renamed column: it must bind against the
+      // physical read schema, not the logical name.
+      def query =
+        spark.sql(s"SELECT * FROM delta.`$path` WHERE w >= (SELECT lo FROM delta.`$thresholds`)")
+      checkDeltaNativeScanAnswer(query)
+      val df = query
+      assert(df.collect().length == 550)
+      assertSubqueryFilterPushed(df, dataColumn = "w")
+    }
+  }
+
+  /**
+   * Assert the resolved scalar-subquery bound was actually appended to the native scan's
+   * execution-time common data (answers alone cannot show this: Spark's covering FilterExec would
+   * mask a silently-skipped pushdown). `df` must already have been executed.
+   */
+  private def assertSubqueryFilterPushed(df: DataFrame, dataColumn: String): Unit = {
+    val scans = deltaNativeScans(df).collect {
+      case s: CometDeltaNativeScanExec if s.output.exists(_.name == dataColumn) => s
+    }
+    assert(scans.size == 1)
+    val scan = scans.head
+    val planTimeFilters =
+      DeltaSparkScanEnvelope.unpack(scan.nativeOp).getCommon.getDataFiltersCount
+    val executedFilters = OperatorOuterClass.DeltaSparkScan
+      .parseFrom(scan.commonData)
+      .getCommon
+      .getDataFiltersCount
+    assert(
+      executedFilters > planTimeFilters,
+      "expected resolved subquery filters appended at execution: " +
+        s"plan-time=$planTimeFilters executed=$executedFilters " +
+        s"dataFilters=${scan.dataFilters.mkString("; ")}")
+  }
+
+  test("scalar subquery filter is NOT pushed below a limit") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 3).selectExpr("id").write.format("delta").save(path)
+      spark.read.format("delta").load(path).createOrReplaceTempView("t_limit_pushdown")
+
+      val df = spark.sql(
+        "SELECT id FROM (SELECT id FROM t_limit_pushdown ORDER BY id LIMIT 1) q " +
+          "WHERE id > (SELECT max(id) FROM range(1))")
+      checkSparkAnswer(df)
+      assert(df.collect().isEmpty)
+      assertNoSubqueryFilterPushed(df)
+    }
+  }
+
+  test("scalar subquery filter is NOT pushed across a nondeterministic projection") {
+    withSQLConf(CometConf.COMET_PARQUET_ROW_FILTER_PUSHDOWN_ENABLED.key -> "true") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        spark.range(0, 5).coalesce(1).write.format("delta").save(path)
+        spark.read.format("delta").load(path).createOrReplaceTempView("t_monotonic_id")
+
+        // A deterministic conjunct does not commute with a nondeterministic projection: the
+        // subquery bound must not be pushed into the scan below `seq`, or the surviving rows'
+        // monotonically_increasing_id() values change and the answer is wrong.
+        val df = spark.sql(
+          "SELECT id FROM (SELECT id, monotonically_increasing_id() AS seq " +
+            "FROM t_monotonic_id) q WHERE id > (SELECT max(id) FROM range(1)) AND seq = 1")
+        checkSparkAnswer(df)
+        assert(df.collect().toSeq == Seq(Row(1)))
+        assertNoSubqueryFilterPushed(df)
+      }
+    }
+  }
+
+  /**
+   * Assert no scalar-subquery filter was harvested and pushed into the native scan's
+   * execution-time common data: the scan must sit below a non-commuting operator (e.g. LIMIT /
+   * TopN), so the covering FilterExec's predicate must stay above it rather than move into the
+   * scan. Also confirms the query still engaged the native Delta scan, i.e. this exercises the
+   * commutativity guard rather than a plan that fell back to Spark entirely. `df` must already
+   * have been executed.
+   */
+  private def assertNoSubqueryFilterPushed(df: DataFrame): Unit = {
+    val scans = deltaNativeScans(df).collect { case s: CometDeltaNativeScanExec => s }
+    assert(scans.size == 1, s"expected exactly one native Delta scan; found ${scans.size}")
+    val scan = scans.head
+    val planTimeFilters =
+      DeltaSparkScanEnvelope.unpack(scan.nativeOp).getCommon.getDataFiltersCount
+    val executedFilters = OperatorOuterClass.DeltaSparkScan
+      .parseFrom(scan.commonData)
+      .getCommon
+      .getDataFiltersCount
+    assert(
+      executedFilters == planTimeFilters,
+      "expected no subquery filter pushed across the non-commuting operator between the " +
+        s"covering filter and the scan: plan-time=$planTimeFilters executed=$executedFilters " +
+        s"dataFilters=${scan.dataFilters.mkString("; ")}")
+  }
+
+  test("scalar subquery filter rejected by serde still marks the scan as filtered") {
+    withTempPath { dir =>
+      val path = s"${dir.getAbsolutePath}/data"
+      val bounds = s"${dir.getAbsolutePath}/bounds"
+      spark.range(0, 100).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      spark.sql("SELECT CAST(42 AS BIGINT) AS lo").write.format("delta").save(bounds)
+
+      // With EqualNullSafe disabled the resolved bound cannot serialize, yet the scan must still
+      // carry has_data_filters so native treats it as a filtered read, exactly like core does.
+      withSQLConf("spark.comet.expression.EqualNullSafe.enabled" -> "false") {
+        def query =
+          spark.sql(
+            s"SELECT * FROM delta.`$path` WHERE id <=> (SELECT max(lo) FROM delta.`$bounds`)")
+        checkDeltaNativeScanAnswer(query)
+        val df = query
+        assert(df.collect().toSeq == Seq(Row(42L, 84L)))
+        assertUnserializedSubqueryFilterMarksScanFiltered(df, dataColumn = "v")
+      }
+    }
+  }
+
+  test("unserializable scalar subquery filter keeps the safe TIMESTAMP_MILLIS conversion") {
+    // Same fixture as core's "filtered TIMESTAMP_MILLIS scans do not convert values Spark can
+    // skip": a raw file whose only overflowing millisecond value Spark prunes from the footer
+    // statistics once the resolved bound is pushed, so native must not convert it either.
+    withTempPath { dir =>
+      val path = s"${dir.getAbsolutePath}/data"
+      val bounds = s"${dir.getAbsolutePath}/bounds"
+      writeRawParquetFile(
+        path,
+        """message root {
+          |  optional int32 id;
+          |  optional int64 ts(TIMESTAMP_MILLIS);
+          |}""".stripMargin) { factory =>
+        (1 to 16).map(id => factory.newGroup().append("id", id).append("ts", 1717243200000L)) :+
+          factory.newGroup().append("id", 17).append("ts", 9223372036854776L)
+      }
+      spark.sql(s"CONVERT TO DELTA parquet.`$path` NO STATISTICS")
+      spark.sql("SELECT timestamp_seconds(0) AS bound").write.format("delta").save(bounds)
+
+      withSQLConf(
+        "spark.comet.expression.EqualNullSafe.enabled" -> "false",
+        "spark.sql.parquet.datetimeRebaseModeInRead" -> "CORRECTED",
+        "spark.sql.parquet.int96RebaseModeInRead" -> "CORRECTED") {
+        def query = spark.sql(
+          s"SELECT id, ts FROM delta.`$path` " +
+            s"WHERE ts <=> (SELECT max(bound) FROM delta.`$bounds`)")
+        // Spark 3.x never pushes subquery filters into its parquet reader and converts the
+        // overflowing value itself, so the answer comparison is meaningful on Spark 4.0+ only.
+        if (isSpark40Plus) {
+          checkDeltaNativeScanAnswer(query)
+        }
+        val df = query
+        assert(df.collect().isEmpty)
+        assert(
+          deltaNativeScans(df).nonEmpty,
+          s"expected a native Delta scan:\n${df.queryExecution}")
+        assertUnserializedSubqueryFilterMarksScanFiltered(df, dataColumn = "ts")
+      }
+    }
+  }
+
+  /**
+   * Assert the execution-time common data of the scan producing `dataColumn` reports
+   * `has_data_filters` with no serialized data filter: the plan-time proto carries neither, and
+   * the resolved subquery filter is the only data filter, so only the execution-time path can set
+   * the bit. `df` must already have been executed.
+   */
+  private def assertUnserializedSubqueryFilterMarksScanFiltered(
+      df: DataFrame,
+      dataColumn: String): Unit = {
+    val scans = deltaNativeScans(df).collect {
+      case s: CometDeltaNativeScanExec if s.output.exists(_.name == dataColumn) => s
+    }
+    assert(scans.size == 1, s"expected exactly one native Delta scan; found ${scans.size}")
+    val scan = scans.head
+    assert(
+      scan.dataFilters.exists(_.exists(_.isInstanceOf[ScalarSubquery])),
+      s"expected a scalar subquery data filter: ${scan.dataFilters.mkString("; ")}")
+    val planTime = DeltaSparkScanEnvelope.unpack(scan.nativeOp).getCommon
+    assert(!planTime.getHasDataFilters && planTime.getDataFiltersCount == 0)
+    val executed = OperatorOuterClass.DeltaSparkScan.parseFrom(scan.commonData).getCommon
+    assert(
+      executed.getHasDataFilters,
+      "expected has_data_filters at execution even though the resolved subquery filter did " +
+        s"not serialize: dataFilters=${scan.dataFilters.mkString("; ")}")
+    assert(executed.getDataFiltersCount == 0)
+  }
+
+  test("aggregation over delta table") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 10000)
+        .selectExpr("id", "id % 13 as g", "id * 2 as v")
+        .write
+        .format("delta")
+        .save(path)
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .groupBy("g")
+        .sum("v")
+      checkDeltaNativeScanAnswer(df)
+    }
+  }
+
+  test("conf disables the native delta scan") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      withSQLConf(DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key -> "false") {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswer(df)
+        assert(deltaNativeScans(df).isEmpty)
+      }
+    }
+  }
+
+  test("native delta scan is opt-in: disabled when the conf is not set") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      // The suite base enables the scan globally; drop the key entirely to
+      // observe the out-of-the-box default.
+      spark.conf.unset(DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key)
+      try {
+        assert(!DeltaScanConf.scanEnabled)
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswer(df)
+        assert(deltaNativeScans(df).isEmpty)
+      } finally {
+        spark.conf.set(DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key, "true")
+      }
+    }
+  }
+
+  test("table root under a directory whose name contains a newline falls back to Spark") {
+    // object_store recognizes the `file` scheme but rejects the control character in the
+    // directory name (`%0A` in the URI), so native execution could not open the table where
+    // Spark's Hadoop-backed reader can. The claim gate must decline before native planning.
+    withTempPath { dir =>
+      val path = new File(new File(dir, "dir\n"), "data").getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      val df = spark.read.format("delta").load(path)
+      assert(
+        deltaNativeScans(df).isEmpty,
+        "Expected no native Delta scan under a newline directory:\n" +
+          s"${df.queryExecution.executedPlan}")
+      checkSparkAnswerAndFallbackReason(
+        df,
+        "Native Delta scan cannot open path 'file:" + dir.getAbsolutePath +
+          "/dir%0A/data': object_store rejects it")
+    }
+  }
+
+  test("shallow clone whose source data files sit under a newline directory falls back") {
+    // The clone's own root is an ordinary path, so only the selected data files (resolved to
+    // the source table's directory) carry the rejected segment: this exercises the
+    // selected-paths probe, not the root gate. The reason names the first such complete path,
+    // a data file under the source directory.
+    withTempPath { dir =>
+      val sourcePath = new File(new File(dir, "dir\n"), "source").getAbsolutePath
+      val clonePath = new File(dir, "clone").getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(sourcePath)
+      spark.sql(s"CREATE TABLE delta.`$clonePath` SHALLOW CLONE delta.`$sourcePath`")
+
+      val df = spark.read.format("delta").load(clonePath)
+      assert(
+        deltaNativeScans(df).isEmpty,
+        "Expected no native Delta scan for a clone of a newline-directory source:\n" +
+          s"${df.queryExecution.executedPlan}")
+      checkSparkAnswerAndFallbackReason(
+        df,
+        "Native Delta scan cannot open path 'file:" + dir.getAbsolutePath +
+          "/dir%0A/source/")
+    }
+  }
+
+  test("converted Parquet table with a newline in a data file basename falls back to Spark") {
+    // CONVERT TO DELTA keeps the existing Parquet file names, so the rejected character sits in
+    // the basename rather than a directory segment: the table root and every parent directory
+    // pass the path probe, and only a check of the complete selected path can decline.
+    withTempPath { dir =>
+      val path = new File(dir, "data").getAbsolutePath
+      spark.range(0, 100).repartition(2).write.parquet(path)
+      val original = new File(path).listFiles().filter(_.getName.endsWith(".parquet")).head
+      val renamed = new File(path, "part-00000\n.snappy.parquet")
+      java.nio.file.Files.move(original.toPath, renamed.toPath)
+      spark.sql(s"CONVERT TO DELTA parquet.`$path`")
+
+      val df = spark.read.format("delta").load(path)
+      assert(
+        deltaNativeScans(df).isEmpty,
+        "Expected no native Delta scan for a converted table with a newline basename:\n" +
+          s"${df.queryExecution.executedPlan}")
+      checkSparkAnswerAndFallbackReason(
+        df,
+        s"Native Delta scan cannot open path 'file:$path/part-00000%0A.snappy.parquet': " +
+          "object_store rejects it")
+    }
+  }
+
+  private def createDvTable(path: String, rows: Long = 1000): Unit = {
+    spark.range(0, rows).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+    spark.sql(
+      s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+  }
+
+  /**
+   * Same shape as `createDvTable`, plus one extra TINYINT column (value 7) under `columnName`.
+   */
+  private def createDvTableWithExtraColumn(
+      path: String,
+      columnName: String,
+      rows: Long = 1000): Unit = {
+    spark
+      .range(0, rows)
+      .selectExpr("id", s"cast(7 as tinyint) as `$columnName`")
+      .write
+      .format("delta")
+      .save(path)
+    spark.sql(
+      s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+  }
+
+  test("deletion vectors: DELETE-produced DVs read natively with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 500)
+    }
+  }
+
+  test(
+    "deletion vectors: user column named like the synthetic internal-column slot keeps its " +
+      "own values") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      val collidingName = "_comet_delta___delta_internal_is_row_deleted"
+      createDvTableWithExtraColumn(path, collidingName)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id = 0")
+
+      val df = spark.read.format("delta").load(path).select("id", collidingName)
+      checkDeltaNativeScanAnswer(df)
+      val survivingValues = df.collect().map(_.getAs[Byte](collidingName)).distinct
+      assert(
+        survivingValues.sameElements(Array(7.toByte)),
+        "expected the user column's own value (7) to survive DV filtering, " +
+          s"got ${survivingValues.toSeq}")
+    }
+  }
+
+  test("deletion vectors: normally named extra column alongside DVs reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTableWithExtraColumn(path, "tag")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id = 0")
+
+      val df = spark.read.format("delta").load(path).select("id", "tag")
+      checkDeltaNativeScanAnswer(df)
+      val survivingValues = df.collect().map(_.getAs[Byte]("tag")).distinct
+      assert(
+        survivingValues.sameElements(Array(7.toByte)),
+        "expected the extra column's value (7) to survive DV filtering, got " +
+          survivingValues.toSeq)
+    }
+  }
+
+  test("deletion vectors: UPDATE-produced DVs read natively with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"UPDATE delta.`$path` SET v = -1 WHERE id < 100")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.filter(col("v") === -1).count() == 100)
+      assert(df.count() == 1000)
+    }
+  }
+
+  test("deletion vectors: multiple DELETEs accumulate correctly") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 3 = 0")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      // odd ids not divisible by 3
+      assert(df.count() == (0L until 1000L).count(i => i % 2 != 0 && i % 3 != 0))
+    }
+  }
+
+  test(
+    "deletion vectors: maxDeletedRowsPerFile budget declines an oversized DV and " +
+      "claims once raised") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // repartition(4) guarantees >= 2 physical files so the per-file cardinality gate has
+      // more than one file to inspect.
+      spark
+        .range(0, 1000)
+        .selectExpr("id", "id * 2 as v")
+        .repartition(4)
+        .write
+        .format("delta")
+        .save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      withSQLConf(DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.key -> "1") {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswer(df)
+        assert(
+          deltaNativeScans(df).isEmpty,
+          "a budget of 1 deleted row per file must decline every DV-bearing file")
+      }
+
+      withSQLConf(DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.key -> "1000000") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+      }
+    }
+  }
+
+  test("deletion vectors: maxDeletedRowsPerFile decline reason names the conf key") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      withSQLConf(DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.key -> "1") {
+        checkSparkAnswerAndFallbackReason(
+          spark.read.format("delta").load(path),
+          DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.key)
+      }
+    }
+  }
+
+  test("deletion vectors: fully-deleted region and selective predicate still prune pages") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      val hadoopConf = spark.sparkContext.hadoopConfiguration
+      val oldBlockSize = hadoopConf.get("parquet.block.size")
+      val oldPageSize = hadoopConf.get("parquet.page.size")
+      hadoopConf.setInt("parquet.block.size", 256 * 1024)
+      hadoopConf.setInt("parquet.page.size", 16 * 1024)
+      try {
+        spark
+          .range(0, 500000)
+          .selectExpr("id", "id * 2 as v")
+          .sort("id")
+          .coalesce(1)
+          .write
+          .format("delta")
+          .save(path)
+      } finally {
+        if (oldBlockSize == null) hadoopConf.unset("parquet.block.size")
+        else hadoopConf.set("parquet.block.size", oldBlockSize)
+        if (oldPageSize == null) hadoopConf.unset("parquet.page.size")
+        else hadoopConf.set("parquet.page.size", oldPageSize)
+      }
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      // Delete a slice inside the predicate range and a large slice outside it.
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id >= 150 AND id < 160")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id >= 300000")
+
+      def query = spark.read
+        .format("delta")
+        .load(path)
+        .filter(col("id") >= 100 && col("id") < 200)
+      checkDeltaNativeScanAnswer(query)
+
+      val df = query
+      assert(df.collect().length == 90)
+      val scans = deltaNativeScans(df)
+      assert(scans.size == 1)
+      val metrics = scans.head.metrics
+      val pagesPruned = metrics.get("page_index_rows_pruned").map(_.value).getOrElse(0L)
+      assert(
+        pagesPruned > 0,
+        s"expected page-index pruning to compose with DVs; metrics: ${metrics.map { case (k, v) =>
+            s"$k=${v.value}"
+          }}")
+    }
+  }
+
+  test("deletion vectors: one file split into many byte ranges reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // One file made of many small row groups, so a small maxPartitionBytes below turns it
+      // into many splits that each cover a few row groups.
+      val hadoopConf = spark.sparkContext.hadoopConfiguration
+      val oldBlockSize = hadoopConf.get("parquet.block.size")
+      val oldPageSize = hadoopConf.get("parquet.page.size")
+      hadoopConf.setInt("parquet.block.size", 16 * 1024)
+      hadoopConf.setInt("parquet.page.size", 4 * 1024)
+      try {
+        spark
+          .range(0, 20000)
+          .selectExpr("id", "id * 2 as v")
+          .coalesce(1)
+          .write
+          .format("delta")
+          .save(path)
+      } finally {
+        if (oldBlockSize == null) hadoopConf.unset("parquet.block.size")
+        else hadoopConf.set("parquet.block.size", oldBlockSize)
+        if (oldPageSize == null) hadoopConf.unset("parquet.page.size")
+        else hadoopConf.set("parquet.page.size", oldPageSize)
+      }
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      // Scattered deletes across every row group plus a deleted tail, so every split sees the
+      // deletion vector and the last splits are mostly deleted.
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 5 = 0")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id >= 19000")
+
+      // A claimed scan is split like any other file, and the deletion vector is applied in
+      // file coordinates, so each split must skip exactly its own deleted rows.
+      withSQLConf(SQLConf.FILES_MAX_PARTITION_BYTES.key -> "4096") {
+        def query = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(query)
+
+        val df = query
+        assert(df.collect().length == 15200)
+        val scans = deltaNativeScans(df)
+        assert(scans.size == 1)
+        val numFiles = scans.head.metrics.get("numFiles").map(_.value).getOrElse(0L)
+        assert(numFiles == 1, s"expected a single data file, got $numFiles")
+        val numPartitions = scans.head.outputPartitioning.numPartitions
+        assert(
+          numPartitions > 1,
+          "expected the single file to be split into more than one native partition, " +
+            s"got $numPartitions")
+      }
+    }
+  }
+
+  test("deletion vectors: aggregation over DV table") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path, rows = 10000)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 7 = 0")
+
+      val df = spark.read.format("delta").load(path).groupBy(col("id") % 13).count()
+      checkDeltaNativeScanAnswer(df)
+    }
+  }
+
+  test("deletion vectors: partitioned table reads natively with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 1000)
+        .selectExpr("id", "id % 5 as p", "id * 2 as v")
+        .write
+        .format("delta")
+        .partitionBy("p")
+        .save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 3 = 0")
+
+      val df = spark.read.format("delta").load(path).filter(col("p") === 2)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == (0L until 1000L).count(i => i % 5 == 2 && i % 3 != 0))
+
+      val all = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(all)
+      assert(all.count() == (0L until 1000L).count(_ % 3 != 0))
+    }
+  }
+
+  test("deletion vectors: combined with constant metadata columns") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id < 250")
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .selectExpr("id", "v", "_metadata.file_name as fn")
+      checkSparkAnswer(df.selectExpr("id", "v", "length(fn) > 0"))
+      // Whether this claims or declines, results must match; if it claimed, verify the
+      // native node is present so the combination is actually exercised when supported.
+      val rows = df.collect()
+      assert(rows.length == 750)
+      assert(rows.forall(_.getString(2).nonEmpty))
+    }
+  }
+
+  test(
+    "deletion vectors: constant-metadata field names are deduplicated against the physical " +
+      "data and partition schemas") {
+    // End-to-end coverage is not possible here: selecting any `_metadata.*` field in the DV
+    // shape always declines today for an unrelated, pre-existing reason -- Spark reuses the
+    // scan's own row-index bookkeeping attribute as `_metadata.row_index`'s source, and
+    // `DeltaScanSupport.rowIndexUnusedAbove` conservatively treats extracting ANY `_metadata`
+    // field as making that attribute live (see "combined with constant metadata columns"
+    // above, which hedges its assertions for the same reason). That decline fires before
+    // `buildDvScanCommon` ever runs, regardless of collision, so it cannot exercise the fix.
+    // Test the builder's dedup logic directly instead, the same way `storeUris` and
+    // `mergedObjectStoreOptions` are unit-tested without a live scan.
+    val physicalDataSchema =
+      StructType(Seq(StructField("_comet_metadata_file_path", ByteType)))
+    val physicalPartitionSchema =
+      StructType(Seq(StructField("_comet_metadata_file_size", LongType)))
+    val fileConstantMetadataColumns = Seq(
+      AttributeReference("file_path", StringType, nullable = false)(),
+      AttributeReference("file_size", LongType, nullable = false)())
+
+    val constantMetadataFields = CometNativeScan.uniqueConstantMetadataFields(
+      fileConstantMetadataColumns,
+      physicalDataSchema.fields.map(_.name).toSet ++ physicalPartitionSchema.fields
+        .map(_.name)
+        .toSet)
+    assert(
+      constantMetadataFields.map(_.name) == Seq(
+        "_comet_metadata_file_path_",
+        "_comet_metadata_file_size_"),
+      "expected both constant-metadata names to be uniquified on collision, got " +
+        s"${constantMetadataFields.map(_.name)}")
+
+    // The DV builder must feed these already-unique names into allocateUniqueInternalFields's
+    // reserved set so the internal-column suffix chain stays consistent with them.
+    val requiredSchema = StructType(
+      Seq(
+        StructField("id", LongType),
+        StructField(CometDeltaNativeScan.IsRowDeletedColumn, ByteType),
+        StructField(CometDeltaNativeScan.RowIndexColumn, LongType)))
+    val internalFields = CometDeltaNativeScan.allocateUniqueInternalFields(
+      requiredSchema,
+      physicalDataSchema,
+      physicalPartitionSchema,
+      constantMetadataFields)
+
+    val allNames = physicalDataSchema.fields.map(_.name) ++
+      physicalPartitionSchema.fields.map(_.name) ++
+      constantMetadataFields.map(_.name) ++
+      internalFields.map(_.name)
+    assert(allNames.distinct.length == allNames.length, s"expected all names distinct: $allNames")
+  }
+
+  test(
+    "non-DV shape: user column named like the synthetic constant-metadata slot keeps its " +
+      "own values") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      val collidingName = "_comet_metadata_file_path"
+      spark
+        .range(0, 100)
+        .selectExpr("id", s"cast(7 as tinyint) as `$collidingName`")
+        .write
+        .format("delta")
+        .save(path)
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .selectExpr("id", s"`$collidingName`", "_metadata.file_path as fp")
+      checkDeltaNativeScanAnswer(df)
+      val rows = df.collect()
+      val survivingValues = rows.map(_.getAs[Byte](collidingName)).distinct
+      assert(
+        survivingValues.sameElements(Array(7.toByte)),
+        "expected the user column's own value (7) to survive the constant-metadata " +
+          s"collision, got ${survivingValues.toSeq}")
+      assert(
+        rows.forall(_.getString(2).nonEmpty),
+        "expected _metadata.file_path to still report a real path")
+    }
+  }
+
+  test("deletion vectors: special characters in table path") {
+    withTempDir { base =>
+      val dir = new java.io.File(base, "s p a r k %dv% test")
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 500)
+    }
+  }
+
+  test("deletion vectors: decline when row_index is consumed via multi-hop aliases") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .selectExpr("id", "_metadata.row_index as ri")
+        .selectExpr("id", "ri + 1 as ri2")
+        .filter(col("ri2") > 10)
+      checkSparkAnswer(df)
+      assert(deltaNativeScans(df).isEmpty, "derived row_index consumption must decline")
+    }
+  }
+
+  test("deletion vectors: decline when row_index feeds a non-Project operator") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .groupBy(col("_metadata.row_index") % 7)
+        .count()
+      checkSparkAnswer(df)
+      assert(deltaNativeScans(df).isEmpty, "aggregate over row_index must decline")
+    }
+  }
+
+  test("deletion vectors: decline when _metadata.row_index is referenced above the scan") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      createDvTable(path)
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .selectExpr("id", "_metadata.row_index as ri")
+      checkSparkAnswer(df)
+      assert(
+        deltaNativeScans(df).isEmpty,
+        "plans consuming a real row_index must fall back to Spark")
+    }
+  }
+
+  /**
+   * Every [[SparkPlan]] executed during `body`, captured via a [[QueryExecutionListener]] rather
+   * than a returned `DataFrame`'s own plan: a `DataFrameWriter` action such as `.write.parquet`
+   * has no result `Dataset` to call `.queryExecution` on, so the write's physical plan -- the one
+   * `DeltaScanSupport.declineReason` actually saw -- is only observable this way.
+   */
+  private def capturePlansDuring(body: => Unit): Seq[SparkPlan] = {
+    val plans = ListBuffer.empty[SparkPlan]
+    val listener = new QueryExecutionListener {
+      override def onSuccess(funcName: String, qe: QueryExecution, durationNs: Long): Unit = {
+        plans += qe.executedPlan
+      }
+      override def onFailure(
+          funcName: String,
+          qe: QueryExecution,
+          exception: Exception): Unit = {}
+    }
+    spark.listenerManager.register(listener)
+    try {
+      body
+      // The listener bus delivers asynchronously, so the plans are not all in hand until it has
+      // drained.
+      CometListenerBusUtils.waitUntilEmpty(spark.sparkContext)
+    } finally {
+      spark.listenerManager.unregister(listener)
+    }
+    plans.toSeq
+  }
+
+  test(
+    "deletion vectors: a write sink persisting _metadata.row_index declines the native scan " +
+      "and saves the real row indexes") {
+    withTempPath { srcDir =>
+      withTempPath { dstDir =>
+        val src = srcDir.getAbsolutePath
+        val dst = dstDir.getAbsolutePath
+        spark
+          .range(32)
+          .coalesce(1)
+          .write
+          .format("delta")
+          .option("delta.enableDeletionVectors", "true")
+          .save(src)
+        spark.sql(s"DELETE FROM delta.`$src` WHERE id IN (1, 7, 13)").collect()
+
+        val capturedPlans = capturePlansDuring {
+          spark.read
+            .format("delta")
+            .load(src)
+            .selectExpr("id", "_metadata.row_index AS ri")
+            .write
+            .parquet(dst)
+        }
+
+        // The write persists whatever the reader returns for `ri`, so the native DV scan must
+        // not be claimed here: claiming it would let the reader's dead synthetic row-index
+        // constant (correct only because the value is normally proven unused) get persisted as
+        // if it were the real row index.
+        val nativeScans = capturedPlans.flatMap(p => collectByName(p, "CometDeltaNativeScanExec"))
+        assert(
+          nativeScans.isEmpty,
+          "expected the write to decline the native Delta scan for a persisted row_index")
+
+        // Documents which write-sink shape this test actually covers: the liveness gate in
+        // `DeltaScanSupport.rowIndexUnusedAbove` (the `childOutputLeak` check) declines a DV
+        // scan under ANY one-child, empty-output write sink structurally, including the DSv2
+        // `V2TableWriteExec` family -- but a DV-enabled Delta read cannot be composed with a
+        // genuine DSv2 `AppendData` write in this delta-spark/Spark combination (see the
+        // dsv2-infeasibility test below), so `.write.parquet` here is the only write-sink shape
+        // this liveness gate is exercised against end-to-end.
+        assert(
+          capturedPlans.map(stripAQEPlan).forall(!_.isInstanceOf[V2TableWriteExec]),
+          s"expected a V1 write command, not a DSv2 write, got: $capturedPlans")
+
+        val declinedScans = capturedPlans.flatMap { plan =>
+          collectWithSubqueries(stripAQEPlan(plan)) {
+            case f: FileSourceScanExec if DeltaScanSupport.isDeltaScan(f) => f
+          }
+        }
+        val reasons = declinedScans.flatMap(f => new ExtendedExplainInfo().getFallbackReasons(f))
+        assert(
+          reasons.exists(_.contains("row_index values consumed by the query")),
+          "expected the row-index-consumed-by-the-query decline reason, got: " +
+            reasons.mkString(", "))
+
+        val readBack = spark.read.parquet(dst)
+        checkSparkAnswer(readBack)
+        val rows = readBack.collect()
+        assert(rows.length == 29, s"expected 29 surviving rows, got ${rows.length}")
+        val id31 = rows.find(_.getLong(0) == 31)
+        assert(id31.isDefined, "expected id=31 to survive the DELETE")
+        assert(
+          id31.get.getLong(1) == 31,
+          "expected the persisted row_index for id=31 to be 31, got " +
+            s"${id31.get.getLong(1)} -- a wrongly-claimed native scan would have written a " +
+            "synthetic zero instead")
+        val sumRi = rows.map(_.getLong(1)).sum
+        assert(
+          sumRi == 475,
+          "expected sum(row_index) == 475 (sum(0..31) - (1 + 7 + 13) = 496 - 21), got " +
+            s"$sumRi -- a wrongly-claimed native scan would have summed to 0")
+      }
+    }
+  }
+
+  /**
+   * The write-sink liveness gate above (`rowIndexUnusedAbove`'s `childOutputLeak` check in
+   * `DeltaScanSupport`) covers a DSv2 write sink STRUCTURALLY -- any one-child node with an empty
+   * output that doesn't re-expose a tainted attribute, which is exactly the shape
+   * `AppendDataExec`/`OverwriteByExpressionExec`/the rest of the `V2TableWriteExec` family take
+   * -- but the test above only ever exercises the V1 `.write.parquet` command path.
+   *
+   * Reaching a genuine DSv2 `AppendDataExec` in this Spark 3.5 setup is itself achievable: a
+   * table created via the session catalog with `USING parquet` still plans as a V1
+   * `InsertIntoHadoopFsRelationCommand` (built-in file-based sources stay on
+   * `spark.sql.sources.useV1SourceList` by default), but `InMemoryTableCatalog` (from
+   * `spark-catalyst`'s test-jar, already a test dependency of this module, registered ad hoc
+   * under a throwaway name exactly as Spark's own DataSourceV2 test suites do) forces a genuine
+   * V2 write.
+   *
+   * What is NOT achievable in this delta-spark 3.3.2 / Spark 3.5.9 combination: composing that
+   * DSv2 `AppendData` write with a deletion-vector-enabled Delta table as its SOURCE. Both
+   * `df.writeTo(target).append()` (gluing an already-analyzed `DataFrame` into a fresh V2
+   * command) AND a single `INSERT INTO target SELECT ... FROM delta.\`path\`` statement
+   * (resolving the read and the V2 write in one analysis pass) hit the identical failure:
+   * delta-spark's own `PreprocessTableWithDVs` rule requires the source relation's
+   * `TahoeFileIndex` to be a "pinned" `TahoeLogFileIndex`
+   * (`ScanWithDeletionVectors$.dvEnabledScanFor`, `PreprocessTableWithDVs.scala:78`), which does
+   * not hold when that relation sits under a DSv2 `AppendData` command's analysis -- confirmed
+   * unrelated to catalog choice or DataFrame-vs-SQL construction. This is a delta-spark
+   * limitation on how a DV read may be composed, not a Comet regression, so this test pins it
+   * down as an expected, named failure rather than silently having no DSv2 coverage at all: the
+   * write-sink liveness gate's DSv2 coverage for a DV row-index source remains V1-only (see the
+   * test above), which this test documents by construction.
+   */
+  test(
+    "deletion vectors: a genuine DSv2 AppendData write cannot compose with a DV-enabled Delta " +
+      "source in this Spark/Delta combination (delta-spark's own pinned-snapshot requirement, " +
+      "not a Comet regression) -- documents why DSv2 write-sink coverage stays V1-only above") {
+    val catalogName = "cometDeltaRowIndexV2Cat"
+    withSQLConf(
+      s"spark.sql.catalog.$catalogName" ->
+        "org.apache.spark.sql.connector.catalog.InMemoryTableCatalog") {
+      withTempPath { srcDir =>
+        val src = srcDir.getAbsolutePath
+        spark
+          .range(32)
+          .coalesce(1)
+          .write
+          .format("delta")
+          .option("delta.enableDeletionVectors", "true")
+          .save(src)
+        spark.sql(s"DELETE FROM delta.`$src` WHERE id IN (1, 7, 13)").collect()
+
+        val targetTable = s"$catalogName.ns.row_index_sink"
+        spark.sql(s"CREATE TABLE $targetTable (id BIGINT, ri BIGINT) USING foo")
+
+        val ex = intercept[IllegalArgumentException] {
+          spark.sql(
+            s"INSERT INTO $targetTable SELECT id, _metadata.row_index AS ri FROM delta.`$src`")
+        }
+        assert(
+          ex.getMessage.contains("non-pinned"),
+          "expected delta-spark's pinned-TahoeLogFileIndex requirement to be the failure " +
+            "(if this now succeeds, DSv2 coverage for the DV row-index write-sink scenario " +
+            "may finally be achievable and this test should be replaced with a real one): " +
+            ex.getMessage)
+      }
+    }
+  }
+
+  /**
+   * Single-file (ids 0-4) deletion-vector table with one id deleted, used by the UnionExec
+   * row-index liveness tests below: UnionExec's output takes its expression IDs positionally from
+   * its FIRST child, so a live `_metadata.row_index` alias in a later branch is invisible to a
+   * taint analysis that only follows `ProjectExec` aliases. A small fixed fixture keeps the
+   * expected surviving row_index values easy to hand-verify.
+   */
+  private def createSmallDvTable(path: String, deleteId: Long): Unit = {
+    spark.range(0, 5).selectExpr("id").coalesce(1).write.format("delta").save(path)
+    spark.sql(
+      s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+    spark.sql(s"DELETE FROM delta.`$path` WHERE id = $deleteId")
+  }
+
+  test(
+    "deletion vectors: row_index live through UNION ALL declines both branches " +
+      "with correct SUM") {
+    withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "false") {
+      withTempPath { dir1 =>
+        withTempPath { dir2 =>
+          val t1 = dir1.getAbsolutePath
+          val t2 = dir2.getAbsolutePath
+          // t1: ids 0,1,3,4 survive (id 2 deleted); t2: ids 0,1,2,4 survive (id 3 deleted).
+          createSmallDvTable(t1, deleteId = 2)
+          createSmallDvTable(t2, deleteId = 3)
+
+          def query: DataFrame = {
+            val left =
+              spark.read.format("delta").load(t1).selectExpr("id", "_metadata.row_index as ri")
+            val right =
+              spark.read.format("delta").load(t2).selectExpr("id", "_metadata.row_index as ri")
+            left.union(right)
+          }
+
+          checkSparkAnswer(query)
+          val df = query
+          val rows = df.collect()
+          assert(rows.length == 8, s"expected 8 surviving rows, got ${rows.length}")
+          assert(
+            deltaNativeScans(df).isEmpty,
+            "row_index live via a union's positional output remap must decline both branches")
+          // row_index equals id for every surviving row in this single-file, insertion-ordered
+          // fixture, so summing the real (uncorrupted) row indexes is equivalent to summing ids:
+          // t1 (0+1+3+4=8) + t2 (0+1+2+4=7) = 15. A wrongly-claimed branch would instead
+          // contribute a constant 0 per row, which this exact total rules out.
+          val sum = rows.map(_.getLong(1)).sum
+          assert(sum == 15L, s"expected SUM(ri) == 15, got $sum")
+        }
+      }
+    }
+  }
+
+  test(
+    "deletion vectors: row_index live only in the second UNION ALL branch declines " +
+      "only that branch") {
+    withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "false") {
+      withTempPath { dir1 =>
+        withTempPath { dir2 =>
+          val t1 = dir1.getAbsolutePath
+          val t2 = dir2.getAbsolutePath
+          createSmallDvTable(t1, deleteId = 2)
+          createSmallDvTable(t2, deleteId = 3)
+
+          def query: DataFrame = {
+            // Branch 1's "ri" is a constant, never derived from its own row_index; branch 2's
+            // "ri" is the real _metadata.row_index. UnionExec's output reuses branch 1's
+            // expression ID for the "ri" column, so only branch 2's scan should decline.
+            val left =
+              spark.read.format("delta").load(t1).selectExpr("id", "CAST(-1 AS BIGINT) as ri")
+            val right =
+              spark.read.format("delta").load(t2).selectExpr("id", "_metadata.row_index as ri")
+            left.union(right)
+          }
+
+          checkSparkAnswer(query)
+          val df = query
+          val rows = df.collect()
+          assert(rows.length == 8, s"expected 8 surviving rows, got ${rows.length}")
+          val fromT1 = rows.filter(_.getLong(1) == -1L)
+          val fromT2 = rows.filter(_.getLong(1) != -1L)
+          assert(fromT1.length == 4, s"expected 4 rows from t1, got ${fromT1.length}")
+          assert(fromT2.length == 4, s"expected 4 rows from t2, got ${fromT2.length}")
+          // Real row_index equals id in this fixture; a wrongly-claimed branch 2 would instead
+          // report a constant 0 for every row, which this per-row check rules out.
+          assert(
+            fromT2.forall(r => r.getLong(0) == r.getLong(1)),
+            s"expected t2's ri to equal id, got: ${fromT2.mkString(", ")}")
+          val scans = deltaNativeScans(df)
+          assert(
+            scans.size == 1,
+            s"expected exactly branch 1 (t1) to claim natively, got ${scans.size} native scans")
+        }
+      }
+    }
+  }
+
+  test(
+    "deletion vectors: SUM(row_index) over UNION ALL declines both branches with correct total") {
+    withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "false") {
+      withTempPath { dir1 =>
+        withTempPath { dir2 =>
+          val t1 = dir1.getAbsolutePath
+          val t2 = dir2.getAbsolutePath
+          createSmallDvTable(t1, deleteId = 2)
+          createSmallDvTable(t2, deleteId = 3)
+
+          def query: DataFrame = {
+            val left =
+              spark.read.format("delta").load(t1).selectExpr("id", "_metadata.row_index as ri")
+            val right =
+              spark.read.format("delta").load(t2).selectExpr("id", "_metadata.row_index as ri")
+            left.union(right).selectExpr("sum(ri) as total")
+          }
+
+          checkSparkAnswer(query)
+          val total = query.collect()(0).getLong(0)
+          assert(total == 15L, s"expected SUM(ri) == 15, got $total")
+          assert(
+            deltaNativeScans(query).isEmpty,
+            "row_index live via an aggregate over a union must decline both branches")
+        }
+      }
+    }
+  }
+
+  test(
+    "deletion vectors: UNION ALL without _metadata still claims both branches natively " +
+      "(anti-regression)") {
+    withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "false") {
+      withTempPath { dir1 =>
+        withTempPath { dir2 =>
+          val t1 = dir1.getAbsolutePath
+          val t2 = dir2.getAbsolutePath
+          createSmallDvTable(t1, deleteId = 2)
+          createSmallDvTable(t2, deleteId = 3)
+
+          def query: DataFrame = {
+            val left = spark.read.format("delta").load(t1).selectExpr("id")
+            val right = spark.read.format("delta").load(t2).selectExpr("id")
+            left.union(right)
+          }
+
+          checkSparkAnswer(query)
+          val df = query
+          val ids = df.collect().map(_.getLong(0)).sorted
+          assert(
+            ids.sameElements(Array(0L, 0L, 1L, 1L, 2L, 3L, 4L, 4L)),
+            s"unexpected surviving ids: ${ids.mkString(", ")}")
+          val scans = deltaNativeScans(df)
+          assert(
+            scans.size == 2,
+            "a DV union without _metadata must still claim both branches natively " +
+              s"(the row-index column is dead in both), got ${scans.size} native scans")
+        }
+      }
+    }
+  }
+
+  test("deletion vectors: inner join between two DV tables claims both scans natively") {
+    // Positive coverage for the generic multi-child safety net (DeltaScanSupport.scala's
+    // multiChildLeak check): a plain join carries no row-index taint at all, so the safety net
+    // must not mistake a join's normal attribute passthrough for a leak and fall both sides back
+    // to Spark.
+    withSQLConf(SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "false") {
+      withTempPath { dir1 =>
+        withTempPath { dir2 =>
+          val t1 = dir1.getAbsolutePath
+          val t2 = dir2.getAbsolutePath
+          // t1 survives ids {0,1,3,4} (id 2 deleted); t2 survives ids {0,1,2,4} (id 3 deleted).
+          createSmallDvTable(t1, deleteId = 2)
+          createSmallDvTable(t2, deleteId = 3)
+
+          def query: DataFrame = {
+            val left = spark.read.format("delta").load(t1).withColumnRenamed("id", "lid")
+            val right = spark.read.format("delta").load(t2).withColumnRenamed("id", "rid")
+            left.join(right, col("lid") === col("rid"))
+          }
+
+          checkSparkAnswer(query)
+          val df = query
+          val rows = df.collect()
+          val ids = rows.map(_.getLong(0)).sorted
+          // Only ids surviving in BOTH tables' deletion vectors should match.
+          assert(
+            ids.sameElements(Array(0L, 1L, 4L)),
+            s"expected join to match surviving ids {0,1,4}, got: ${ids.mkString(", ")}")
+          assert(
+            rows.forall(r => r.getLong(0) == r.getLong(1)),
+            "join key mismatch in result rows")
+          val scans = deltaNativeScans(df)
+          assert(
+            scans.size == 2,
+            "a DV-backed join with no row-index consumption must claim both sides natively, " +
+              s"got ${scans.size} native scans")
+        }
+      }
+    }
+  }
+
+  private def enableColumnMapping(path: String): Unit =
+    spark.sql(s"""ALTER TABLE delta.`$path` SET TBLPROPERTIES (
+                 |  'delta.minReaderVersion' = '2',
+                 |  'delta.minWriterVersion' = '5',
+                 |  'delta.columnMapping.mode' = 'name')""".stripMargin)
+
+  test("column mapping: renamed column reads natively across old and new files") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      enableColumnMapping(path)
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN v TO w")
+      // Files written after the rename carry the same physical name.
+      spark
+        .range(100, 200)
+        .selectExpr("id", "id * 2 as w")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path).filter(col("w") > 100)
+      checkDeltaNativeScanAnswer(df)
+      assert(spark.read.format("delta").load(path).count() == 200)
+    }
+  }
+
+  test("column mapping: dropped and re-added column name reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      enableColumnMapping(path)
+      spark.sql(s"ALTER TABLE delta.`$path` DROP COLUMN v")
+      spark.sql(s"ALTER TABLE delta.`$path` ADD COLUMN v LONG")
+      spark
+        .range(100, 200)
+        .selectExpr("id", "id * 3 as v")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      // Old files must yield NULL for the re-added v (different physical column).
+      assert(df.filter(col("id") < 100).filter(col("v").isNotNull).count() == 0)
+      assert(df.filter(col("id") >= 100).filter(col("v").isNull).count() == 0)
+    }
+  }
+
+  test("column mapping: partitioned table reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 500)
+        .selectExpr("id", "id % 5 as p")
+        .write
+        .format("delta")
+        .partitionBy("p")
+        .save(path)
+      enableColumnMapping(path)
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN p TO part")
+
+      val df = spark.read.format("delta").load(path).filter(col("part") === 3)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 100)
+    }
+  }
+
+  test(
+    "column mapping: rename history colliding logical partition name with physical data " +
+      "name reads correctly") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // a->b then p->a leaves the LOGICAL name "a" bound to the partition column while a
+      // DIFFERENT physical data column (originally "a", now logically "b") retains physical
+      // name "a". Passing the partition schema's logical names to the native side collides
+      // with that retained physical data name and lets DataFusion's name-based partition
+      // rewrite replace the data projection with the partition constant.
+      spark.sql(s"CREATE TABLE delta.`$path` (a BIGINT, p BIGINT) USING delta PARTITIONED BY (p)")
+      enableColumnMapping(path)
+      spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 100), (2, 100)")
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN a TO b")
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN p TO a")
+
+      val df = spark.sql(s"SELECT b, a FROM delta.`$path`")
+      checkDeltaNativeScanAnswer(df)
+      val rows = df.collect().map(r => (r.getLong(0), r.getLong(1))).sorted
+      assert(
+        rows.sameElements(Array((1L, 100L), (2L, 100L))),
+        s"expected (1,100),(2,100) but got ${rows.mkString(", ")}")
+    }
+  }
+
+  test(
+    "column mapping: rename history colliding partition name reads correctly with " +
+      "deletion vectors") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"CREATE TABLE delta.`$path` (a BIGINT, p BIGINT) USING delta PARTITIONED BY (p)")
+      enableColumnMapping(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 100), (2, 100)")
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN a TO b")
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN p TO a")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE b = 1")
+
+      val df = spark.sql(s"SELECT b, a FROM delta.`$path`")
+      checkDeltaNativeScanAnswer(df)
+      val rows = df.collect().map(r => (r.getLong(0), r.getLong(1))).sorted
+      assert(
+        rows.sameElements(Array((2L, 100L))),
+        s"expected (2,100) but got ${rows.mkString(", ")}")
+    }
+  }
+
+  test("column mapping: renamed partition column without collision reads correctly (control)") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"CREATE TABLE delta.`$path` (a BIGINT, p BIGINT) USING delta PARTITIONED BY (p)")
+      enableColumnMapping(path)
+      spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 100), (2, 100)")
+      // Rename ONLY the partition column, to a name that collides with nothing: no physical
+      // data column is named "q", so this must not be affected by the collision above.
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN p TO q")
+
+      val df = spark.sql(s"SELECT a, q FROM delta.`$path`")
+      checkDeltaNativeScanAnswer(df)
+      val rows = df.collect().map(r => (r.getLong(0), r.getLong(1))).sorted
+      assert(
+        rows.sameElements(Array((1L, 100L), (2L, 100L))),
+        s"expected (1,100),(2,100) but got ${rows.mkString(", ")}")
+    }
+  }
+
+  test("column mapping: combined with deletion vectors") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 1000).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      enableColumnMapping(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN v TO w")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 4 = 0")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 750)
+    }
+  }
+
+  test("column mapping: to_json on a nested struct matches Spark's field names") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 10)
+        .selectExpr("id", "named_struct('a', id) as s")
+        .write
+        .format("delta")
+        .save(path)
+      enableColumnMapping(path)
+      // Renaming the NESTED field (not the outer column) is what diverges the physical name
+      // ("a", preserved on rename) from the logical name ("b") for a struct field below the
+      // top level -- the shape that leaks physical names into to_json's output.
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN s.a TO b")
+
+      withSQLConf(CometConf.getExprAllowIncompatConfigKey(classOf[StructsToJson]) -> "true") {
+        val df = spark.read.format("delta").load(path).select(to_json(col("s")))
+        checkSparkAnswer(df)
+        assert(
+          deltaNativeScans(df).isEmpty,
+          "column mapping with nested struct fields must fall back to Spark")
+      }
+    }
+  }
+
+  test("decline: column mapping with nested struct columns falls back to Spark") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 200)
+        .selectExpr(
+          "id",
+          "named_struct('a', id, 'b', cast(id as string)) as st",
+          "array(id, id * 2) as arr",
+          "map(cast(id as string), id) as mp")
+        .write
+        .format("delta")
+        .save(path)
+      enableColumnMapping(path)
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN st TO st2")
+      spark
+        .range(200, 300)
+        .selectExpr(
+          "id",
+          "named_struct('a', id, 'b', cast(id as string)) as st2",
+          "array(id, id * 2) as arr",
+          "map(cast(id as string), id) as mp")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path).selectExpr("id", "st2.a", "arr", "mp")
+      checkSparkAnswer(df)
+      assert(df.count() == 300)
+      assert(
+        deltaNativeScans(df).isEmpty,
+        "column mapping with nested struct fields must fall back to Spark")
+    }
+  }
+
+  test("decline: column mapping with structs nested in arrays and maps falls back to Spark") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 50)
+        .selectExpr(
+          "id",
+          "array(named_struct('a', id, 'b', cast(id as string))) as arrOfStruct",
+          "map(cast(id as string), named_struct('a', id)) as mapOfStruct")
+        .write
+        .format("delta")
+        .save(path)
+      enableColumnMapping(path)
+
+      val df = spark.read.format("delta").load(path)
+      checkSparkAnswer(df)
+      assert(
+        deltaNativeScans(df).isEmpty,
+        "column mapping with structs nested in arrays/maps must fall back to Spark")
+    }
+  }
+
+  test("column mapping: top-level scalars and array-of-primitives still claim natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 200)
+        .selectExpr("id", "cast(id as string) as v", "array(id, id * 2) as arr")
+        .write
+        .format("delta")
+        .save(path)
+      enableColumnMapping(path)
+      spark.sql(s"ALTER TABLE delta.`$path` RENAME COLUMN v TO w")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 200)
+    }
+  }
+
+  test("decline: column mapping id mode falls back to Spark with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"""CREATE TABLE delta.`$path` (id LONG, v LONG) USING delta
+                   |TBLPROPERTIES ('delta.columnMapping.mode' = 'id')""".stripMargin)
+      spark
+        .range(0, 100)
+        .selectExpr("id", "id * 2 as v")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path)
+      checkSparkAnswer(df)
+      assert(deltaNativeScans(df).isEmpty, "id-mode column mapping must decline")
+    }
+  }
+
+  test("delete without deletion vectors rewrites files and still reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 1000).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      // DVs are off by default, so DELETE rewrites files; result is still a plain table.
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id < 100")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 900)
+    }
+  }
+
+  test("dynamic partition pruning via broadcast join prunes delta partitions") {
+    withSQLConf(
+      SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true",
+      SQLConf.COALESCE_PARTITIONS_ENABLED.key -> "true",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "20",
+      SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "100m") {
+      withTempPath { factDir =>
+        withTempPath { dimDir =>
+          val factPath = factDir.getAbsolutePath
+          val dimPath = dimDir.getAbsolutePath
+          spark
+            .range(0, 2000)
+            .selectExpr("id", "id % 10 as p")
+            .write
+            .format("delta")
+            .partitionBy("p")
+            .save(factPath)
+          // Unfiltered on disk: the selective predicate below is a query-time filter, which
+          // is what gives Spark's DynamicPartitionPruning rule a subquery to inject in the
+          // first place. Filtering before the write (the old shape of this test) leaves no
+          // predicate in the query for DPP to see, so the assertions below never fired.
+          spark
+            .range(0, 10)
+            .selectExpr("id as key", "id % 10 as dp")
+            .write
+            .format("delta")
+            .save(dimPath)
+
+          def query = {
+            val fact = spark.read.format("delta").load(factPath)
+            val dim = spark.read.format("delta").load(dimPath)
+            // only partitions 0 and 1 survive the join
+            fact.join(dim, fact("p") === dim("dp")).filter(dim("key") < 2)
+          }
+
+          checkSparkAnswer(query)
+
+          val df = query
+          val rows = df.collect()
+          assert(rows.length == 400) // 2 partitions x 200 rows
+          val scans = deltaNativeScans(df)
+          assert(
+            scans.nonEmpty,
+            s"expected native delta scans:\n${df.queryExecution.executedPlan}")
+
+          val deltaScans = scans.collect { case s: CometDeltaNativeScanExec => s }
+          assert(
+            deltaScans.exists(_.runtimeFilters.exists(_.isInstanceOf[DynamicPruningExpression])),
+            "expected a DynamicPruningExpression in a CometDeltaNativeScanExec's " +
+              s"runtimeFilters:\n${df.queryExecution.executedPlan}")
+
+          // The fact-side scan must have read fewer files than the table holds (DPP pruning).
+          val factScan = scans.maxBy(_.metrics.get("staticFilesNum").map(_.value).getOrElse(0L))
+          val staticFiles = factScan.metrics.get("staticFilesNum").map(_.value).getOrElse(0L)
+          val readFiles = factScan.metrics.get("numFiles").map(_.value).getOrElse(0L)
+          assert(staticFiles > 0, "expected the staticFilesNum metric to be populated")
+          assert(
+            readFiles < staticFiles,
+            s"expected DPP pruning: read $readFiles of $staticFiles files")
+        }
+      }
+    }
+  }
+
+  for (adaptive <- Seq(false, true)) {
+    test(
+      "DPP stays executable when transition reversion restores the delta scan: " +
+        s"AQE=$adaptive") {
+      assume(isSpark35Plus, "Comet AQE DPP query-stage optimizer rules require Spark 3.5+")
+      withTempPath { factDir =>
+        withTempPath { dimDir =>
+          val factPath = factDir.getAbsolutePath
+          val dimPath = dimDir.getAbsolutePath
+          spark
+            .range(0, 400)
+            .selectExpr(
+              "CAST(id AS INT) AS fact_id",
+              "CAST(id % 10 AS INT) AS fact_key",
+              "CONCAT('f', id) AS fact_str")
+            .write
+            .format("delta")
+            .partitionBy("fact_key")
+            .save(factPath)
+          spark
+            .range(0, 10)
+            .selectExpr(
+              "CAST(id AS INT) AS dim_id",
+              "CAST(id AS INT) AS dim_key",
+              "CONCAT('d', id) AS dim_str")
+            .write
+            .parquet(dimPath)
+
+          withTempView("revert_dpp_fact", "revert_dpp_dim") {
+            spark.read.format("delta").load(factPath).createOrReplaceTempView("revert_dpp_fact")
+            spark.read.parquet(dimPath).createOrReplaceTempView("revert_dpp_dim")
+            val query =
+              """SELECT f.fact_id, f.fact_str, d.dim_str
+                |FROM revert_dpp_fact f JOIN revert_dpp_dim d ON f.fact_key = d.dim_key
+                |WHERE d.dim_id < 5""".stripMargin
+
+            def hasDpp(filters: Seq[Expression]): Boolean =
+              filters.exists(_.isInstanceOf[DynamicPruningExpression])
+
+            withSQLConf(
+              SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> adaptive.toString,
+              SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "true",
+              "spark.comet.exec.project.enabled" -> "false",
+              CometConf.COMET_EXEC_TRANSITION_REVERT_MAX_TRANSITIONS.key -> "0") {
+              // Without reversion the fact side is a native Delta scan carrying the DPP filter.
+              withSQLConf(CometConf.COMET_EXEC_TRANSITION_REVERT_ENABLED.key -> "false") {
+                val df = sql(query)
+                assert(df.collect().length == 200)
+                val nativeScans = deltaNativeScans(df).collect {
+                  case s: CometDeltaNativeScanExec => s
+                }
+                assert(
+                  nativeScans.exists(s => hasDpp(s.runtimeFilters)),
+                  "expected a native Delta scan with a DPP filter:\n" +
+                    df.queryExecution.executedPlan)
+              }
+
+              withSQLConf(CometConf.COMET_EXEC_TRANSITION_REVERT_ENABLED.key -> "true") {
+                val (_, cometPlan) = checkSparkAnswer(query)
+                assert(
+                  collectByName(cometPlan, "CometDeltaNativeScanExec").isEmpty,
+                  s"transition reversion should restore the Spark Delta scan:\n$cometPlan")
+                val restored = collect(cometPlan) {
+                  case s: FileSourceScanExec if hasDpp(s.partitionFilters) => s
+                }
+                assert(
+                  restored.nonEmpty,
+                  s"expected a restored scan with a DPP filter:\n$cometPlan")
+                restored.foreach { scan =>
+                  assert(
+                    scan.relation.fileFormat.getClass.getSimpleName.contains("Delta"),
+                    s"expected the restored scan to read Delta:\n$cometPlan")
+                  assert(
+                    scan.logicalLink.isDefined,
+                    s"restored scan lost its logical link:\n$scan")
+                  val subqueryPlans =
+                    scan.partitionFilters.flatMap(_.collect { case e: InSubqueryExec =>
+                      e.plan match {
+                        case ReusedSubqueryExec(p) => p
+                        case p => p
+                      }
+                    })
+                  assert(
+                    subqueryPlans.nonEmpty && subqueryPlans.forall {
+                      case _: SubqueryBroadcastExec | _: CometSubqueryBroadcastExec => true
+                      case _ => false
+                    },
+                    s"restored scan must carry the executable DPP subquery:\n$cometPlan")
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
+  test("union all with DPP join and coalescible shuffle survives AQE partitioning checks") {
+    // The crash shape: a DPP join in one UNION ALL branch and a coalescible shuffle (the
+    // GROUP BY) in the other. Spark's AQE plan validation walks every operator's
+    // outputPartitioning, including the DPP branch's scan, before
+    // CometPlanAdaptiveDynamicPruningFilters has rewritten the placeholder subquery -- this
+    // is the ordering that reproduced the crash.
+    withSQLConf(
+      SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true",
+      SQLConf.COALESCE_PARTITIONS_ENABLED.key -> "true",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "20",
+      SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "100m") {
+      withTempPath { factDir =>
+        withTempPath { dimDir =>
+          withTempPath { otherDir =>
+            val factPath = factDir.getAbsolutePath
+            val dimPath = dimDir.getAbsolutePath
+            val otherPath = otherDir.getAbsolutePath
+
+            spark
+              .range(0, 2000)
+              .selectExpr("id", "id % 10 as p")
+              .write
+              .format("delta")
+              .partitionBy("p")
+              .save(factPath)
+            spark
+              .range(0, 10)
+              .selectExpr("id as key", "id % 10 as dp", "id as sel")
+              .write
+              .format("delta")
+              .save(dimPath)
+            spark
+              .range(0, 500)
+              .selectExpr("id", "id % 10 as p")
+              .write
+              .format("delta")
+              .partitionBy("p")
+              .save(otherPath)
+
+            spark.read.format("delta").load(factPath).createOrReplaceTempView("r43Fact")
+            spark.read.format("delta").load(dimPath).createOrReplaceTempView("r43Dim")
+            spark.read.format("delta").load(otherPath).createOrReplaceTempView("r43Other")
+
+            def query =
+              spark.sql("""
+                |SELECT f.p, f.id FROM r43Fact f JOIN r43Dim d ON f.p = d.dp WHERE d.sel < 2
+                |UNION ALL
+                |SELECT p, CAST(count(*) AS LONG) AS id FROM r43Other GROUP BY p
+                |""".stripMargin)
+
+            try {
+              checkSparkAnswer(query)
+            } catch {
+              case e: Throwable =>
+                if (e.getMessage != null &&
+                  e.getMessage.contains("does not support the execute() code path")) {
+                  throw new AssertionError(
+                    "AQE inspected outputPartitioning on an unresolved adaptive DPP " +
+                      "placeholder -- this is the crash this test guards against",
+                    e)
+                }
+                throw e
+            }
+
+            val df = query
+            df.collect()
+            // Best-effort: this UNION ALL shape need not always route through the native
+            // Delta scan, but if it does, it must have survived AQE's partitioning checks
+            // above without throwing. Observed to vary run-to-run on this build (Spark 3.5.9
+            // / Delta 3.3.2), so this is logged rather than asserted -- answer correctness is
+            // already verified by checkSparkAnswer above.
+            val scans = deltaNativeScans(df)
+            if (scans.isEmpty) {
+              logInfo(
+                "union all with DPP join and coalescible shuffle: no CometDeltaNativeScanExec " +
+                  "claimed this query on this build; answer correctness already verified above")
+            } else {
+              logInfo(
+                s"union all with DPP join and coalescible shuffle: ${scans.length} " +
+                  "CometDeltaNativeScanExec node(s) claimed this query; answer correctness " +
+                  "already verified above")
+            }
+          }
+        }
+      }
+    }
+  }
+
+  test("scalar subquery in a partition filter does not force partitioning during AQE checks") {
+    // Crash shape: a scalar subquery used directly as
+    // a partition filter, e.g. `p = (SELECT max(p) FROM dim ...)`, references only the
+    // partition column, so it lands in runtimeFilters rather than dataFilters.
+    // ValidateRequirements walks outputPartitioning for every operator, including this scan,
+    // before the subquery has executed -- forcing perPartitionData at that point evaluates the
+    // still-unresolved ScalarSubquery and throws "has not finished".
+    withSQLConf(
+      SQLConf.ADAPTIVE_EXECUTION_ENABLED.key -> "true",
+      SQLConf.COALESCE_PARTITIONS_ENABLED.key -> "true",
+      SQLConf.SHUFFLE_PARTITIONS.key -> "20",
+      SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "100m") {
+      withTempPath { factDir =>
+        withTempPath { dimDir =>
+          withTempPath { otherDir =>
+            val factPath = factDir.getAbsolutePath
+            val dimPath = dimDir.getAbsolutePath
+            val otherPath = otherDir.getAbsolutePath
+
+            spark
+              .range(0, 2000)
+              .selectExpr("id", "id % 10 as p")
+              .write
+              .format("delta")
+              .partitionBy("p")
+              .save(factPath)
+            spark
+              .range(0, 10)
+              .selectExpr("id as p", "case when id in (0, 3) then 'yes' else 'no' end as country")
+              .write
+              .format("parquet")
+              .save(dimPath)
+            spark
+              .range(0, 500)
+              .selectExpr("id", "id % 10 as p")
+              .write
+              .format("parquet")
+              .save(otherPath)
+
+            spark.read.format("delta").load(factPath).createOrReplaceTempView("r45Fact")
+            spark.read.format("parquet").load(dimPath).createOrReplaceTempView("r45Dim")
+            spark.read.format("parquet").load(otherPath).createOrReplaceTempView("r45Other")
+
+            def query =
+              spark.sql("""
+                |SELECT id, p FROM r45Fact
+                |WHERE p = (SELECT max(p) FROM r45Dim WHERE country = 'yes')
+                |UNION ALL
+                |SELECT cast(count(*) AS int) AS id, p FROM r45Other GROUP BY p
+                |""".stripMargin)
+
+            try {
+              checkSparkAnswer(query)
+            } catch {
+              case e: Throwable =>
+                if (e.getMessage != null && e.getMessage.contains("has not finished")) {
+                  throw new AssertionError(
+                    "AQE ValidateRequirements forced outputPartitioning to evaluate an " +
+                      "unresolved scalar partition-filter subquery -- this is the crash this " +
+                      "test guards against",
+                    e)
+                }
+                throw e
+            }
+
+            val df = query
+            df.collect()
+            // Best-effort, mirroring the DPP union-all test above: this shape need not always
+            // route through the native Delta scan, but if it does, it must have survived AQE's
+            // partitioning checks above without throwing. Answer correctness is already
+            // verified by checkSparkAnswer above.
+            val scans = deltaNativeScans(df)
+            if (scans.isEmpty) {
+              logInfo(
+                "scalar subquery partition filter: no CometDeltaNativeScanExec claimed this " +
+                  "query on this build; answer correctness already verified above")
+            } else {
+              logInfo(
+                s"scalar subquery partition filter: ${scans.length} CometDeltaNativeScanExec " +
+                  "node(s) claimed this query; answer correctness already verified above")
+            }
+          }
+        }
+      }
+    }
+  }
+
+  test(
+    "aggregate over a scalar-subquery partition filter executes under a fused native " +
+      "parent") {
+    // Crash shape: a scalar subquery used as a partition filter (`p = (SELECT max(p) ...)`)
+    // lands in runtimeFilters. Once execution resolves it, a native aggregate sitting
+    // directly on top of the scan (no intervening exchange) reads the scan's
+    // outputPartitioning to size its own execution context; that getter must report the
+    // real post-pruning partition count, not a value stuck from before resolution.
+    withTempPath { factDir =>
+      withTempPath { thresholdsDir =>
+        val factPath = factDir.getAbsolutePath
+        val thresholdsPath = thresholdsDir.getAbsolutePath
+
+        spark
+          .range(0, 2000)
+          .selectExpr("id", "id % 10 as p")
+          .write
+          .format("delta")
+          .partitionBy("p")
+          .save(factPath)
+
+        spark
+          .sql("SELECT CAST(7 AS BIGINT) AS p")
+          .write
+          .format("delta")
+          .save(thresholdsPath)
+
+        def query =
+          spark.sql(
+            s"SELECT sum(id) AS total FROM delta.`$factPath` " +
+              s"WHERE p = (SELECT max(p) FROM delta.`$thresholdsPath`)")
+
+        checkSparkAnswer(query)
+
+        val df = query
+        try {
+          df.collect()
+        } catch {
+          case e: Throwable =>
+            if (e.getMessage != null && e.getMessage.contains("All per-partition arrays")) {
+              throw new AssertionError(
+                "a fused native aggregate above the scan read a stale zero " +
+                  "outputPartitioning after the scalar-subquery partition filter had " +
+                  "already resolved",
+                e)
+            }
+            throw e
+        }
+
+        val scans = deltaNativeScans(df)
+        assert(
+          scans.nonEmpty,
+          s"expected CometDeltaNativeScanExec in plan:\n${df.queryExecution.executedPlan}")
+        assert(
+          collectByName(df.queryExecution.executedPlan, "CometHashAggregateExec").nonEmpty,
+          "expected a fused native aggregate parent above the scan in plan:\n" +
+            s"${df.queryExecution.executedPlan}")
+      }
+    }
+  }
+
+  test(
+    "metrics evaluates without throwing when runtimeFilters holds a ScalarSubquery " +
+      "placeholder (pins the invariant documented on CometDeltaNativeScanExec.scanHelper: " +
+      "AQE's UI plan-walk calls .metrics on every node mid-planning, sometimes before a " +
+      "DPP/scalar-subquery filter has resolved, and this must never throw)") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 50).write.format("delta").save(path)
+
+      val scan = deltaNativeScans(spark.read.format("delta").load(path)).collect {
+        case s: CometDeltaNativeScanExec => s
+      }.head
+
+      // A real execution.ScalarSubquery instance (the exec-time class CometDeltaNativeScanExec
+      // itself matches against in hasUnevaluableSubqueryFilter), wrapping a never-executed
+      // SubqueryExec -- deliberately never run, so this is unresolved exactly as it would be
+      // when AQE's mid-planning walk reaches this node ahead of subquery execution.
+      val innerPlan = spark.range(1).selectExpr("id AS c").queryExecution.executedPlan
+      val unresolvedScalarSubquery =
+        ScalarSubquery(
+          SubqueryExec("metrics-guard-subquery", innerPlan),
+          NamedExpression.newExprId)
+
+      val scanWithSubquery = scan.copy(runtimeFilters = Seq(unresolvedScalarSubquery))
+      val metrics = scanWithSubquery.metrics
+      assert(
+        metrics.nonEmpty,
+        "expected CometDeltaNativeScanExec.metrics to populate the native scan metric node " +
+          "even with an unresolved ScalarSubquery in runtimeFilters")
+    }
+  }
+
+  test("input_file_name falls back to Spark with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id").write.format("delta").save(path)
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .selectExpr("id", "input_file_name() as f")
+      checkSparkAnswer(df.selectExpr("id", "length(f) > 0"))
+      assert(deltaNativeScans(df).isEmpty, "input_file_name must decline")
+    }
+  }
+
+  test("self-join of the same delta table keeps scans distinct") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id", "id % 5 as k").write.format("delta").save(path)
+
+      def query = {
+        val left = spark.read.format("delta").load(path).filter(col("id") < 50)
+        val right = spark.read.format("delta").load(path).filter(col("id") >= 50)
+        left.as("l").join(right.as("r"), col("l.k") === col("r.k"))
+      }
+      checkSparkAnswer(query)
+
+      val df = query
+      df.collect()
+      assert(deltaNativeScans(df).size == 2)
+    }
+  }
+
+  test("schema evolution: added column yields nulls for old files, natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id").write.format("delta").save(path)
+      spark.sql(s"ALTER TABLE delta.`$path` ADD COLUMN v LONG")
+      spark
+        .range(100, 200)
+        .selectExpr("id", "id * 2 as v")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.filter(col("id") < 100).filter(col("v").isNotNull).count() == 0)
+      assert(df.filter(col("id") >= 100).filter(col("v").isNull).count() == 0)
+    }
+  }
+
+  test("schema evolution: column default (Delta two-step) reads correctly") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id").write.format("delta").save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES " +
+          "('delta.feature.allowColumnDefaults' = 'supported')")
+      // Delta only allows defaults via add-then-set (applies to FUTURE inserts; old files
+      // read as NULL -- unlike Spark's existence defaults).
+      spark.sql(s"ALTER TABLE delta.`$path` ADD COLUMN v LONG")
+      spark.sql(s"ALTER TABLE delta.`$path` ALTER COLUMN v SET DEFAULT 42")
+      spark.sql(s"INSERT INTO delta.`$path` (id) VALUES (100), (101)")
+
+      val df = spark.read.format("delta").load(path)
+      // Whether claimed or declined, results must match Spark exactly.
+      checkSparkAnswer(df)
+      assert(df.count() == 102)
+      assert(df.filter(col("v") === 42).count() == 2)
+      assert(df.filter(col("id") < 100).filter(col("v").isNotNull).count() == 0)
+    }
+  }
+
+  test("legacy INT96 timestamps read natively with correct values") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      withSQLConf("spark.sql.parquet.outputTimestampType" -> "INT96") {
+        spark
+          .range(0, 100)
+          .selectExpr("id", "timestamp_seconds(1600000000 + id * 3600) as ts")
+          .write
+          .format("delta")
+          .save(path)
+      }
+      val df = spark.read.format("delta").load(path).filter(col("id") < 50)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 50)
+    }
+  }
+
+  test("decline: type widening feature falls back with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // Delta 3.3's widening preview supports byte/short -> int.
+      spark.sql(s"""CREATE TABLE delta.`$path` (id SMALLINT) USING delta
+                   |TBLPROPERTIES ('delta.enableTypeWidening' = 'true')""".stripMargin)
+      spark
+        .range(0, 100)
+        .selectExpr("cast(id as smallint) as id")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+      spark.sql(s"ALTER TABLE delta.`$path` ALTER COLUMN id TYPE INT")
+      spark
+        .range(100, 200)
+        .selectExpr("cast(id as int) as id")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path)
+      checkSparkAnswer(df)
+      assert(df.count() == 200)
+    }
+  }
+
+  test(
+    "decline: SMALLINT column falls back with correct results when unsigned-small-int " +
+      "safety check is enabled") {
+    // Regression: the Delta claim path must
+    // run the same CometScanTypeChecker core's own scan does, so the default-on
+    // COMET_PARQUET_UNSIGNED_SMALL_INT_CHECK safety fallback still applies to a native Delta
+    // scan. Without it, an out-of-range/malformed UINT_8 payload stored under a ShortType
+    // column could be claimed and silently decoded with the wrong values.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"CREATE TABLE delta.`$path` (id INT, s SMALLINT) USING delta")
+      spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 10), (2, 20), (3, 30)")
+
+      // CometTestBase flips this conf off by default so the rest of the suite can exercise
+      // ShortType columns against Comet's native scan; put it back to its real production
+      // default so this gate actually declines (mirrors the same pattern in
+      // DeltaScanContribSuite for the vectorized-reader conf).
+      withSQLConf(CometConf.COMET_PARQUET_UNSIGNED_SMALL_INT_CHECK.key -> "true") {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswerAndFallbackReason(
+          df,
+          CometConf.COMET_PARQUET_UNSIGNED_SMALL_INT_CHECK.key)
+        assert(deltaNativeScans(df).isEmpty)
+      }
+    }
+  }
+
+  test("claims SMALLINT column natively when unsigned-small-int safety check is disabled") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"CREATE TABLE delta.`$path` (id INT, s SMALLINT) USING delta")
+      spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 10), (2, 20), (3, 30)")
+
+      withSQLConf(CometConf.COMET_PARQUET_UNSIGNED_SMALL_INT_CHECK.key -> "false") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+      }
+    }
+  }
+
+  test("checkpointed delta log reads natively") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // Force a checkpoint by exceeding the default interval via many commits.
+      spark.sql(s"""CREATE TABLE delta.`$path` (id LONG, v LONG) USING delta
+                   |TBLPROPERTIES ('delta.checkpointInterval' = '3')""".stripMargin)
+      for (i <- 0 until 5) {
+        spark
+          .range(i * 10L, (i + 1) * 10L)
+          .selectExpr("id", "id * 2 as v")
+          .write
+          .format("delta")
+          .mode("append")
+          .save(path)
+      }
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 50)
+    }
+  }
+
+  test(
+    "decline: shallow clone with a supported local root but viewfs-scheme selected files " +
+      "falls back to Spark") {
+    // A shallow clone whose root is a supported scheme (local `file:`) but whose selected data
+    // files resolve through the source table's unsupported location (`viewfs:`, mounted onto
+    // the local filesystem so results are checkable). A gate on rootPaths alone misses this.
+    val cluster = "cometDeltaViewfsGate"
+    // Hadoop's mounttable is plain Configuration, not SQLConf: mutate the session's shared
+    // hadoopConfiguration directly (mirroring withSQLConf's set-then-restore shape) rather than
+    // withSQLConf, which only round-trips actual SQLConf entries.
+    val hadoopConf = spark.sparkContext.hadoopConfiguration
+    val linkFallbackKey = s"fs.viewfs.mounttable.$cluster.linkFallback"
+    val priorLinkFallback = Option(hadoopConf.get(linkFallbackKey))
+    hadoopConf.set(linkFallbackKey, "file:///")
+    try {
+      withTempPath { sourceDir =>
+        withTempPath { cloneDir =>
+          val sourcePath = sourceDir.getAbsolutePath
+          val clonePath = cloneDir.getAbsolutePath
+          val sourceViewfsPath = s"viewfs://$cluster$sourcePath"
+
+          spark
+            .range(0, 10)
+            .write
+            .format("delta")
+            .save(sourceViewfsPath)
+          spark.sql(s"CREATE TABLE delta.`$clonePath` SHALLOW CLONE delta.`$sourceViewfsPath`")
+          // Append local (file:) data on top of the clone's inherited viewfs-scheme files: the
+          // scan's selected data files now span both an unsupported scheme (viewfs) AND multiple
+          // object-store authorities (file: carries none, viewfs://cometDeltaViewfsGate carries
+          // one), the same shape DeltaScanContribSuite's
+          // "unsupportedSelectedSchemeReason declines a mixed file:+viewfs selection" unit test
+          // pins directly against declineReason's gate ordering (DeltaScanSupport.scala): the
+          // scheme gate runs before multiStoreReason, so the fallback reason below must still
+          // name viewfs, never "spans multiple object stores". This confirms that ordering
+          // end to end through declineReason, not merely at the unit level.
+          spark.range(10, 20).write.format("delta").mode("append").save(clonePath)
+
+          val df = spark.read.format("delta").load(clonePath)
+          assert(
+            deltaNativeScans(df).isEmpty,
+            "Expected no native Delta scan for a viewfs-selected-file clone:\n" +
+              s"${df.queryExecution.executedPlan}")
+          checkSparkAnswerAndFallbackReason(
+            df,
+            "Native Delta scan does not support selected data file or deletion vector " +
+              "filesystem scheme(s) viewfs")
+        }
+      }
+    } finally {
+      priorLinkFallback match {
+        case Some(v) => hadoopConf.set(linkFallbackKey, v)
+        case None => hadoopConf.unset(linkFallbackKey)
+      }
+    }
+  }
+
+  test("change data feed read never engages the native Delta scan, with correct results") {
+    // A batch readChangeFeed() query never reaches DeltaScanSupport.declineReason's own
+    // isCDCRead check at all: CDCReader wraps its answer in a DeltaCDFRelation whose buildScan
+    // executes its internal (possibly DeltaParquetFileFormat-backed) plan via queryExecution's
+    // RDD lineage directly, so the physical plan Spark and Comet's extensions ultimately see for
+    // this query is a single, opaque RowDataSourceScanExec, never a FileSourceScanExec
+    // DeltaScanSupport.isDeltaScan could recognize. This still pins the outcome that matters:
+    // Change Data Feed reads are never claimed by the native Delta scan and stay correct.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      // Change Data Feed must be enabled from the table's first version: CDC reads validate
+      // that change data was actually recorded for every version in the requested range.
+      spark.sql(s"""CREATE TABLE delta.`$path` (id LONG, v LONG) USING delta
+                   |TBLPROPERTIES ('delta.enableChangeDataFeed' = 'true')""".stripMargin)
+      spark.sql(s"INSERT INTO delta.`$path` SELECT id, id * 2 FROM range(0, 100)")
+      spark.sql(s"UPDATE delta.`$path` SET v = -1 WHERE id < 10")
+
+      val df = spark.read
+        .format("delta")
+        .option("readChangeFeed", "true")
+        .option("startingVersion", 0)
+        .load(path)
+      checkSparkAnswer(df)
+      assert(deltaNativeScans(df).isEmpty)
+      assert(df.count() > 0)
+    }
+  }
+
+  test("reader features: TIMESTAMP_NTZ column claims natively with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"CREATE TABLE delta.`$path` (id LONG, ts TIMESTAMP_NTZ) USING delta")
+      spark.sql(
+        s"INSERT INTO delta.`$path` VALUES " +
+          "(1, CAST('2021-01-01 00:00:00' AS TIMESTAMP_NTZ)), " +
+          "(2, CAST('2022-06-15 12:30:00' AS TIMESTAMP_NTZ))")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 2)
+    }
+  }
+
+  test("reader features: v2Checkpoint table claims natively with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"""CREATE TABLE delta.`$path` (id LONG, v LONG) USING delta
+                   |TBLPROPERTIES (
+                   |  'delta.checkpointPolicy' = 'v2',
+                   |  'delta.checkpointInterval' = '3')""".stripMargin)
+      for (i <- 0 until 5) {
+        spark
+          .range(i * 10L, (i + 1) * 10L)
+          .selectExpr("id", "id * 2 as v")
+          .write
+          .format("delta")
+          .mode("append")
+          .save(path)
+      }
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 50)
+    }
+  }
+
+  test(
+    "reader features: an unsupported reader feature (type widening) declines with the " +
+      "reader feature(s) reason") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.sql(s"""CREATE TABLE delta.`$path` (id SMALLINT) USING delta
+                   |TBLPROPERTIES ('delta.enableTypeWidening' = 'true')""".stripMargin)
+      spark
+        .range(0, 100)
+        .selectExpr("cast(id as smallint) as id")
+        .write
+        .format("delta")
+        .mode("append")
+        .save(path)
+      spark.sql(s"ALTER TABLE delta.`$path` ALTER COLUMN id TYPE INT")
+
+      val df = spark.read.format("delta").load(path)
+      checkSparkAnswerAndFallbackReason(
+        df,
+        "Native Delta scan does not support reader feature(s) typeWidening")
+      assert(deltaNativeScans(df).isEmpty)
+    }
+  }
+
+  test("_metadata.row_index declines before any deletion vector exists on a DV-enabled table") {
+    // _metadata.row_index only resolves on a Delta table once deletion-vector support is on
+    // the protocol (it errors as an unknown field otherwise); once it resolves, Delta always
+    // routes the read through the DV-application shape (a row-index column with no
+    // is_row_deleted alongside it), even with zero deletion vectors written yet. This pins that
+    // the hasRowIndex-without-hasIsRowDeleted gate declines this shape regardless of whether a
+    // DV has ever actually been written for the file.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id").write.format("delta").save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+
+      val df = spark.read
+        .format("delta")
+        .load(path)
+        .selectExpr("id", "_metadata.row_index as ri")
+      checkSparkAnswerAndFallbackReason(
+        df,
+        "Native Delta scan does not support row-index reads outside a deletion-vector scan")
+      assert(deltaNativeScans(df).isEmpty)
+      assert(df.count() == 100)
+    }
+  }
+
+  test(
+    "decline: parquet.crypto.factory.class configured declines conservatively even without " +
+      "actual encryption") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+
+      val hadoopConf = spark.sparkContext.hadoopConfiguration
+      val key = "parquet.crypto.factory.class"
+      val prior = Option(hadoopConf.get(key))
+      // A real, resolvable factory that explicitly allows plaintext files: the table itself is
+      // NOT encrypted, so this exercises Comet's stricter, conservative "decline ALL
+      // encrypted-parquet configurations" gate without breaking Spark's own read.
+      hadoopConf.set(key, "org.apache.parquet.crypto.keytools.PropertiesDrivenCryptoFactory")
+      try {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswerAndFallbackReason(
+          df,
+          "Native Delta scan does not support encrypted parquet")
+        assert(deltaNativeScans(df).isEmpty)
+        assert(df.count() == 100)
+      } finally {
+        prior match {
+          case Some(v) => hadoopConf.set(key, v)
+          case None => hadoopConf.unset(key)
+        }
+      }
+    }
+  }
+
+  test(
+    "deletion vectors: a data predicate deleting every row of one file still claims " +
+      "natively with correct results") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 40)
+        .selectExpr("id", "id % 2 as p", "id * 2 as v")
+        .repartition(2, col("p"))
+        .write
+        .format("delta")
+        .partitionBy("p")
+        .save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      // A data-column predicate (not purely a partition predicate) forces Delta through the
+      // row-level deletion-vector path rather than a metadata-only partition drop, even though
+      // every row in partition 1's file happens to match.
+      spark.sql(s"DELETE FROM delta.`$path` WHERE p = 1 AND v >= 0")
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 20)
+      assert(df.filter(col("p") === 1).count() == 0)
+    }
+  }
+
+  test(
+    "conf interactions: ANSI, case sensitivity, and disabled DPP leave claim/decline " +
+      "outcomes unchanged") {
+    withTempPath { claimDir =>
+      withTempPath { declineDir =>
+        val claimPath = claimDir.getAbsolutePath
+        val declinePath = declineDir.getAbsolutePath
+        spark.range(0, 200).selectExpr("id", "id * 2 as v").write.format("delta").save(claimPath)
+        spark.sql(s"""CREATE TABLE delta.`$declinePath` (id LONG, v LONG) USING delta
+                     |TBLPROPERTIES ('delta.columnMapping.mode' = 'id')""".stripMargin)
+        spark
+          .range(0, 200)
+          .selectExpr("id", "id * 2 as v")
+          .write
+          .format("delta")
+          .mode("append")
+          .save(declinePath)
+
+        val confVariants = Seq(
+          SQLConf.ANSI_ENABLED.key -> "true",
+          SQLConf.CASE_SENSITIVE.key -> "true",
+          SQLConf.DYNAMIC_PARTITION_PRUNING_ENABLED.key -> "false")
+
+        confVariants.foreach { case (key, value) =>
+          withSQLConf(key -> value) {
+            val claimDf = spark.read.format("delta").load(claimPath)
+            checkDeltaNativeScanAnswer(claimDf)
+
+            val declineDf = spark.read.format("delta").load(declinePath)
+            checkSparkAnswer(declineDf)
+            assert(
+              deltaNativeScans(declineDf).isEmpty,
+              s"expected id-mode column mapping to still decline under $key=$value")
+          }
+        }
+      }
+    }
+  }
+
+  test(
+    "deletion vectors: maxDeletedRowsPerFile boundary claims when cardinality exactly " +
+      "equals the limit (gate declines only when the limit is exceeded)") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 1000)
+        .selectExpr("id", "id * 2 as v")
+        .coalesce(1)
+        .write
+        .format("delta")
+        .save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      withSQLConf(DeltaScanConf.COMET_DELTA_MAX_DELETED_ROWS_PER_FILE.key -> "500") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+        assert(df.count() == 500)
+      }
+    }
+  }
+
+  // Both tests below pin caseSensitive=true purely to exercise the exact-match (non-folding)
+  // path for a non-ASCII column name. Native's case-insensitive name matching reproduces the
+  // JVM's `toLowerCase(Locale.ROOT)` fold (see `fold_names` in
+  // native/core/src/parquet/name_fold.rs), so caseSensitive=false would also read these
+  // correctly -- there is no decline gate involved here to route around.
+  test("unicode column names round-trip natively with correct results") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "true") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        spark.sql(s"CREATE TABLE delta.`$path` (id LONG, `名前` STRING) USING delta")
+        spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 'たろう'), (2, 'はなこ')")
+
+        val df = spark.sql(s"SELECT id, `名前` FROM delta.`$path` ORDER BY id")
+        checkDeltaNativeScanAnswer(df)
+        val rows = df.collect()
+        assert(rows.map(_.getString(1)).sameElements(Array("たろう", "はなこ")))
+      }
+    }
+  }
+
+  test("unicode and space-containing column names round-trip natively under column mapping") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "true") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        // A space is one of Parquet's disallowed schema-name characters, so the space-containing
+        // column can only be added AFTER column mapping (physical names) is already active --
+        // creating it inline at CREATE TABLE time fails before column mapping ever takes effect.
+        spark.sql(s"CREATE TABLE delta.`$path` (id LONG, `名前` STRING) USING delta")
+        enableColumnMapping(path)
+        spark.sql(s"ALTER TABLE delta.`$path` ADD COLUMN `a b` LONG")
+        spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 'たろう', 10), (2, 'はなこ', 20)")
+
+        val df = spark.sql(s"SELECT id, `名前`, `a b` FROM delta.`$path` ORDER BY id")
+        checkDeltaNativeScanAnswer(df)
+        val rows = df.collect()
+        assert(rows.map(_.getString(1)).sameElements(Array("たろう", "はなこ")))
+        assert(rows.map(_.getLong(2)).sameElements(Array(10L, 20L)))
+      }
+    }
+  }
+
+  test(
+    "a non-ASCII case-insensitive column name claims the native Delta scan with correct " +
+      "results") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        val table = "comet_unicode_" + java.util.UUID.randomUUID().toString.replace("-", "")
+        withTable(table) {
+          // Two plain parquet files whose footers differ only in the case of a non-ASCII letter
+          // (an ordinary CONVERT-eligible layout: no column mapping, no defaults, no DVs).
+          // Native's name matcher reproduces this JVM's `toLowerCase(Locale.ROOT)` from
+          // shipped case tables, which folds 'É'/'é' together just like Spark does.
+          spark.range(1, 2).select(col("id"), lit(71).as("É")).coalesce(1).write.parquet(path)
+          spark
+            .range(2, 3)
+            .select(col("id"), lit(72).as("é"))
+            .coalesce(1)
+            .write
+            .mode("append")
+            .parquet(path)
+
+          spark.sql(s"CREATE TABLE $table (id BIGINT, `É` INT) USING PARQUET LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+
+          val df = spark.read.format("delta").load(path).selectExpr("id", "`É`")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect().sortBy(_.getLong(0))
+          assert(rows.map(_.getInt(1)).sameElements(Array(71, 72)))
+        }
+      }
+    }
+  }
+
+  test(
+    "an ASCII case-insensitive column name still claims the native Delta scan with correct " +
+      "results") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        val table = "comet_ascii_case_" + java.util.UUID.randomUUID().toString.replace("-", "")
+        withTable(table) {
+          // Same shape as above, but the differing-case letter is plain ASCII, which native's
+          // name folding (`fold_names` in name_fold.rs) always matches correctly, ASCII being
+          // the easy case.
+          spark.range(1, 2).select(col("id"), lit(71).as("E")).coalesce(1).write.parquet(path)
+          spark
+            .range(2, 3)
+            .select(col("id"), lit(72).as("e"))
+            .coalesce(1)
+            .write
+            .mode("append")
+            .parquet(path)
+
+          spark.sql(s"CREATE TABLE $table (id BIGINT, `E` INT) USING PARQUET LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+
+          val df = spark.read.format("delta").load(path).selectExpr("id", "`E`")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect().sortBy(_.getLong(0))
+          assert(rows.map(_.getInt(1)).sameElements(Array(71, 72)))
+        }
+      }
+    }
+  }
+
+  test(
+    "a non-ASCII partition column name still claims the native Delta scan with correct " +
+      "results") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        // Partition values are injected into the output as constants by exact name match, never
+        // matched against a file's footer schema, so a non-ASCII partition name (data names stay
+        // plain ASCII here) never goes through native's case-insensitive DATA-column name
+        // folding (`fold_names` in name_fold.rs) at all.
+        spark
+          .range(0, 20)
+          .selectExpr("id", "cast(id % 4 as long) as `名前`")
+          .write
+          .format("delta")
+          .partitionBy("名前")
+          .save(path)
+
+        val df = spark.read.format("delta").load(path).filter(col("名前") === 2)
+        checkDeltaNativeScanAnswer(df)
+        assert(df.count() > 0)
+      }
+    }
+  }
+
+  test(
+    "a non-ASCII physical column name still claims the native Delta scan under column " +
+      "mapping with case-insensitive reads") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        // The column pre-exists the column-mapping upgrade, so Delta assigns its physical name
+        // as its current (non-ASCII) name verbatim -- exactly what a converted-then-upgraded
+        // table keeps. Logical and physical names are identical here, so this was always safe;
+        // it now also claims natively rather than being caught by a blanket non-ASCII gate.
+        spark.sql(s"CREATE TABLE delta.`$path` (id LONG, `É` STRING) USING delta")
+        enableColumnMapping(path)
+        spark.sql(s"INSERT INTO delta.`$path` VALUES (1, 'a'), (2, 'b')")
+
+        val df = spark.sql(s"SELECT id, `É` FROM delta.`$path` ORDER BY id")
+        checkDeltaNativeScanAnswer(df)
+        val rows = df.collect()
+        assert(rows.map(_.getString(1)).sameElements(Array("a", "b")))
+      }
+    }
+  }
+
+  test(
+    "a Kelvin sign physical column name in one file of an otherwise-ASCII CONVERTed table " +
+      "claims the native Delta scan with correct results") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        val table = "comet_kelvin_" + java.util.UUID.randomUUID().toString.replace("-", "")
+        withTable(table) {
+          // An ordinary CONVERT-eligible layout (no column mapping, no defaults, no DVs)
+          // where the table is declared with a plain ASCII "K" column, but one of its
+          // underlying Parquet files happens to have been written with a physical column
+          // literally named U+212A (KELVIN SIGN) -- not decomposable to ASCII by naive
+          // folding, but a case variant of ASCII 'k'/'K' under Java's `Character` mappings
+          // (and thus under Spark's `caseSensitive=false` resolution). Nothing on the JVM
+          // side can see this: the divergent name lives only in the second file's footer.
+          spark.range(1, 2).select(col("id"), lit(71).as("K")).coalesce(1).write.parquet(path)
+          spark
+            .range(2, 3)
+            .select(col("id"), lit(72).as("K"))
+            .coalesce(1)
+            .write
+            .mode("append")
+            .parquet(path)
+
+          spark.sql(s"CREATE TABLE $table (id BIGINT, `K` INT) USING PARQUET LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+
+          val df = spark.read.format("delta").load(path).selectExpr("id", "`K`")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect().sortBy(_.getLong(0))
+          assert(rows.map(_.getInt(1)).sameElements(Array(71, 72)))
+          assert(
+            df.filter(col("K").isNotNull).count() == 2,
+            "the Kelvin-sign-named file's row must not be nulled out by native")
+        }
+      }
+    }
+  }
+
+  test(
+    "a capital-sigma physical column name matches a final-sigma table column with correct " +
+      "results") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        val table = "comet_sigma_" + java.util.UUID.randomUUID().toString.replace("-", "")
+        withTable(table) {
+          // Java's `String.toLowerCase(Locale.ROOT)` lowers "A1Σ" to "a1ς" (FINAL
+          // sigma): its Final_Cased context scan runs on word boundaries, and the digit keeps
+          // "A1Σ" a single word, so the trailing sigma takes the final form. Spark's
+          // footer matching therefore folds physical "A1Σ" onto a requested "a1ς",
+          // and the value in that file must be read, not nulled. Nothing on the JVM side can
+          // see this: the divergent name lives only in the second file's footer.
+          spark
+            .range(1, 2)
+            .select(col("id"), lit(71).as("a1ς"))
+            .coalesce(1)
+            .write
+            .parquet(path)
+          spark
+            .range(2, 3)
+            .select(col("id"), lit(72).as("A1Σ"))
+            .coalesce(1)
+            .write
+            .mode("append")
+            .parquet(path)
+
+          spark.sql(s"CREATE TABLE $table (id BIGINT, `a1ς` INT) USING PARQUET LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+
+          val df = spark.read.format("delta").load(path).selectExpr("id", "`a1ς`")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect().sortBy(_.getLong(0))
+          assert(rows.map(_.getInt(1)).sameElements(Array(71, 72)))
+          assert(
+            df.filter(col("a1ς").isNotNull).count() == 2,
+            "the capital-sigma-named file's row must not be nulled out by native")
+        }
+      }
+    }
+  }
+
+  test("a capital-sigma physical column name is missing for a non-final-sigma table column") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        val table = "comet_sigma_miss_" + java.util.UUID.randomUUID().toString.replace("-", "")
+        withTable(table) {
+          // The inverse of the test above: "A1Σ" lowers to "a1ς", NOT "a1σ"
+          // (non-final sigma), so Spark's footer lookup treats a requested "a1σ" as
+          // MISSING in the capital-sigma file and substitutes NULL. Reading a value there
+          // (as a naive codepoint-wise fold would) surfaces a row Spark considers absent
+          // and breaks IS NOT NULL filters.
+          spark
+            .range(1, 2)
+            .select(col("id"), lit(71).as("a1σ"))
+            .coalesce(1)
+            .write
+            .parquet(path)
+          spark
+            .range(2, 3)
+            .select(col("id"), lit(72).as("A1Σ"))
+            .coalesce(1)
+            .write
+            .mode("append")
+            .parquet(path)
+
+          spark.sql(s"CREATE TABLE $table (id BIGINT, `a1σ` INT) USING PARQUET LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+
+          val df = spark.read.format("delta").load(path).selectExpr("id", "`a1σ`")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect().sortBy(_.getLong(0))
+          assert(rows.length == 2)
+          assert(rows(0).getInt(1) == 71)
+          assert(
+            rows(1).isNullAt(1),
+            "the capital-sigma file's column lowers to final sigma, so a non-final-sigma " +
+              "requested column must read as missing (NULL) there")
+        }
+      }
+    }
+  }
+
+  test("a Unicode-version-drift physical column name folds per the running JDK") {
+    withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        val table = "comet_drift_" + java.util.UUID.randomUUID().toString.replace("-", "")
+        withTable(table) {
+          // U+A7C0 (LATIN CAPITAL LETTER OLD POLISH O) gained its lowercase pairing U+A7C1
+          // in Unicode 14, after JDK 17's Unicode snapshot: JDK 17 lowers it to itself
+          // (no match against a U+A7C1 column), while JDK 21+ lowers it to U+A7C1 (match).
+          // The expectation is derived from the RUNNING JDK's own toLowerCase, so this test
+          // is correct on any JDK -- exactly the property the native matcher must mirror,
+          // since it consumes case tables generated by this same JVM at plan time.
+          val physicalFolds =
+            "Ꟁ".toLowerCase(java.util.Locale.ROOT) == "ꟁ"
+
+          spark
+            .range(1, 2)
+            .select(col("id"), lit(71).as("ꟁ"))
+            .coalesce(1)
+            .write
+            .parquet(path)
+          spark
+            .range(2, 3)
+            .select(col("id"), lit(72).as("Ꟁ"))
+            .coalesce(1)
+            .write
+            .mode("append")
+            .parquet(path)
+
+          spark.sql(s"CREATE TABLE $table (id BIGINT, `ꟁ` INT) USING PARQUET LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+
+          val df = spark.read.format("delta").load(path).selectExpr("id", "`ꟁ`")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect().sortBy(_.getLong(0))
+          assert(rows.length == 2)
+          assert(rows(0).getInt(1) == 71)
+          if (physicalFolds) {
+            assert(
+              !rows(1).isNullAt(1) && rows(1).getInt(1) == 72,
+              "this JDK folds U+A7C0 onto U+A7C1, so the value must be read")
+          } else {
+            assert(
+              rows(1).isNullAt(1),
+              "this JDK does not fold U+A7C0 onto U+A7C1, so the column must be missing")
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * Runs `action` under a [[SparkListener]] that captures every `onTaskEnd` input-metrics
+   * reading, then drains the listener bus before summing: the bus delivers `onTaskEnd`
+   * asynchronously, so `action` returning is not enough to guarantee every event has already been
+   * processed. Callers compare the sums against a floor rather than an exact target because
+   * Delta's own transaction-log state reconstruction runs a small auxiliary job reading the
+   * commit JSON, which legitimately contributes a few extra input records alongside the actual
+   * data scan. Returns the aggregated (recordsRead, bytesRead).
+   */
+  private def collectTaskInputMetrics(action: => Unit): (Long, Long) = {
+    val inputRecords = mutable.ArrayBuffer.empty[Long]
+    val inputBytes = mutable.ArrayBuffer.empty[Long]
+    val listener = new SparkListener {
+      override def onTaskEnd(taskEnd: SparkListenerTaskEnd): Unit = {
+        val im = taskEnd.taskMetrics.inputMetrics
+        inputRecords.synchronized { inputRecords += im.recordsRead }
+        inputBytes.synchronized { inputBytes += im.bytesRead }
+      }
+    }
+    spark.sparkContext.addSparkListener(listener)
+    try {
+      action
+      CometListenerBusUtils.waitUntilEmpty(spark.sparkContext)
+      (inputRecords.synchronized(inputRecords.sum), inputBytes.synchronized(inputBytes.sum))
+    } finally {
+      spark.sparkContext.removeSparkListener(listener)
+    }
+  }
+
+  test("standalone uncached delta read reports task-level input metrics") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 10000)
+        .selectExpr("id", "id * 2 as v")
+        .write
+        .format("delta")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path)
+      var collected = 0L
+      val (recordsRead, bytesRead) = collectTaskInputMetrics {
+        collected = df.collect().length.toLong
+      }
+
+      assert(collected == 10000L)
+      assert(
+        deltaNativeScans(df).nonEmpty,
+        s"expected a native Delta scan:\n${df.queryExecution.executedPlan}")
+      assert(
+        recordsRead >= 10000L,
+        s"expected task input recordsRead to cover the row count, got $recordsRead")
+      assert(bytesRead > 0L, s"expected task input bytesRead > 0, got $bytesRead")
+    }
+  }
+
+  test("fused aggregate over a delta scan reports task-level input metrics") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark
+        .range(0, 10000)
+        .selectExpr("id", "id % 13 as g", "id * 2 as v")
+        .write
+        .format("delta")
+        .save(path)
+
+      val df = spark.read.format("delta").load(path).groupBy("g").sum("v")
+      val (recordsRead, bytesRead) = collectTaskInputMetrics {
+        df.collect()
+      }
+
+      assert(
+        deltaNativeScans(df).nonEmpty,
+        s"expected the native Delta scan fused into the aggregate:\n${df.queryExecution.executedPlan}")
+      assert(
+        recordsRead >= 10000L,
+        s"expected task input recordsRead to cover the scanned row count, got $recordsRead")
+      assert(bytesRead > 0L, s"expected task input bytesRead > 0, got $bytesRead")
+    }
+  }
+
+  /** Write `values` rows (id, d, ts) as a Delta table with the given write-side rebase modes. */
+  private def writeRebaseTable(
+      path: String,
+      timeZone: String,
+      datetimeMode: String,
+      int96Mode: String,
+      values: String): Unit = {
+    withSQLConf(
+      SQLConf.SESSION_LOCAL_TIMEZONE.key -> timeZone,
+      "spark.sql.parquet.datetimeRebaseModeInWrite" -> datetimeMode,
+      "spark.sql.parquet.int96RebaseModeInWrite" -> int96Mode) {
+      spark
+        .sql(s"select * from values $values as t(id, d, ts)")
+        .write
+        .format("delta")
+        .save(path)
+    }
+  }
+
+  test("legacy-rebase ancient dates and timestamps match Spark's own read") {
+    // Spark stamps org.apache.spark.legacyDateTime / legacyINT96 / timeZone into the file
+    // footer when writing with LEGACY rebase modes, and its own reader rebases based on that
+    // per-file metadata regardless of the session's read-mode conf. The native scan must
+    // resolve the same per-file policy: without rebasing, 1500-01-01 reads as 1500-01-10.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRebaseTable(
+        path,
+        timeZone = "UTC",
+        datetimeMode = "LEGACY",
+        int96Mode = "LEGACY",
+        values = "(1, date'0001-01-01', timestamp'1500-01-01 00:00:00'), " +
+          "(2, date'1500-01-01', timestamp'1582-10-04 23:59:59'), " +
+          "(3, date'1582-10-04', timestamp'0001-01-01 00:00:00'), " +
+          "(4, date'2024-06-01', timestamp'2024-06-01 12:00:00')")
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+      }
+    }
+  }
+
+  test("predicate on a legacy-rebase ancient date matches Spark") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRebaseTable(
+        path,
+        timeZone = "UTC",
+        datetimeMode = "LEGACY",
+        int96Mode = "LEGACY",
+        values = "(1, date'1500-01-01', timestamp'1500-01-01 00:00:00'), " +
+          "(2, date'1500-02-11', timestamp'1500-02-11 00:00:00'), " +
+          "(3, date'2024-06-01', timestamp'2024-06-01 12:00:00')")
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC") {
+        val df = spark.read
+          .format("delta")
+          .load(path)
+          .filter("d = date'1500-01-01'")
+        checkDeltaNativeScanAnswer(df)
+      }
+    }
+  }
+
+  test("legacy-rebase file holding only modern values stays native and correct") {
+    // Rebasing is the identity from 1582-10-15 onward, so a LEGACY-stamped file whose values
+    // are all modern must keep reading natively with unchanged results.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRebaseTable(
+        path,
+        timeZone = "UTC",
+        datetimeMode = "LEGACY",
+        int96Mode = "LEGACY",
+        values = "(1, date'1990-01-01', timestamp'1990-01-01 00:00:00'), " +
+          "(2, date'2024-06-01', timestamp'2024-06-01 12:00:00')")
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+      }
+    }
+  }
+
+  test(
+    "legacy-rebase ancient timestamps with a non-UTC writer zone fail loudly instead of " +
+      "returning shifted values") {
+    // Timestamp rebasing outside a fixed UTC writer zone needs the JVM's historical timezone
+    // tables; the native reader refuses ancient values rather than guessing.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRebaseTable(
+        path,
+        timeZone = "America/Los_Angeles",
+        datetimeMode = "LEGACY",
+        int96Mode = "LEGACY",
+        values = "(1, date'2024-06-01', timestamp'1500-01-01 00:00:00')")
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "America/Los_Angeles") {
+        val e = intercept[Exception] {
+          spark.read.format("delta").load(path).collect()
+        }
+        val messages = Iterator
+          .iterate(e: Throwable)(_.getCause)
+          .takeWhile(_ != null)
+          .map(_.getMessage)
+          .mkString("\n")
+        assert(messages.contains("rebase"), s"expected a calendar-rebase error, got:\n$messages")
+      }
+    }
+  }
+
+  test("mixed rebase flags attribute each timestamp column to its physical type's flag") {
+    // legacyDateTime governs INT64 timestamps while legacyINT96 governs INT96 ones. A file
+    // carrying exactly one of the two flags must read every timestamp column under the flag
+    // of its own physical type -- rebased exactly when that flag is LEGACY, verbatim when it
+    // is not -- matching Spark's own read, instead of refusing ancient values because the two
+    // flags disagree. All four (physical type, mode pair) combinations round-trip
+    // 1500-01-01 00:00:00.
+    for ((outputType, datetimeMode, int96Mode) <- Seq(
+        ("TIMESTAMP_MICROS", "LEGACY", "CORRECTED"),
+        ("TIMESTAMP_MICROS", "CORRECTED", "LEGACY"),
+        ("INT96", "LEGACY", "CORRECTED"),
+        ("INT96", "CORRECTED", "LEGACY"))) {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        withSQLConf("spark.sql.parquet.outputTimestampType" -> outputType) {
+          writeRebaseTable(
+            path,
+            timeZone = "UTC",
+            datetimeMode = datetimeMode,
+            int96Mode = int96Mode,
+            values = "(1, date'2024-06-01', timestamp'1500-01-01 00:00:00'), " +
+              "(2, date'2024-06-01', timestamp'2024-06-01 12:00:00')")
+        }
+        withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.selectExpr("id", "cast(ts as string)").collect().sortBy(_.getInt(0))
+          assert(
+            rows(0).getString(1) == "1500-01-01 00:00:00",
+            s"$outputType/$datetimeMode/$int96Mode: got ${rows(0)}")
+        }
+      }
+    }
+  }
+
+  /**
+   * Write one raw parquet file through parquet-mr's example writer: NO Spark writer metadata
+   * (`org.apache.spark.version` and friends) lands in the footer, the shape any non-Spark writer
+   * produces. Spark resolves such files' rebase policy from the session read modes
+   * (`DataSourceUtils.getRebaseSpec`'s `modeByConfig` fallback), so the native scan must too.
+   * Rows are (id, days-since-epoch date, micros-since-epoch UTC timestamp).
+   */
+  private def writeNonSparkParquetFile(
+      dir: String,
+      rows: Seq[(Int, Option[Int], Option[Long])]): Unit = {
+    writeRawParquetFile(
+      dir,
+      """message m {
+        |  required int32 id;
+        |  optional int32 d (DATE);
+        |  optional int64 ts (TIMESTAMP_MICROS);
+        |}""".stripMargin) { factory =>
+      rows.map { case (id, d, ts) =>
+        val group = factory.newGroup().append("id", id)
+        d.foreach(group.append("d", _))
+        ts.foreach(group.append("ts", _))
+        group
+      }
+    }
+  }
+
+  /**
+   * Write one raw parquet file of the given parquet-mr `schema` (message type syntax) with the
+   * groups `rows` builds from a factory for that schema. Like [[writeNonSparkParquetFile]], no
+   * Spark writer metadata lands in the footer.
+   */
+  private def writeRawParquetFile(dir: String, schema: String)(
+      rows: org.apache.parquet.example.data.simple.SimpleGroupFactory => Seq[
+        org.apache.parquet.example.data.Group]): Unit = {
+    import org.apache.parquet.example.data.simple.SimpleGroupFactory
+    import org.apache.parquet.hadoop.example.{ExampleParquetWriter, GroupWriteSupport}
+    import org.apache.parquet.schema.MessageTypeParser
+    val messageType = MessageTypeParser.parseMessageType(schema)
+    val conf = new org.apache.hadoop.conf.Configuration()
+    GroupWriteSupport.setSchema(messageType, conf)
+    val writer = ExampleParquetWriter
+      .builder(new org.apache.hadoop.fs.Path(s"$dir/part-00000.parquet"))
+      .withConf(conf)
+      .build()
+    try {
+      rows(new SimpleGroupFactory(messageType)).foreach(writer.write)
+    } finally {
+      writer.close()
+    }
+  }
+
+  /**
+   * The 12-byte INT96 encoding of midnight on the day `days` after 1970-01-01: 8 bytes of
+   * nanos-of-day then the 4-byte Julian Day Number (2440588 + days), both little-endian, the
+   * layout Spark's `ParquetRowConverter.binaryToSQLTimestamp` decodes.
+   */
+  private def int96Midnight(days: Int): org.apache.parquet.io.api.Binary = {
+    val buf = java.nio.ByteBuffer.allocate(12).order(java.nio.ByteOrder.LITTLE_ENDIAN)
+    buf.putLong(0L).putInt(2440588 + days)
+    org.apache.parquet.io.api.Binary.fromConstantByteArray(buf.array())
+  }
+
+  /** Collect every message down the cause chain of `e`, newline-joined. */
+  private def causeMessages(e: Throwable): String =
+    Iterator.iterate(e)(_.getCause).takeWhile(_ != null).map(_.getMessage).mkString("\n")
+
+  /** Spark's `RebaseDateTime.lastSwitchJulianTs`: 1900-01-01T00:00:00Z in micros. */
+  private val LastSwitchJulianMicros = -2208988800000000L
+
+  test(
+    "non-Spark INT64 timestamps at or after 1900-01-01 read verbatim under EXCEPTION read " +
+      "modes") {
+    // Spark's EXCEPTION read mode refuses only timestamps before
+    // RebaseDateTime.lastSwitchJulianTs (1900-01-01T00:00:00Z, the last instant at which
+    // rebasing changes a value in any zone), converting MILLIS columns to micros first; a
+    // timestamp one microsecond before the epoch is well inside the accepted range.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(
+        path,
+        """message m {
+          |  required int32 id;
+          |  optional int64 ts_us (TIMESTAMP(MICROS,true));
+          |  optional int64 ts_ms (TIMESTAMP(MILLIS,true));
+          |}""".stripMargin) { factory =>
+        Seq(
+          factory.newGroup().append("id", 1).append("ts_us", -1L).append("ts_ms", -1L),
+          factory
+            .newGroup()
+            .append("id", 2)
+            .append("ts_us", LastSwitchJulianMicros)
+            .append("ts_ms", LastSwitchJulianMicros / 1000),
+          factory
+            .newGroup()
+            .append("id", 3)
+            .append("ts_us", 1717243200000000L)
+            .append("ts_ms", 1717243200000L),
+          factory.newGroup().append("id", 4))
+      }
+      val table = "comet_nonspark_1900_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(
+          s"CREATE TABLE $table (id INT, ts_us TIMESTAMP, ts_ms TIMESTAMP) USING PARQUET " +
+            s"LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(ts_us as string)", "cast(ts_ms as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1969-12-31 23:59:59.999999", s"got ${rows(0)}")
+          assert(rows(0).getString(2) == "1969-12-31 23:59:59.999", s"got ${rows(0)}")
+          assert(rows(1).getString(1) == "1900-01-01 00:00:00", s"got ${rows(1)}")
+          assert(rows(1).getString(2) == "1900-01-01 00:00:00", s"got ${rows(1)}")
+          assert(rows(2).getString(1) == "2024-06-01 12:00:00", s"got ${rows(2)}")
+          assert(rows(3).isNullAt(1) && rows(3).isNullAt(2), s"got ${rows(3)}")
+        }
+      }
+    }
+  }
+
+  test("non-Spark INT64 timestamps before 1900-01-01 fail loudly under EXCEPTION read modes") {
+    // One millisecond before the cutoff, in a MILLIS column: Spark converts to micros before
+    // comparing against lastSwitchJulianTs and raises; the native scan must raise too.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(
+        path,
+        """message m {
+          |  required int32 id;
+          |  optional int64 ts_ms (TIMESTAMP(MILLIS,true));
+          |}""".stripMargin) { factory =>
+        Seq(factory.newGroup().append("id", 1).append("ts_ms", LastSwitchJulianMicros / 1000 - 1))
+      }
+      val table = "comet_nonspark_1899_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(s"CREATE TABLE $table (id INT, ts_ms TIMESTAMP) USING PARQUET LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val messages = causeMessages(e)
+          assert(
+            messages.contains("Native scan cannot rebase") && messages.contains("'ts_ms'"),
+            s"expected the native calendar-rebase error on ts_ms, got:\n$messages")
+        }
+      }
+    }
+  }
+
+  /** A raw file with one INT64 MICROS timestamp (`ts`) and one INT96 timestamp (`ts96`). */
+  private def writeInt64AndInt96File(dir: String, tsMicros: Long, int96Days: Int): Unit = {
+    writeRawParquetFile(
+      dir,
+      """message m {
+        |  required int32 id;
+        |  optional int64 ts (TIMESTAMP(MICROS,true));
+        |  optional int96 ts96;
+        |}""".stripMargin) { factory =>
+      Seq(
+        factory
+          .newGroup()
+          .append("id", 1)
+          .append("ts", tsMicros)
+          .append("ts96", int96Midnight(int96Days)),
+        factory.newGroup().append("id", 2))
+    }
+  }
+
+  /** Proleptic 1500-01-01 as days / micros since the epoch. */
+  private val AncientDays = -171664
+  private val AncientMicros = AncientDays.toLong * 86400000000L
+
+  test("non-Spark INT64 timestamps follow the datetime read mode when the INT96 mode differs") {
+    // Spark selects datetimeRebaseSpec for INT64 MICROS/MILLIS columns and int96RebaseSpec only
+    // for INT96 columns. Under datetime CORRECTED + int96 EXCEPTION an ancient INT64 value reads
+    // verbatim; it must not be refused just because the INT96 spec would refuse an ancient
+    // INT96 value (the INT96 column holds a modern one here).
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeInt64AndInt96File(path, AncientMicros, int96Days = 19875)
+      val table = "comet_int64_vs_int96_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(
+          s"CREATE TABLE $table (id INT, ts TIMESTAMP, ts96 TIMESTAMP) USING PARQUET " +
+            s"LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "CORRECTED",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(ts as string)", "cast(ts96 as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1500-01-01 00:00:00", s"got ${rows(0)}")
+          assert(rows(0).getString(2) == "2024-06-01 00:00:00", s"got ${rows(0)}")
+          assert(rows(1).isNullAt(1) && rows(1).isNullAt(2), s"got ${rows(1)}")
+        }
+      }
+    }
+  }
+
+  test("non-Spark INT96 timestamps follow the INT96 read mode") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeInt64AndInt96File(path, tsMicros = 0L, int96Days = AncientDays)
+      val table = "comet_int96_policy_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(
+          s"CREATE TABLE $table (id INT, ts TIMESTAMP, ts96 TIMESTAMP) USING PARQUET " +
+            s"LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        // datetime CORRECTED + int96 EXCEPTION: the ancient INT96 value is refused, naming the
+        // INT96 column (the INT64 column's epoch value is fine under either spec).
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "CORRECTED",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val messages = causeMessages(e)
+          assert(
+            messages.contains("Native scan cannot rebase") && messages.contains("'ts96'"),
+            s"expected the native calendar-rebase error on ts96, got:\n$messages")
+        }
+        // Mirror image: datetime EXCEPTION + int96 CORRECTED reads the ancient INT96 value
+        // verbatim (Spark decodes the Julian Day Number directly, no calendar involved).
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "CORRECTED") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(ts as string)", "cast(ts96 as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1970-01-01 00:00:00", s"got ${rows(0)}")
+          assert(rows(0).getString(2) == "1500-01-01 00:00:00", s"got ${rows(0)}")
+        }
+      }
+    }
+  }
+
+  /** Proleptic 1800-01-01T00:00:00Z in days and micros: before Spark's 1900-01-01 cutoff. */
+  private val Days1800 = -62091
+  private val Micros1800 = Days1800.toLong * 86400000000L
+
+  test("non-Spark tz-free INT64 timestamps read as TIMESTAMP follow the datetime read mode") {
+    // Spark's ParquetVectorUpdaterFactory keys on the requested type and checks only the unit
+    // of an INT64 timestamp annotation, so a TIMESTAMP(MICROS, isAdjustedToUTC=false) column
+    // read as TIMESTAMP goes through LongWithRebaseUpdater under datetimeRebaseModeInRead:
+    // EXCEPTION refuses the ancient value, CORRECTED reads it verbatim.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(
+        path,
+        """message m {
+          |  required int32 id;
+          |  optional int64 ts (TIMESTAMP(MICROS,false));
+          |}""".stripMargin) { factory =>
+        Seq(
+          factory.newGroup().append("id", 1).append("ts", Micros1800),
+          factory.newGroup().append("id", 2))
+      }
+      val table = "comet_tzfree_as_ltz_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(s"CREATE TABLE $table (id INT, ts TIMESTAMP) USING PARQUET LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "CORRECTED") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val messages = causeMessages(e)
+          assert(
+            messages.contains("Native scan cannot rebase") && messages.contains("'ts'"),
+            s"expected the native calendar-rebase error on ts, got:\n$messages")
+          // Spark's own reader refuses the same value under EXCEPTION.
+          withSQLConf(DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key -> "false") {
+            val sparkError = intercept[Exception] {
+              spark.read.format("delta").load(path).collect()
+            }
+            // SparkUpgradeException is private[spark], so match it by name.
+            val causes = Iterator.iterate(sparkError: Throwable)(_.getCause).takeWhile(_ != null)
+            assert(
+              causes.exists(_.getClass.getName == "org.apache.spark.SparkUpgradeException"),
+              s"expected Spark's own rebase error, got:\n${causeMessages(sparkError)}")
+          }
+        }
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "CORRECTED",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.selectExpr("id", "cast(ts as string)").collect().sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1800-01-01 00:00:00", s"got ${rows(0)}")
+          assert(rows(1).isNullAt(1), s"got ${rows(1)}")
+        }
+        // LEGACY without a recorded writer zone needs the JVM's default zone, which the native
+        // scan cannot know: it refuses rather than guessing.
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "LEGACY",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "CORRECTED") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val messages = causeMessages(e)
+          assert(
+            messages.contains("Native scan cannot rebase") &&
+              messages.contains("timezone tables"),
+            s"expected the native writer-zone error on ts, got:\n$messages")
+        }
+      }
+    }
+  }
+
+  test("INT96 and adjusted INT64 timestamps read as TIMESTAMP_NTZ are never rebased") {
+    // Spark 4.x reads INT96 as TIMESTAMP_NTZ through BinaryToSQLTimestampUpdater and adjusted
+    // INT64 through LongUpdater; neither consults a rebase mode, so ancient values read as
+    // stored even under EXCEPTION. Spark 3.x refuses these pairings up front (SPARK-36182).
+    assume(isSpark40Plus)
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(
+        path,
+        """message m {
+          |  required int32 id;
+          |  optional int96 ts96;
+          |  optional int64 ts64 (TIMESTAMP(MICROS,true));
+          |}""".stripMargin) { factory =>
+        Seq(
+          factory
+            .newGroup()
+            .append("id", 1)
+            .append("ts96", int96Midnight(Days1800))
+            .append("ts64", Micros1800),
+          factory.newGroup().append("id", 2))
+      }
+      val table = "comet_ltz_as_ntz_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(
+          s"CREATE TABLE $table (id INT, ts96 TIMESTAMP_NTZ, ts64 TIMESTAMP_NTZ) USING PARQUET " +
+            s"LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(ts96 as string)", "cast(ts64 as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1800-01-01 00:00:00", s"got ${rows(0)}")
+          assert(rows(0).getString(2) == "1800-01-01 00:00:00", s"got ${rows(0)}")
+          assert(rows(1).isNullAt(1) && rows(1).isNullAt(2), s"got ${rows(1)}")
+        }
+      }
+    }
+  }
+
+  test("ancient timestamps and dates read as BIGINT and INT are never rebase-checked") {
+    // Spark's ParquetVectorUpdaterFactory picks LongUpdater for INT64 read as BIGINT and
+    // IntegerUpdater for INT32 read as INT before any timestamp or date arm, so the stored
+    // integers come back unchanged even under EXCEPTION. NANOS columns read as BIGINT only with
+    // spark.sql.legacy.parquet.nanosAsLong.
+    val nanos1800 = Micros1800 * 1000L
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(
+        path,
+        """message m {
+          |  required int32 id;
+          |  required int64 v (TIMESTAMP(NANOS,true));
+          |  optional int64 us (TIMESTAMP(MICROS,true));
+          |  optional int32 d (DATE);
+          |}""".stripMargin) { factory =>
+        Seq(
+          factory
+            .newGroup()
+            .append("id", 1)
+            .append("v", nanos1800)
+            .append("us", Micros1800)
+            .append("d", Days1800),
+          factory.newGroup().append("id", 2).append("v", 1717243200000000000L))
+      }
+      val table = "comet_temporal_as_int_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withSQLConf("spark.sql.legacy.parquet.nanosAsLong" -> "true") {
+        withTable(table) {
+          spark.sql(
+            s"CREATE TABLE $table (id INT, v BIGINT, us BIGINT, d INT) USING PARQUET " +
+              s"LOCATION '$path'")
+          spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+          withSQLConf(
+            SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+            "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+            "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+            val df = spark.read.format("delta").load(path)
+            checkDeltaNativeScanAnswer(df)
+            val rows = df.collect().sortBy(_.getInt(0))
+            assert(rows(0) == Row(1, nanos1800, Micros1800, Days1800), s"got ${rows(0)}")
+            assert(rows(1) == Row(2, 1717243200000000000L, null, null), s"got ${rows(1)}")
+          }
+        }
+      }
+    }
+  }
+
+  test("a plain INT32 column read as DATE follows the datetime read mode") {
+    // Spark's ParquetVectorUpdaterFactory picks the INT32 updater from the requested type, so
+    // an INT32 column without a DATE annotation, declared DATE by the table, goes through
+    // IntegerWithRebaseUpdater under datetimeRebaseModeInRead like a DATE column does.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(
+        path,
+        """message m {
+          |  required int32 id;
+          |  optional int32 v;
+          |}""".stripMargin) { factory =>
+        Seq(
+          factory.newGroup().append("id", 1).append("v", -171655),
+          factory.newGroup().append("id", 2).append("v", 19875),
+          factory.newGroup().append("id", 3))
+      }
+      val table = "comet_int_as_date_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        spark.sql(s"CREATE TABLE $table (id INT, v DATE) USING PARQUET LOCATION '$path'")
+        spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+        Seq("LEGACY" -> "1500-01-01", "CORRECTED" -> "1500-01-10").foreach {
+          case (mode, expected) =>
+            withSQLConf(
+              SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+              "spark.sql.parquet.datetimeRebaseModeInRead" -> mode) {
+              val df = spark.read.format("delta").load(path).selectExpr("id", "cast(v as string)")
+              checkDeltaNativeScanAnswer(df)
+              val rows = df.collect().sortBy(_.getInt(0)).toSeq
+              assert(
+                rows == Seq(Row(1, expected), Row(2, "2024-06-01"), Row(3, null)),
+                s"$mode: got $rows")
+            }
+        }
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val causes = Iterator.iterate(e: Throwable)(_.getCause).takeWhile(_ != null).toSeq
+          assert(
+            causes.exists(c =>
+              c.getClass.getName == "org.apache.comet.CometNativeException" &&
+                c.getMessage.contains("Native scan cannot rebase") &&
+                c.getMessage.contains("'v'")),
+            s"expected the native calendar-rebase error on v, got:\n${causeMessages(e)}")
+          withSQLConf(DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key -> "false") {
+            val sparkError = intercept[Exception] {
+              spark.read.format("delta").load(path).collect()
+            }
+            val sparkCauses =
+              Iterator.iterate(sparkError: Throwable)(_.getCause).takeWhile(_ != null)
+            assert(
+              sparkCauses.exists(_.getClass.getName == "org.apache.spark.SparkUpgradeException"),
+              s"expected Spark's own rebase error, got:\n${causeMessages(sparkError)}")
+          }
+        }
+      }
+    }
+  }
+
+  private val NestedRawSchema = """message m {
+      |  required int32 id;
+      |  optional group s {
+      |    optional int32 d (DATE);
+      |    optional int64 ts (TIMESTAMP(MICROS,true));
+      |  }
+      |  optional group l (LIST) {
+      |    repeated group list {
+      |      optional int32 element (DATE);
+      |    }
+      |  }
+      |}""".stripMargin
+
+  private def createNestedRawTable(table: String, path: String): Unit = {
+    spark.sql(
+      s"CREATE TABLE $table (id INT, s STRUCT<d: DATE, ts: TIMESTAMP>, l ARRAY<DATE>) " +
+        s"USING PARQUET LOCATION '$path'")
+    spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+  }
+
+  test(
+    "metadata-free nested columns with modern and null datetime leaves stay native under " +
+      "EXCEPTION read modes") {
+    // EXCEPTION only refuses values that actually are ancient; a STRUCT<d: DATE, ts: TIMESTAMP>
+    // and an ARRAY<DATE> holding modern and null leaves must read natively, not be rejected
+    // up front for being nested.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(path, NestedRawSchema) { factory =>
+        val g1 = factory.newGroup().append("id", 1)
+        g1.addGroup("s").append("d", 19875).append("ts", 1717243200000000L)
+        val l1 = g1.addGroup("l")
+        l1.addGroup("list").append("element", 19875)
+        l1.addGroup("list")
+        val g2 = factory.newGroup().append("id", 2)
+        g2.addGroup("s")
+        g2.addGroup("l")
+        val g3 = factory.newGroup().append("id", 3)
+        Seq(g1, g2, g3)
+      }
+      val table = "comet_nested_modern_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        createNestedRawTable(table, path)
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(s.d as string)", "cast(s.ts as string)", "cast(l as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "2024-06-01", s"got ${rows(0)}")
+          assert(rows(0).getString(2) == "2024-06-01 12:00:00", s"got ${rows(0)}")
+          assert(rows(0).getString(3) == "[2024-06-01, null]", s"got ${rows(0)}")
+          assert(rows(1).isNullAt(1) && rows(1).isNullAt(2), s"got ${rows(1)}")
+          assert(rows(1).getString(3) == "[]", s"got ${rows(1)}")
+          assert(rows(2).isNullAt(1) && rows(2).isNullAt(3), s"got ${rows(2)}")
+        }
+      }
+    }
+  }
+
+  test(
+    "metadata-free nested columns with an ancient date leaf fail loudly under EXCEPTION read " +
+      "modes") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(path, NestedRawSchema) { factory =>
+        val g1 = factory.newGroup().append("id", 1)
+        g1.addGroup("s").append("d", -171655)
+        Seq(g1)
+      }
+      val table = "comet_nested_ancient_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        createNestedRawTable(table, path)
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val messages = causeMessages(e)
+          assert(
+            messages.contains("Native scan cannot rebase") && messages.contains("'s'"),
+            s"expected the native calendar-rebase error on s, got:\n$messages")
+        }
+      }
+    }
+  }
+
+  test(
+    "only the requested nested leaves are rebase-checked: an unrequested ancient s.ts does not " +
+      "block select s.d under EXCEPTION read modes") {
+    // A metadata-free file with s.d = 2024-06-01 next to s.ts = 1500-01-01. Spark's requested
+    // schema for `select s.d` is STRUCT<d>, so Spark never decodes s.ts and reads the modern
+    // date fine; the native scan must not refuse the row for a leaf the schema adapter's struct
+    // narrowing drops. Requesting the ancient leaf itself still fails loudly.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeRawParquetFile(path, NestedRawSchema) { factory =>
+        val g1 = factory.newGroup().append("id", 1)
+        g1.addGroup("s").append("d", 19875).append("ts", AncientMicros)
+        Seq(g1)
+      }
+      val table =
+        "comet_nested_requested_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        createNestedRawTable(table, path)
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val df = spark.read.format("delta").load(path).selectExpr("id", "cast(s.d as string)")
+          checkDeltaNativeScanAnswer(df)
+          val rows = df.collect()
+          assert(rows.length == 1 && rows(0).getString(1) == "2024-06-01", s"got ${rows.toSeq}")
+
+          for (projection <- Seq("s", "s.ts")) {
+            val e = intercept[Exception] {
+              spark.read.format("delta").load(path).selectExpr(projection).collect()
+            }
+            val messages = causeMessages(e)
+            assert(
+              messages.contains("Native scan cannot rebase") && messages.contains("'s'"),
+              s"expected the native calendar-rebase error on s for `select $projection`, " +
+                s"got:\n$messages")
+          }
+        }
+      }
+    }
+  }
+
+  test("legacy-rebase ancient datetime values inside nested columns match Spark's own read") {
+    // Spark rebases dates and timestamps at every nesting depth; a LEGACY (UTC) file with
+    // ancient leaves inside a struct, an array, a map and an array of structs must read
+    // natively with exactly Spark's rebased values, nulls and offsets preserved.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      withSQLConf(
+        SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+        "spark.sql.parquet.datetimeRebaseModeInWrite" -> "LEGACY",
+        "spark.sql.parquet.int96RebaseModeInWrite" -> "LEGACY") {
+        spark
+          .sql("select * from values " +
+            "(1, named_struct('d', date'1500-01-01', 'ts', timestamp'1500-01-01 12:34:56'), " +
+            "array(date'1500-01-01', null, date'2024-06-01'), " +
+            "map(1, date'1582-10-04', 2, cast(null as date)), " +
+            "array(named_struct('d', date'0001-01-01'), named_struct('d', cast(null as date)))), " +
+            "(2, named_struct('d', cast(null as date), 'ts', cast(null as timestamp)), " +
+            "array(), map(), array(cast(null as struct<d: date>))), " +
+            "(3, cast(null as struct<d: date, ts: timestamp>), cast(null as array<date>), " +
+            "cast(null as map<int, date>), cast(null as array<struct<d: date>>)) " +
+            "as t(id, s, l, m, ls)")
+          .write
+          .format("delta")
+          .save(path)
+      }
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+        val rows = df
+          .selectExpr(
+            "id",
+            "cast(s.d as string)",
+            "cast(s.ts as string)",
+            "cast(l as string)",
+            "cast(m as string)",
+            "cast(ls as string)")
+          .collect()
+          .sortBy(_.getInt(0))
+        assert(rows(0).getString(1) == "1500-01-01", s"got ${rows(0)}")
+        assert(rows(0).getString(2) == "1500-01-01 12:34:56", s"got ${rows(0)}")
+        assert(rows(0).getString(3) == "[1500-01-01, null, 2024-06-01]", s"got ${rows(0)}")
+        assert(rows(0).getString(4) == "{1 -> 1582-10-04, 2 -> null}", s"got ${rows(0)}")
+        assert(rows(0).getString(5) == "[{0001-01-01}, {null}]", s"got ${rows(0)}")
+        assert(rows(1).isNullAt(1) && rows(1).isNullAt(2), s"got ${rows(1)}")
+        assert(rows(1).getString(3) == "[]" && rows(1).getString(4) == "{}", s"got ${rows(1)}")
+        assert(rows(1).getString(5) == "[null]", s"got ${rows(1)}")
+        assert((1 to 5).forall(rows(2).isNullAt), s"got ${rows(2)}")
+      }
+    }
+  }
+
+  /** Register `path`'s raw parquet files as an external table and CONVERT it to Delta. */
+  private def convertRawParquetToDelta(path: String, table: String): Unit = {
+    spark.sql(
+      s"CREATE TABLE $table (id INT, d DATE, ts TIMESTAMP) USING PARQUET LOCATION '$path'")
+    spark.sql(s"CONVERT TO DELTA $table NO STATISTICS")
+  }
+
+  test("non-Spark parquet files read ancient values verbatim under CORRECTED read modes") {
+    // A converted table over a file with no Spark writer metadata: getRebaseSpec resolves the
+    // policy from the session read modes (Spark 4.0 defaults both to CORRECTED), so a
+    // proleptic 1500-01-01 (day -171664) and a timestamp one microsecond before the epoch
+    // must read natively exactly as stored.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeNonSparkParquetFile(
+        path,
+        Seq(
+          (1, Some(-171664), Some(-1L)),
+          (2, Some(19875), Some(1717243200000000L)),
+          (3, None, None)))
+      val table =
+        "comet_nonspark_corrected_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        convertRawParquetToDelta(path, table)
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "CORRECTED",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "CORRECTED") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(d as string)", "cast(ts as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1500-01-01", s"got ${rows(0)}")
+          assert(rows(0).getString(2) == "1969-12-31 23:59:59.999999", s"got ${rows(0)}")
+          assert(rows(1).getString(1) == "2024-06-01", s"got ${rows(1)}")
+          assert(rows(2).isNullAt(1) && rows(2).isNullAt(2), s"got ${rows(2)}")
+        }
+      }
+    }
+  }
+
+  test("non-Spark parquet files rebase ancient dates under LEGACY read modes") {
+    // LEGACY read modes on a file without writer metadata: the stored day count is hybrid
+    // Julian + Gregorian, so Julian 1500-01-01 (stored as -171655) must rebase to proleptic
+    // 1500-01-01, matching Spark's own LEGACY read (the day rebase is timezone-free).
+    // Timestamps stay modern: rebasing ancient ones needs the writer zone, which this file
+    // does not record.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeNonSparkParquetFile(
+        path,
+        Seq((1, Some(-171655), Some(0L)), (2, Some(19875), Some(1717243200000000L))))
+      val table = "comet_nonspark_legacy_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        convertRawParquetToDelta(path, table)
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "LEGACY",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "LEGACY") {
+          val df = spark.read.format("delta").load(path)
+          checkDeltaNativeScanAnswer(df)
+          val rows = df
+            .selectExpr("id", "cast(d as string)")
+            .collect()
+            .sortBy(_.getInt(0))
+          assert(rows(0).getString(1) == "1500-01-01", s"got ${rows(0)}")
+          assert(rows(1).getString(1) == "2024-06-01", s"got ${rows(1)}")
+        }
+      }
+    }
+  }
+
+  test("non-Spark parquet files with ancient values fail loudly under EXCEPTION read modes") {
+    // EXCEPTION read modes (Spark 3.x's default) refuse ancient values whose calendar the
+    // file does not declare; the native scan must refuse them too rather than return
+    // silently shifted values.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      writeNonSparkParquetFile(path, Seq((1, Some(-171655), Some(0L))))
+      val table =
+        "comet_nonspark_exception_" + java.util.UUID.randomUUID().toString.replace("-", "")
+      withTable(table) {
+        convertRawParquetToDelta(path, table)
+        withSQLConf(
+          SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+          "spark.sql.parquet.datetimeRebaseModeInRead" -> "EXCEPTION",
+          "spark.sql.parquet.int96RebaseModeInRead" -> "EXCEPTION") {
+          val e = intercept[Exception] {
+            spark.read.format("delta").load(path).collect()
+          }
+          val messages = Iterator
+            .iterate(e: Throwable)(_.getCause)
+            .takeWhile(_ != null)
+            .map(_.getMessage)
+            .mkString("\n")
+          assert(
+            messages.toLowerCase(java.util.Locale.ROOT).contains("rebase"),
+            s"expected a calendar-rebase error, got:\n$messages")
+        }
+      }
+    }
+  }
+
+  test(
+    "a struct with a date column stays native when the file carries only the legacy INT96 " +
+      "flag and corrected dates") {
+    // legacyINT96 alone puts the file's INT96 timestamp column under the LEGACY policy, but
+    // its DATE policy is CORRECTED -- so a STRUCT<d: DATE> column has nothing to rebase and
+    // must pass through natively, unwrapped, instead of being handled just because the
+    // timestamp policy needs handling elsewhere in the file.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      withSQLConf(
+        SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC",
+        "spark.sql.parquet.outputTimestampType" -> "INT96",
+        "spark.sql.parquet.datetimeRebaseModeInWrite" -> "CORRECTED",
+        "spark.sql.parquet.int96RebaseModeInWrite" -> "LEGACY") {
+        spark
+          .sql(
+            "select * from values " +
+              "(1, named_struct('d', date'2020-06-01'), timestamp'2021-01-01 00:00:00'), " +
+              "(2, named_struct('d', cast(null as date)), timestamp'2022-01-01 12:34:56') " +
+              "as t(id, s, ts)")
+          .write
+          .format("delta")
+          .save(path)
+      }
+      withSQLConf(SQLConf.SESSION_LOCAL_TIMEZONE.key -> "UTC") {
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+        val rows = df.selectExpr("id", "cast(s.d as string)").collect().sortBy(_.getInt(0))
+        assert(rows(0).getString(1) == "2020-06-01", s"got ${rows(0)}")
+        assert(rows(1).isNullAt(1), s"got ${rows(1)}")
+      }
+    }
+  }
+}
diff --git a/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaS3Suite.scala b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaS3Suite.scala
new file mode 100644
index 0000000000..4f758e2430
--- /dev/null
+++ b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaS3Suite.scala
@@ -0,0 +1,307 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import java.util.Locale
+
+import scala.util.{Failure, Success, Try}
+
+import org.testcontainers.DockerClientFactory
+
+import org.apache.hadoop.fs.Path
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.delta.DeltaLog
+import org.apache.spark.sql.delta.actions.DeletionVectorDescriptor
+
+import org.apache.comet.CometS3TestBase
+
+/**
+ * MinIO-backed integration coverage for multi-bucket Delta shapes: a real two-bucket shallow
+ * clone, which a single-bucket `withTempPath` table can never produce, because it is
+ * `DeltaTable`'s CLONE machinery -- not test fixturing -- that leaves some `AddFile` entries
+ * pointing at the source table's absolute location while new files land under the clone's own
+ * root.
+ *
+ * Manual/opt-in, same as [[org.apache.comet.parquet.ParquetReadFromS3Suite]] in the spark module
+ * -- but gated differently out of necessity. That suite is invisible to every PR workflow simply
+ * because `.github/workflows/pr_build_linux.yml` / `pr_build_macos.yml` enumerate test classes by
+ * name and never name it (`dev/ci/check-suites.py` exempts it via `ignore_list` instead of
+ * requiring it be listed). The contrib module has no such allowlist: `delta_contrib_test.yml`
+ * runs `mvn ... test -pl contrib/delta-spark`, which discovers and runs every suite on the
+ * module's test classpath, and `check-suites.py` does not enforce anything under `contrib/` at
+ * all (see its `path.parts[0] == "contrib"` skip), so there is no file to omit this suite from.
+ * Every test therefore starts with `assume(dockerAvailable, ...)`: when no Docker daemon is
+ * reachable, ScalaTest reports the test CANCELED rather than failed or run, which
+ * `scalatest-maven-plugin` does not treat as a build failure -- the practical equivalent of
+ * `ParquetReadFromS3Suite`'s blanket omission, reached by a runtime check instead of never being
+ * named. `beforeAll` mirrors this: it probes Docker BEFORE calling `CometS3TestBase#beforeAll`,
+ * because that trait's `sparkConf` dereferences `minioContainer` unconditionally, and starting
+ * the Spark session (let alone a container) is exactly what a Docker-less run must not do.
+ *
+ * That fail-soft default makes a zero-coverage run look green, so the CI job that exists only to
+ * run this suite sets `COMET_DELTA_S3_REQUIRED=1`, which turns a missing Docker daemon or a
+ * failed MinIO start into a thrown `beforeAll`: the suite aborts and `scalatest-maven-plugin`
+ * fails.
+ */
+class CometDeltaS3Suite extends CometDeltaTestBase with CometS3TestBase with Logging {
+
+  override protected val testBucketName = "comet-delta-a"
+
+  /**
+   * The clone's destination bucket: distinct from [[testBucketName]] on purpose -- these tests
+   * exist to put a table's data (or its deletion vectors) across two object-store authorities.
+   */
+  private val cloneBucketName = "comet-delta-b"
+
+  /**
+   * A bucket touched by no other test in this suite: the native S3 object-store cache
+   * (`object_store_cache` in parquet_support.rs) is process-wide and keyed per bucket, so reusing
+   * [[testBucketName]] for the `${...}` forwarding test below risks silently passing against a
+   * store handle another test already warmed with plain credentials, rather than actually forcing
+   * a fresh credential derivation through the substituted `${...}` value.
+   */
+  private val reviewRefBucketName = "comet-delta-review-ref"
+
+  private var dockerAvailable = false
+
+  override def beforeAll(): Unit = {
+    val required = CometDeltaS3Suite.s3Required(sys.env.get(CometDeltaS3Suite.S3_REQUIRED_ENV))
+    dockerAvailable = DockerClientFactory.instance().isDockerAvailable
+    if (!dockerAvailable && required) {
+      throw new IllegalStateException(
+        CometDeltaS3Suite.requiredFailureMessage("no Docker daemon is reachable"))
+    }
+    if (dockerAvailable) {
+      // Fail soft unless COMET_DELTA_S3_REQUIRED arms the hard failure: this suite runs
+      // unconditionally in CI (no allowlist to omit it from, see the class doc above), and
+      // testcontainers networking inside a CI job container is unverified -- MinIO is a sibling
+      // container there, so `getS3URL` may resolve to an address that is wrong from inside the
+      // job container. If startup or bucket creation blows up, log the resolved URL (the signal
+      // needed to diagnose a first bad CI run), flip `dockerAvailable` back off so every test
+      // cancels via `assume` instead of aborting the whole suite, and best-effort stop whatever
+      // container did come up.
+      Try {
+        super.beforeAll() // CometS3TestBase starts MinIO, then CometTestBase starts the session.
+        createBucketIfNotExists(cloneBucketName)
+        createBucketIfNotExists(reviewRefBucketName)
+      } match {
+        case Success(_) =>
+          logInfo(s"CometDeltaS3Suite: MinIO reachable at ${minioContainer.getS3URL}")
+        case Failure(e) =>
+          val resolvedUrl = Try(minioContainer.getS3URL).getOrElse("<unresolvable>")
+          val cause = s"MinIO setup failed (resolved S3 URL: $resolvedUrl)"
+          dockerAvailable = false
+          // Tear down here, synchronously: super.beforeAll() may have partially succeeded
+          // (e.g. the Spark session started but createBucketIfNotExists(cloneBucketName)
+          // failed), and this suite's own afterAll() below is gated on `dockerAvailable`,
+          // which is now false -- the framework-invoked afterAll() will no-op and never get a
+          // chance to stop anything. super.afterAll() stops both the Spark session
+          // (CometTestBase#afterAll, tolerates a session that never started) and MinIO
+          // (CometS3TestBase#afterAll, tolerates a container that never started), so this is
+          // safe to call unconditionally here regardless of how far beforeAll got.
+          Try(super.afterAll())
+          if (required) {
+            throw new IllegalStateException(CometDeltaS3Suite.requiredFailureMessage(cause), e)
+          }
+          logWarning(s"CometDeltaS3Suite: $cause; skipping all tests in this suite", e)
+      }
+    }
+  }
+
+  override def afterAll(): Unit = {
+    if (dockerAvailable) {
+      super.afterAll()
+    }
+  }
+
+  // CometTestBase#afterEach unconditionally touches `spark` (cache-clearing, open-stream
+  // assertions); with no session ever created in a Docker-less run, that NPEs and aborts the
+  // whole suite -- turning a clean per-test cancellation into a module-wide build failure.
+  override def afterEach(): Unit = {
+    if (dockerAvailable) {
+      super.afterEach()
+    }
+  }
+
+  private def tablePath(bucket: String, relPath: String): String = s"s3a://$bucket/$relPath"
+
+  test("shallow clone across buckets + append declines with the multi-store reason") {
+    assume(dockerAvailable, "Docker is not available; skipping MinIO-backed Delta test")
+
+    val sourcePath = tablePath(testBucketName, "clone-append/source")
+    val clonePath = tablePath(cloneBucketName, "clone-append/clone")
+
+    spark.range(0, 100).selectExpr("id", "id * 2 as v").write.format("delta").save(sourcePath)
+    spark.sql(s"CREATE TABLE delta.`$clonePath` SHALLOW CLONE delta.`$sourcePath`")
+    // The clone's own transaction log still references the SOURCE's physical files (bucket A)
+    // for every row carried over by the clone. This append writes NEW physical files under the
+    // clone's own root (bucket B): the clone's data files now span two object-store
+    // authorities -- exactly the shape the multi-store decline gate exists for, since the shared
+    // native scan builder resolves the whole scan's ObjectStoreUrl from the first selected file
+    // only.
+    spark
+      .range(100, 150)
+      .selectExpr("id", "id * 2 as v")
+      .write
+      .format("delta")
+      .mode("append")
+      .save(clonePath)
+
+    val df = spark.read.format("delta").load(clonePath)
+    checkSparkAnswerAndFallbackReason(
+      df,
+      "Native Delta scan does not support data files spanning multiple object stores")
+  }
+
+  test(
+    "clone across buckets + DELETE on the clone reads correct rows natively " +
+      "(cold cross-bucket deletion-vector store)") {
+    assume(dockerAvailable, "Docker is not available; skipping MinIO-backed Delta test")
+
+    val sourcePath = tablePath(testBucketName, "clone-delete/source")
+    val clonePath = tablePath(cloneBucketName, "clone-delete/clone")
+
+    spark.range(0, 1000).selectExpr("id", "id * 2 as v").write.format("delta").save(sourcePath)
+    spark.sql(
+      s"ALTER TABLE delta.`$sourcePath` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+    spark.sql(s"CREATE TABLE delta.`$clonePath` SHALLOW CLONE delta.`$sourcePath`")
+    // DELETE against a deletion-vector table does not rewrite the target file; it attaches a
+    // deletion-vector sidecar to the existing `AddFile` action instead. The sidecar is written
+    // under the CLONE's own root (bucket B), while the `AddFile` it decorates still points at
+    // the SOURCE's absolute, un-copied physical file (bucket A) -- shallow clone never
+    // relocates data it did not modify. That is the cold cross-bucket deletion-vector-store bug
+    // shape: attaching the access plan nested a `Handle::block_on` call that built the
+    // (previously untouched, so cold) bucket-B object store for the sidecar from inside an
+    // already-running Tokio runtime, which panics.
+    //
+    // It is also, deliberately, NOT the shape the multi-store decline gate catches: that gate
+    // inspects only DATA-file authorities (`scanHelper.selectedPartitions...map(_.getPath)`),
+    // and every data file this scan selects is still on bucket A -- only the deletion vector's
+    // own authority is bucket B. That distinction is worth stating here because it is
+    // the one property that makes this test exercise the cold cross-bucket deletion-vector-store
+    // path instead of re-proving the multi-store decline gate.
+    spark.sql(s"DELETE FROM delta.`$clonePath` WHERE id % 2 = 0")
+
+    // Assert the cross-bucket shape STRUCTURALLY, not just end-to-end via the read below: if
+    // Delta's shallow-clone or DELETE-on-a-DV-table semantics ever change (DELETE starts
+    // rewriting the file instead of writing a DV, or the DV sidecar starts landing next to the
+    // data it decorates instead of under the clone's own root), the test must fail loudly right
+    // here -- otherwise it would silently degrade into a same-bucket read that never exercises
+    // the cold cross-bucket deletion-vector-store code path at all, while
+    // `checkDeltaNativeScanAnswer` below would still pass.
+    val log = DeltaLog.forTable(spark, clonePath)
+    val cloneTableRootPath = new Path(clonePath)
+    val files = log.update().allFiles.collect()
+
+    // At least one data file must still resolve into the SOURCE bucket: shallow clone never
+    // copies files it did not modify.
+    val dataAuthorities = files.map(_.absolutePath(log).toUri.getHost).distinct
+    assert(
+      dataAuthorities.contains(testBucketName),
+      "expected at least one data file to still resolve into the SOURCE bucket " +
+        s"($testBucketName, carried over unmodified by the shallow clone); resolved data-file " +
+        s"authorities: ${dataAuthorities.mkString(", ")}")
+
+    // At least one deletion-vector descriptor must resolve into the CLONE's own bucket.
+    // Resolution mirrors DeltaScanSupport.selectedDvDescriptors (copyWithAbsolutePath against
+    // the table root) followed by CometDeltaNativeScan.storeUris's own absolutePath call --
+    // the exact path production code takes from AddFile to an object-store authority. Inline
+    // or canonically-empty descriptors are excluded first (`cardinality == 0` is the
+    // EMPTY-descriptor characterization: no rows deleted, so no on-disk sidecar exists):
+    // DeletionVectorDescriptor#absolutePath's isOnDisk precondition
+    // throws for inline ones, and neither carries a resolvable external authority.
+    val dvAuthorities = files
+      .flatMap(f => Option(f.deletionVector))
+      .filter(dv =>
+        dv.storageType != DeletionVectorDescriptor.INLINE_DV_MARKER && dv.cardinality > 0)
+      .map(
+        _.copyWithAbsolutePath(cloneTableRootPath).absolutePath(cloneTableRootPath).toUri.getHost)
+      .distinct
+    assert(
+      dvAuthorities.contains(cloneBucketName),
+      "expected at least one deletion-vector sidecar to resolve into the CLONE's own bucket " +
+        s"($cloneBucketName); resolved deletion-vector authorities: " +
+        s"${dvAuthorities.mkString(", ")}")
+
+    val df = spark.read.format("delta").load(clonePath)
+    checkDeltaNativeScanAnswer(df)
+    assert(df.count() == 500)
+  }
+
+  test(
+    s"S3 credentials configured via a Hadoop $${...} variable reference (fs.s3a.access.key = " +
+      s"$${review.access}, fs.s3a.secret.key = $${review.secret}) claim natively and read " +
+      "correct rows against a real MinIO bucket") {
+    assume(dockerAvailable, "Docker is not available; skipping MinIO-backed Delta test")
+
+    // Mutate the session's shared hadoopConfiguration directly (mirroring the set-then-restore
+    // shape CometDeltaNativeScanSuite's viewfs gate test uses for the same reason: these are
+    // plain Hadoop Configuration entries, not SQLConf, so withSQLConf cannot round-trip them).
+    // Aliasing the real MinIO credentials behind review.access/review.secret and pointing
+    // fs.s3a.access.key/fs.s3a.secret.key at them via ${...} reproduces exactly the shape
+    // PART 1 fixed: Configuration#get expands the reference to the real credential, and
+    // NativeConfig.extractObjectStoreOptions must forward that EXPANDED value, not the literal
+    // "${review.access}" string, or the native S3 client would authenticate with garbage.
+    val hadoopConf = spark.sparkContext.hadoopConfiguration
+    val priorAccessKey = Option(hadoopConf.get("fs.s3a.access.key"))
+    val priorSecretKey = Option(hadoopConf.get("fs.s3a.secret.key"))
+    hadoopConf.set("review.access", userName)
+    hadoopConf.set("review.secret", password)
+    hadoopConf.set("fs.s3a.access.key", s"$${review.access}")
+    hadoopConf.set("fs.s3a.secret.key", s"$${review.secret}")
+    try {
+      val path = tablePath(reviewRefBucketName, "review-ref-table")
+      spark.range(0, 200).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+
+      val df = spark.read.format("delta").load(path)
+      checkDeltaNativeScanAnswer(df)
+      assert(df.count() == 200)
+    } finally {
+      hadoopConf.unset("review.access")
+      hadoopConf.unset("review.secret")
+      priorAccessKey match {
+        case Some(v) => hadoopConf.set("fs.s3a.access.key", v)
+        case None => hadoopConf.unset("fs.s3a.access.key")
+      }
+      priorSecretKey match {
+        case Some(v) => hadoopConf.set("fs.s3a.secret.key", v)
+        case None => hadoopConf.unset("fs.s3a.secret.key")
+      }
+    }
+  }
+}
+
+object CometDeltaS3Suite {
+
+  /** Environment variable that turns a Docker-less or MinIO-less run into a suite failure. */
+  val S3_REQUIRED_ENV = "COMET_DELTA_S3_REQUIRED"
+
+  /**
+   * Whether the run must fail rather than cancel when MinIO is unavailable. Strict on purpose:
+   * only `1` and `true` (trimmed, case-insensitive) arm it; anything else, including `yes` and
+   * `0`, keeps the fail-soft default so a typo cannot arm or disarm the switch unnoticed.
+   */
+  private[delta] def s3Required(value: Option[String]): Boolean =
+    value.map(_.trim.toLowerCase(Locale.ROOT)).exists(v => v == "1" || v == "true")
+
+  /** Names the env var and the cause so a red CI run reads directly from the failure line. */
+  private[delta] def requiredFailureMessage(cause: String): String =
+    s"$S3_REQUIRED_ENV is set but $cause; failing CometDeltaS3Suite instead of cancelling it"
+}
diff --git a/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaTestBase.scala b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaTestBase.scala
new file mode 100644
index 0000000000..50fbcc23fe
--- /dev/null
+++ b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/CometDeltaTestBase.scala
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.{CometTestBase, DataFrame}
+import org.apache.spark.sql.execution.SparkPlan
+import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanHelper
+
+/**
+ * Base for Delta contrib suites: CometTestBase plus the Delta Lake session extension and catalog.
+ */
+abstract class CometDeltaTestBase extends CometTestBase with AdaptiveSparkPlanHelper {
+
+  override protected def sparkConf: SparkConf = {
+    val conf = super.sparkConf
+    conf.set("spark.sql.extensions", "io.delta.sql.DeltaSparkSessionExtension")
+    conf.set("spark.sql.catalog.spark_catalog", "org.apache.spark.sql.delta.catalog.DeltaCatalog")
+    conf.set(DeltaScanConf.COMET_DELTA_NATIVE_ENABLED.key, "true")
+    conf
+  }
+
+  /** Collect nodes of the given simple class name anywhere in the (AQE-stripped) plan. */
+  protected def collectByName(plan: SparkPlan, simpleName: String): Seq[SparkPlan] =
+    collectWithSubqueries(stripAQEPlan(plan)) {
+      case op if op.getClass.getSimpleName == simpleName => op
+    }
+
+  protected def deltaNativeScans(df: DataFrame): Seq[SparkPlan] =
+    collectByName(df.queryExecution.executedPlan, "CometDeltaNativeScanExec")
+
+  /** Assert the query ran through the native Delta scan AND matches the comet-off answer. */
+  protected def checkDeltaNativeScanAnswer(df: DataFrame): Unit = {
+    checkSparkAnswer(df)
+    // Re-materialize the plan after execution so AQE has finalized stages.
+    assert(
+      deltaNativeScans(df).nonEmpty,
+      s"Expected CometDeltaNativeScanExec in plan:\n${df.queryExecution.executedPlan}")
+  }
+}
diff --git a/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/DeltaScanContribSuite.scala b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/DeltaScanContribSuite.scala
new file mode 100644
index 0000000000..6d45bf7a56
--- /dev/null
+++ b/contrib/delta-spark/src/test/scala/org/apache/comet/contrib/delta/DeltaScanContribSuite.scala
@@ -0,0 +1,2905 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.comet.contrib.delta
+
+import java.io.{File, IOException}
+import java.net.URI
+import java.nio.file.Files
+import java.util.{Locale, UUID}
+import java.util.concurrent.atomic.AtomicBoolean
+
+import scala.jdk.CollectionConverters._
+
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.fs.{Path, RawLocalFileSystem}
+import org.apache.hadoop.fs.s3a.{S3AFileSystem, S3AUtils}
+import org.apache.hadoop.security.alias.CredentialProviderFactory
+import org.apache.spark.sql.comet.CometDeltaNativeScanExec
+import org.apache.spark.sql.delta.actions.DeletionVectorDescriptor
+
+import org.apache.comet.{CometConf, ExtendedExplainInfo}
+import org.apache.comet.objectstore.NativeConfig
+import org.apache.comet.rules.CometScanRule
+
+/**
+ * Guards the contrib claim path: the contrib is never active when Comet exec or Comet scan is
+ * disabled, and the claim hook runs before core's metadata-column guard.
+ */
+class DeltaScanContribSuite extends CometDeltaTestBase {
+
+  test("contrib is inert when comet exec is disabled") {
+    // The COMET_EXEC_ENABLED gate lives in DeltaScanContrib.tryTransformV1; this pins it there.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      withSQLConf(CometConf.COMET_EXEC_ENABLED.key -> "false") {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswer(df)
+        assert(deltaNativeScans(df).isEmpty)
+      }
+    }
+  }
+
+  test("contrib is inert when comet native scan is disabled") {
+    // COMET_NATIVE_SCAN_ENABLED is checked in CometScanRule.transformScan before any V1
+    // handling, so it short-circuits the CometScanContrib hook too.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      withSQLConf(CometConf.COMET_NATIVE_SCAN_ENABLED.key -> "false") {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswer(df)
+        assert(deltaNativeScans(df).isEmpty)
+      }
+    }
+  }
+
+  test("claim runs before core's metadata-column guard") {
+    // A DV read's plan carries generated metadata columns that core's generic V1 guard
+    // would decline; the scan still goes native because CometScanContrib.tryTransformV1
+    // is consulted first (CometScanRule.transformV1Scan hook order).
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 1000).selectExpr("id", "id * 2 as v").write.format("delta").save(path)
+      spark.sql(
+        s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+      spark.sql(s"DELETE FROM delta.`$path` WHERE id % 2 = 0")
+
+      val df = spark.read.format("delta").load(path)
+      checkSparkAnswer(df)
+      assert(deltaNativeScans(df).nonEmpty)
+    }
+  }
+
+  test("declined scan carries the contrib's fallback reason, not core's generic one") {
+    // Disabling Spark's vectorized Parquet reader is a scan the contrib recognizes
+    // (DeltaScanSupport.isDeltaScan) but explicitly declines (DeltaScanSupport.declineReason,
+    // mirroring core's own vectorized-reader gate). Per the CometScanContrib ownership
+    // contract the contrib still claims it (tagging its own fallback reason), so core's
+    // generic V1 gate -- and its "Unsupported file format" message -- never runs on it.
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      withSQLConf(
+        "spark.sql.parquet.enableVectorizedReader" -> "false",
+        // CometTestBase flips this to "true" so the rest of the suite can exercise the
+        // vectorized-off path against Comet's native scan; put it back to its real default so
+        // this gate actually declines.
+        CometConf.COMET_SCAN_ALLOW_DISABLED_PARQUET_VECTORIZED_READER.key -> "false") {
+        val df = spark.read.format("delta").load(path)
+
+        val (_, cometPlan) = checkSparkAnswerAndFallbackReason(
+          df,
+          "Native Delta scan is incompatible with " +
+            "spark.sql.parquet.enableVectorizedReader=false")
+
+        val reasons = new ExtendedExplainInfo().getFallbackReasons(cometPlan)
+        assert(
+          !reasons.exists(_.contains("Unsupported file format")),
+          s"Did not expect core's generic fallback reason among: $reasons")
+      }
+    }
+  }
+
+  test(
+    "vectorized reader disabled still claims natively when the safety conf allows it " +
+      "(claim-direction control for the decline above)") {
+    withTempPath { dir =>
+      val path = dir.getAbsolutePath
+      spark.range(0, 100).write.format("delta").save(path)
+
+      withSQLConf(
+        "spark.sql.parquet.enableVectorizedReader" -> "false",
+        CometConf.COMET_SCAN_ALLOW_DISABLED_PARQUET_VECTORIZED_READER.key -> "true") {
+        val df = spark.read.format("delta").load(path)
+        checkSparkAnswer(df)
+        assert(deltaNativeScans(df).nonEmpty)
+      }
+    }
+  }
+
+  test("_metadata.file_block_start and file_block_length fall back on a split Delta file") {
+    // When a file is split, Spark keeps a row group in the split holding its midpoint while
+    // DataFusion keeps it in the split holding its first page, so these per-split values differ.
+    withSQLConf("spark.sql.files.maxPartitionBytes" -> "4096") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        spark
+          .range(0, 5000)
+          .selectExpr("id", "concat('value_', cast(id as string)) as s")
+          .coalesce(1)
+          .write
+          .format("delta")
+          .save(path)
+        withSQLConf(CometConf.COMET_ENABLED.key -> "false") {
+          assert(
+            spark.read.format("delta").load(path).rdd.getNumPartitions > 1,
+            "the file has to be split across partitions for this test to mean anything")
+        }
+
+        val df = spark.read.format("delta").load(path)
+        for (column <- Seq("file_block_start", "file_block_length")) {
+          checkSparkAnswerAndFallbackReason(
+            df.selectExpr("id", "s", s"_metadata.$column"),
+            s"Native Delta scan does not support metadata column(s) $column")
+        }
+        // A filter alone consumes the value too, as does selecting the whole struct.
+        checkSparkAnswerAndFallbackReason(
+          df.filter("_metadata.file_block_start > 0").select("id"),
+          "Native Delta scan does not support metadata column(s) file_block_start")
+        checkSparkAnswerAndFallbackReason(
+          df.selectExpr("id", "_metadata"),
+          "Native Delta scan does not support metadata column(s) " +
+            "file_block_start, file_block_length")
+        // The per-file constants do not depend on which split reads a row group.
+        checkDeltaNativeScanAnswer(df.selectExpr("id", "s", "_metadata.file_path"))
+      }
+    }
+  }
+
+  test("_metadata.file_block_start falls back on a split deletion-vector Delta file") {
+    // A deletion-vector read puts every _metadata field in the scan output; the plain read stays
+    // native (see the claim test above) while a query consuming file_block_start falls back.
+    withSQLConf("spark.sql.files.maxPartitionBytes" -> "4096") {
+      withTempPath { dir =>
+        val path = dir.getAbsolutePath
+        spark
+          .range(0, 5000)
+          .selectExpr("id", "concat('value_', cast(id as string)) as s")
+          .coalesce(1)
+          .write
+          .format("delta")
+          .save(path)
+        spark.sql(
+          s"ALTER TABLE delta.`$path` SET TBLPROPERTIES ('delta.enableDeletionVectors' = 'true')")
+        spark.sql(s"DELETE FROM delta.`$path` WHERE id % 7 = 0")
+
+        val df = spark.read.format("delta").load(path)
+        checkDeltaNativeScanAnswer(df)
+        val expected = "Native Delta scan does not support metadata column(s) file_block_start"
+        val (_, cometPlan) = checkSparkAnswerAndFallbackReason(
+          df.selectExpr("id", "s", "_metadata.file_block_start"),
+          expected)
+        // file_block_length is in the scan output too, but nothing above the scan reads it.
+        val reasons = new ExtendedExplainInfo().getFallbackReasons(cometPlan)
+        assert(
+          reasons.exists(r => r.contains(expected) && !r.contains("file_block_length")),
+          s"expected '$expected' naming only file_block_start among: $reasons")
+      }
+    }
+  }
+
+  test(
+    "unsupportedSchemes declines an all-viewfs root-path selection (the same helper " +
+      "declineReason applies to scanExec.relation.location.rootPaths, ahead of the " +
+      "selected-file gate)") {
+    val viewfsUri = new URI("viewfs://cluster/table")
+    // Precondition, mirroring the selected-file scheme tests below: guards against a fail-open
+    // native build vacuously passing this test.
+    assert(!CometScanRule.isNativelyReadableScheme(viewfsUri, Set.empty))
+
+    val schemes = DeltaScanSupport.unsupportedSchemes(Seq(viewfsUri), Set("hdfs"))
+    assert(schemes == Set("viewfs"))
+  }
+
+  test(
+    "unsupportedSchemes flags an opted-in S3-compliant alias scheme that core's gate admits " +
+      "(the contrib never hands core its alias set)") {
+    val blobUri = new URI("blob://bucket/table")
+    // Precondition: core admits the alias once opted in, and only then.
+    assert(CometScanRule.isNativelyReadableScheme(blobUri, Set("blob")))
+    assert(!CometScanRule.isNativelyReadableScheme(blobUri, Set.empty))
+
+    assert(DeltaScanSupport.unsupportedSchemes(Seq(blobUri), Set("hdfs")) == Set("blob"))
+  }
+
+  test(
+    "s3CompliantAliasSchemeReason declines an opted-in alias root path with the explaining " +
+      "reason, and passes when the scheme is not opted in or is plain s3a") {
+    val blobUri = new URI("blob://bucket/table")
+    val s3aUri = new URI("s3a://bucket/table")
+
+    val optedIn = new Configuration(false)
+    optedIn.set(CometConf.COMET_S3_COMPLIANT_SCHEMES_KEY, " Blob , minio ")
+    val reason = DeltaScanSupport.s3CompliantAliasSchemeReason(optedIn, Seq(s3aUri, blobUri))
+    assert(reason.isDefined)
+    assert(reason.get.contains("blob"))
+    assert(reason.get.contains(CometConf.COMET_S3_COMPLIANT_SCHEMES_KEY))
+    assert(reason.get.contains("S3AFileSystem"))
+    assert(DeltaScanSupport.s3CompliantAliasSchemeReason(optedIn, Seq(s3aUri)).isEmpty)
+
+    val notOptedIn = new Configuration(false)
+    assert(DeltaScanSupport.s3CompliantAliasSchemeReason(notOptedIn, Seq(blobUri)).isEmpty)
+  }
+
+  test("libhdfsSchemes parses the list exactly like core's scan gate (trim, lowercase, blanks)") {
+    withSQLConf(CometConf.COMET_LIBHDFS_SCHEMES.key -> " HDFS , viewfs ,, ") {
+      assert(DeltaScanSupport.libhdfsSchemes == Set("hdfs", "viewfs"))
+    }
+    assert(DeltaScanSupport.libhdfsSchemes == Set("hdfs"))
+  }
+
+  test("unsupportedSchemes passes an all-file: root-path selection (no regression)") {
+    assert(
+      DeltaScanSupport
+        .unsupportedSchemes(Seq(new URI("file:///tmp/table")), Set("hdfs"))
+        .isEmpty)
+  }
+
+  test(
+    "unsupportedSchemes passes a root-path scheme configured as a libhdfs exemption " +
+      "(exemption honored for the root-path call site too)") {
+    val viewfsUri = new URI("viewfs://cluster/table")
+    assert(!CometScanRule.isNativelyReadableScheme(viewfsUri, Set.empty))
+
+    assert(DeltaScanSupport.unsupportedSchemes(Seq(viewfsUri), Set("viewfs")).isEmpty)
+  }
+
+  test(
+    "objectStoreRejectedPathReason declines a root whose path object_store rejects and " +
+      "stays None for an ordinary path or a libhdfs-exempt scheme") {
+    val rejected = new URI("file:///tmp/dir%0A/data")
+    // Precondition, mirroring the scheme tests above: guards against a fail-open native build
+    // vacuously passing this test.
+    assert(!CometScanRule.objectStoreAcceptsPath(rejected))
+    assert(CometScanRule.objectStoreAcceptsPath(new URI("file:///tmp/table")))
+
+    val reason = DeltaScanSupport.objectStoreRejectedPathReason(Seq(rejected), Set("hdfs"))
+    assert(reason.isDefined)
+    assert(reason.get.contains("cannot open path 'file:///tmp/dir%0A/data'"))
+    assert(reason.get.contains("object_store rejects it"))
+
+    assert(
+      DeltaScanSupport
+        .objectStoreRejectedPathReason(Seq(new URI("file:///tmp/table")), Set("hdfs"))
+        .isEmpty)
+    // A libhdfs-routed scheme never reaches object_store's path parser.
+    assert(
+      DeltaScanSupport
+        .objectStoreRejectedPathReason(Seq(new URI("hdfs://nn/dir%0A/data")), Set("hdfs"))
+        .isEmpty)
+    // Userinfo is masked in the reason (redactedAuthority's invariant); the path is kept.
+    val withUserInfo = DeltaScanSupport.objectStoreRejectedPathReason(
+      Seq(new URI("s3a://key:secret@bucket/dir%0A/data")),
+      Set("hdfs"))
+    assert(withUserInfo.exists(_.contains("'s3a://***@bucket/dir%0A/data'")), s"$withUserInfo")
+    assert(!withUserInfo.exists(_.contains("secret")))
+  }
+
+  test(
+    "objectStoreRejectedPathReason declines a selected file whose basename object_store " +
+      "rejects even though its parent directory is accepted") {
+    // CONVERT TO DELTA keeps the source Parquet basenames, so the rejected character can sit in
+    // the file name itself; a directory-only probe accepts the parent and misses it. Both URIs
+    // come from Hadoop's Path, as the selected files do, so they render as `file:/...`.
+    val file = new Path(new Path("file:/tmp/table"), "part-00000\n.snappy.parquet").toUri
+    val parent = new Path(file).getParent.toUri
+    assert(file == new URI("file:/tmp/table/part-00000%0A.snappy.parquet"), s"$file")
+    assert(CometScanRule.objectStoreAcceptsPath(parent), s"directory probe rejected $parent")
+    assert(!CometScanRule.objectStoreAcceptsPath(file))
+    assert(DeltaScanSupport.objectStoreRejectedPathReason(Seq(parent), Set("hdfs")).isEmpty)
+
+    val reason = DeltaScanSupport.objectStoreRejectedPathReason(Seq(file), Set("hdfs"))
+    assert(
+      reason.exists(
+        _.contains("cannot open path 'file:/tmp/table/part-00000%0A.snappy.parquet': " +
+          "object_store rejects it")),
+      s"reason: $reason")
+  }
+
+  test("multiStoreReason declines data files spanning multiple object-store authorities") {
+    // Same bucket, different keys: one authority, claimable.
+    assert(
+      DeltaScanSupport
+        .multiStoreReason(
+          Seq(new URI("s3a://bucket/a/part-0.parquet"), new URI("s3a://bucket/b/part-1.parquet")))
+        .isEmpty)
+
+    // Distinct buckets: two authorities, must decline (this is the shallow-clone-across-
+    // buckets-plus-append shape the shared native scan builder cannot route correctly, since
+    // it resolves the whole scan's ObjectStoreUrl from the first file only).
+    val reason = DeltaScanSupport.multiStoreReason(
+      Seq(new URI("s3a://bucket-a/part-0.parquet"), new URI("s3a://bucket-b/part-1.parquet")))
+    assert(reason.isDefined)
+    assert(reason.get.contains("multiple object stores"))
+    assert(reason.get.contains("bucket-a"))
+    assert(reason.get.contains("bucket-b"))
+
+    // file:// paths never carry an authority (host/port are always empty), so local scans
+    // across distinct directories are unaffected.
+    assert(
+      DeltaScanSupport
+        .multiStoreReason(
+          Seq(new URI("file:///tmp/a/part-0.parquet"), new URI("file:///tmp/b/part-1.parquet")))
+        .isEmpty)
+  }
+
+  test(
+    "multiStoreReason declines cross-container abfss shallow clones (userinfo normalization)") {
+    // Same storage account, different containers: URI#getHost drops the userinfo entirely, so
+    // keying the authority on host alone would collapse containerA and containerB into one
+    // authority and silently claim a cross-container shallow clone. getAuthority (used by
+    // uriAuthority) keeps the userinfo, so this must decline.
+    val reason = DeltaScanSupport.multiStoreReason(
+      Seq(
+        new URI("abfss://containerA@account.dfs.core.windows.net/a/part-0.parquet"),
+        new URI("abfss://containerB@account.dfs.core.windows.net/b/part-1.parquet")))
+    assert(reason.isDefined)
+    assert(reason.get.contains("multiple object stores"))
+
+    // Same container: one authority, so multiStoreReason itself still passes this shape
+    // unchanged (this gate was never touched by the userinfo work). But every abfss:// URI here
+    // carries userinfo (the container) in its authority, so declineReason's earlier-firing
+    // userInfoBearingAuthorityReason gate now declines this input before multiStoreReason ever
+    // runs on it -- pinned directly here since multiStoreReason alone can no longer observe the
+    // difference between this shape and a truly userinfo-free single-authority scan.
+    val sameContainer = Seq(
+      new URI("abfss://container@account.dfs.core.windows.net/a/part-0.parquet"),
+      new URI("abfss://container@account.dfs.core.windows.net/b/part-1.parquet"))
+    assert(DeltaScanSupport.multiStoreReason(sameContainer).isEmpty)
+    assert(DeltaScanSupport.userInfoBearingAuthorityReason(sameContainer).isDefined)
+  }
+
+  test("multiStoreReason declines data files on more than one ABFS store or beside s3a") {
+    // Core's extractScanObjectStoreOptions needs one ABFS container and account per scan and no
+    // other scheme beside ABFS. This gate declines all three shapes before convert reaches it.
+    val shapes = Seq(
+      "two accounts" -> Seq(
+        new URI("abfss://data@accountA.dfs.core.windows.net/t/part-0.parquet"),
+        new URI("abfss://data@accountB.dfs.core.windows.net/t/part-1.parquet")),
+      "two containers" -> Seq(
+        new URI("abfss://dataA@account.dfs.core.windows.net/t/part-0.parquet"),
+        new URI("abfss://dataB@account.dfs.core.windows.net/t/part-1.parquet")),
+      "abfss and s3a" -> Seq(
+        new URI("abfss://data@account.dfs.core.windows.net/t/part-0.parquet"),
+        new URI("s3a://bucket/t/part-1.parquet")))
+    shapes.foreach { case (shape, uris) =>
+      val reason = DeltaScanSupport.multiStoreReason(uris)
+      assert(reason.exists(_.contains("multiple object stores")), s"$shape: $reason")
+    }
+  }
+
+  test(
+    "multiStoreReason declines distinct underscore-bearing GCS buckets " +
+      "(URI#getHost null-collapse)") {
+    // `gs://my_bucket` has an underscore reg-name, which URI#getHost cannot parse -- it returns
+    // null for the WHOLE authority, not just an empty host. Keying uriAuthority on getHost alone
+    // would make every underscore-bearing bucket normalize to the same "null host" authority
+    // regardless of which bucket it actually is, so two distinct underscore buckets would
+    // wrongly collapse into one authority and never decline -- even though the native side
+    // parses `gs://my_bucket` and `gs://other_bucket` as genuinely different authorities and
+    // would hard-error on them. getAuthority (used by uriAuthority) returns the raw authority
+    // text regardless of RFC 3986 conformance, so this must decline instead.
+    val reason = DeltaScanSupport.multiStoreReason(
+      Seq(
+        new URI("gs://my_bucket/a/part-0.parquet"),
+        new URI("gs://other_bucket/b/part-1.parquet")))
+    assert(reason.isDefined)
+    assert(reason.get.contains("multiple object stores"))
+
+    // Same underscore-bearing bucket: one authority, claimable on both the JVM gate and the
+    // native check (native side asserted in delta_spark_scan.rs's
+    // same_underscore_host_bucket_files_pass).
+    assert(
+      DeltaScanSupport
+        .multiStoreReason(
+          Seq(
+            new URI("gs://my_bucket/a/part-0.parquet"),
+            new URI("gs://my_bucket/b/part-1.parquet")))
+        .isEmpty)
+  }
+
+  test(
+    "userInfoBearingAuthorityReason declines a single userinfo-bearing abfss authority " +
+      "(the behavior change: one container alone is no longer claimable)") {
+    val reason = DeltaScanSupport.userInfoBearingAuthorityReason(
+      Seq(new URI("abfss://container@account.dfs.core.windows.net/a/part-0.parquet")))
+    assert(reason.isDefined)
+    assert(reason.get.contains("userinfo"))
+  }
+
+  test(
+    "userInfoBearingAuthorityReason declines two containers on one storage account " +
+      "(cross-container deletion-vector authority on a single storage account)") {
+    val reason = DeltaScanSupport.userInfoBearingAuthorityReason(
+      Seq(
+        new URI("abfss://source@account.dfs.core.windows.net/a/part-0.parquet"),
+        new URI("abfss://clone@account.dfs.core.windows.net/_delta_log/dv/deletion_vector.bin")))
+    assert(reason.isDefined)
+  }
+
+  test(
+    "userInfoBearingAuthorityReason passes s3a data-file and deletion-vector paths " +
+      "(no regression for the MinIO live suites)") {
+    // Same bucket: userinfo-free authority, unaffected.
+    assert(
+      DeltaScanSupport
+        .userInfoBearingAuthorityReason(
+          Seq(
+            new URI("s3a://bucket/a/part-0.parquet"),
+            new URI("s3a://bucket/_delta_log/dv/deletion_vector.bin")))
+        .isEmpty)
+
+    // Distinct buckets, still no userinfo on either: this gate only inspects userinfo, so it is
+    // unaffected by multiStoreReason's separate authority-count decline (ported from the deleted
+    // storeIdentityCollisionReason suite's "passes distinct s3a buckets" case).
+    assert(
+      DeltaScanSupport
+        .userInfoBearingAuthorityReason(
+          Seq(
+            new URI("s3a://bucket-a/part-0.parquet"),
+            new URI("s3a://bucket-b/deletion_vector.bin")))
+        .isEmpty)
+  }
+
+  test("userInfoBearingAuthorityReason passes file:// paths (no authority at all)") {
+    assert(
+      DeltaScanSupport
+        .userInfoBearingAuthorityReason(
+          Seq(new URI("file:///tmp/a/part-0.parquet"), new URI("file:///tmp/b/part-1.parquet")))
+        .isEmpty)
+  }
+
+  test(
+    "userInfoBearingAuthorityReason: underscore-bearing GCS bucket passes without userinfo, " +
+      "declines with it (raw-authority parsing, not URI#getHost)") {
+    // `gs://my_bucket` has an underscore reg-name that URI#getHost cannot parse (returns null
+    // for the whole authority); no userinfo either way, so this must pass.
+    assert(
+      DeltaScanSupport
+        .userInfoBearingAuthorityReason(Seq(new URI("gs://my_bucket/a/part-0.parquet")))
+        .isEmpty)
+
+    // Same underscore-bearing bucket, now with userinfo: uriUserInfo's raw last-`@` split still
+    // finds it even though URI#getHost/getUserInfo would return null for this authority.
+    val reason = DeltaScanSupport.userInfoBearingAuthorityReason(
+      Seq(new URI("gs://u1@my_bucket/a/part-0.parquet")))
+    assert(reason.isDefined)
+  }
+
+  test("userInfoBearingAuthorityReason passes an hdfs authority with no userinfo") {
+    assert(
+      DeltaScanSupport
+        .userInfoBearingAuthorityReason(Seq(new URI("hdfs://nn:8020/table/part-0.parquet")))
+        .isEmpty)
+  }
+
+  test(
+    "userInfoBearingAuthorityReason redacts userinfo out of the decline reason (never leaks " +
+      "embedded credentials)") {
+    val reason = DeltaScanSupport.userInfoBearingAuthorityReason(
+      Seq(new URI("s3a://AKIAEXAMPLE:secr3t@bucket/a/part-0.parquet")))
+    assert(reason.isDefined)
+    assert(reason.get.contains("bucket"))
+    assert(!reason.get.contains("secr3t"))
+    assert(!reason.get.contains("AKIAEXAMPLE"))
+  }
+
+  test(
+    "unsupportedSelectedSchemeReason declines an all-viewfs selection, naming the scheme and " +
+      "the selected-file/DV wording") {
+    val viewfsUri = new URI("viewfs://cluster/table/part-0.parquet")
+    // Precondition: guards against a fail-open native build vacuously passing this test --
... 13511 lines suppressed ...


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org