Skip to content

[Spark] List _change_data separately to speed up VACUUM listing - #14

Open
sezruby wants to merge 157 commits into
masterfrom
vacuum-list-change-data-separately
Open

sezruby wants to merge 157 commits into
masterfrom
vacuum-list-change-data-separately

Conversation

@sezruby

@sezruby sezruby commented Aug 12, 2026

Copy link
Copy Markdown
Owner

What

VACUUM now lists the table's _change_data directory as its own listing
branch instead of recursing into it inline. Gated by
spark.databricks.delta.vacuum.listing.changeDataDirSeparately.enabled
(default true).

Relates to delta-io#2201 (improving VACUUM listing parallelism).

Why

VACUUM discovers files by:

  1. shallow-listing the table root,
  2. distributing that first level across the cluster, then
  3. recursing each first-level directory in a single task.

_change_data is one of those first-level directories, and it mirrors
the table's partitioning (or is a single large flat directory), so it can
hold a large fraction of the table's files. Recursing it inline leaves
one task listing that entire subtree while the rest of the cluster is
idle — typically the tail of VACUUM on tables with Change Data Feed
enabled. Simply deepening the initial listing does not help the common
case where _change_data is a flat directory: there are no
sub-directories to spread, so it is still a single listStatus.

What changed

  • VacuumCommand.getFilesFromFilesystem excludes _change_data from the
    main listing (via the dir-name filter) and lists it through a separate
    recursiveListDirs call. Its sub-directories then get their own
    repartition + parallel recursion, and because the two branches are
    unioned Spark schedules them concurrently.
  • The _change_data directory entry itself is emitted explicitly (the
    listing helper emits the contents of its roots, not the roots), so
    empty-directory cleanup behaves exactly as before.
  • If the table has no _change_data directory, or the config is off, the
    original single-call listing path is used unchanged.
  • recursiveListDirs is left as-is (no signature change).

The set of files considered by VACUUM is identical; only the listing
parallelism differs.

Tests

  • listing _change_data as a separate branch yields the same files and directories — builds a table-shaped tree (data partitions + a
    _change_data dir that mirrors partitioning and nests deeper) and
    asserts the separate-branch decomposition returns exactly the same set
    (paths + isDir) as the inline listing.
  • VACUUM removes the same untracked _change_data files whether listed separately or inline — end-to-end SQL VACUUM run with the config both
    on and off, confirming the same untracked files (including one nested
    deep under _change_data) are removed and the tracked file retained.

Both pass locally (spark/testOnly ... DeltaVacuumSuite).

🤖 Generated with Claude Code

tdas and others added 29 commits November 17, 2026 02:02
…hema in the V2 connector (delta-io#8105)

[AI-assisted]

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

The V2 connector's `SchemaUtils` has a Kernel-to-Spark schema converter:
`convertKernelSchemaToSparkSchema`,
`convertKernelDataTypeToSparkDataType`,
`convertKernelFieldMetadataToSparkMetadata`, and their private helpers.
Main code never calls them. Table schemas are built with
`convertKernelMetadataToSparkSchema`, which parses the log's schema
string with `DataType.fromJson`. Since delta-io#7942, the converter also rejects
collated strings.

This PR:
- removes the unused converter and its helpers. The Spark-to-Kernel
direction is unchanged.
- removes the `SchemaUtilsTest` cases that only covered the removed
code, and the Kernel-to-Spark halves of the round-trip checks.
- changes `PartitionUtilsTest` to get a snapshot's Spark schema through
`convertKernelMetadataToSparkSchema`, as the connector does.

## How was this patch tested?

`build/sbt "sparkV2/Test/javafmtCheck" "sparkV2/javafmtCheck"
"sparkV2/testOnly org.apache.spark.sql.delta.v2.utils.SchemaUtilsTest
org.apache.spark.sql.delta.v2.utils.PartitionUtilsTest"`: formatting
checks are clean, and 65 JUnit cases pass (`SchemaUtilsTest` 42,
`PartitionUtilsTest` 23).

## Does this PR introduce _any_ user-facing changes?

No.

---------

Signed-off-by: tdas <tathagata.das1565@gmail.com>
…-io#8171)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Before writing data files, Delta makes the query's output attributes
nullable (`TransactionalWrite.makeOutputNullable`), so that a query that
under-reports nullability can't produce unreadable Parquet files. The
helper it uses, `SchemaUtils.typeAsNullable`, skips primitive map values
and the elements of nested arrays and maps. When such a field holds
NULLs that the query reports as NOT NULL (e.g. from `lag`/`lead` with a
NULL default), they land in a required Parquet field: the commit
succeeds, but reading the table fails. This affects CTAS, RTAS, INSERT
INTO, INSERT OVERWRITE, DataFrame writes and MERGE INSERT.

This PR adds `SchemaUtils.typeAsFullyNullable`, which makes every nested
field nullable, and uses it in `makeOutputNullable`. Only the Parquet
schemas of the data files change; the table schema in the Delta log was
already fully nullable.

`typeAsNullable` is unchanged, because the DDL NOT NULL validation
(`removeUnenforceableNotNullConstraints`) also uses it, and making it
fully recursive would reject table schemas that are accepted today. Its
doc now says what it leaves as it is.

## How was this patch tested?

New tests in `SchemaUtilsSuite` cover what `typeAsNullable` and
`typeAsFullyNullable` return for each kind of nested type.

New tests in `TransactionalWriteSuite` write a query whose `lag`/`lead`
defaults put NULLs into a primitive map value, nested array elements and
values nested in map values, which the query reports as NOT NULL:
- For each write (CTAS, RTAS, CREATE OR REPLACE TABLE AS SELECT, INSERT
INTO, INSERT OVERWRITE, DataFrame save/append/overwrite,
DataFrameWriterV2 append, MERGE INSERT, INSERT BY NAME, MERGE UPDATE,
UPDATE), the NULLs read back correctly.
- A check that the query reports these fields as NOT NULL but returns
NULLs there, so the tests keep exercising the bug.

## Does this PR introduce _any_ user-facing changes?

Yes, a bug fix: writes whose query reports a primitive map value or a
nested array/map element as NOT NULL, but returns NULLs there, used to
commit Parquet files that couldn't be read afterwards. They now produce
readable files, and the NULLs read back.
…implementation (delta-io#8149)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Reconstruct the change files of an AMT commit per state reconstruction
implementation.

The change file reconstruction decodes each manifest row into an
`AMTDataEntryExtended` and converts it with `DataEntryResolver`, while
the columnar state reconstruction builds the same `AddFile`s as columns.
This gives the columnar implementation a change file read built from
those columns, so it has a single `AddFile` derivation. The per-row
implementation keeps its read and stays the default and the fallback.

Review it commit by commit in the stacked history this was exported
from; the change is:

- `trackingDerivedChangeActions` and `mdvDerivedChangeActions` are
declared on `AMTCheckpointProviderImpl`. `PerRowAMTCheckpointProvider`
keeps the existing per-row code. `ColumnarAMTCheckpointProvider` builds
them from its `AddFile` columns.
- Columnar change files: a live entry becomes its `add` column, stamped
with the commit-level `dataChange` and without a back reference. Any
other entry becomes a `RemoveFile` built from that `add` the way
`removeWithTimestamp` builds it. `removeFileColumn` maps every
`RemoveFile` field explicitly, so a new field fails the read until it is
mapped.
- `rootDataEntries` and `leafDataEntries` are shared by the snapshot
reads, the MDV read and the tracking-derived change file read.
`leafEntriesWithRowIdPrefix` is replaced by `leafDataEntries`.
- `PerRowAMTCheckpointProvider` and `ColumnarAMTCheckpointProvider` move
into their own files; `AMTCheckpointProvider` is no longer sealed.

## How was this patch tested?

`AMTCommitReconstructionSuite` runs every test with both implementations
and compares the reconstructed change files with the committed ones
(adds, removes and MDV-derived removes). It also asserts the two
implementations produce identical actions field by field, and that each
reconstructed `RemoveFile` equals `AddFile.removeWithTimestamp` of the
previous `AddFile`. `AMTAddFileFieldCoverageSuite` pins the `RemoveFile`
fields and calls `removeFileColumn` for each.
`AMTAddFileReconstructionSuite` checks that both implementations reject
a leaf entry read from a manifest that is not one of its parent's
leaves.

## Does this PR introduce _any_ user-facing changes?

No.

Co-authored-by: Isaac <no-reply@databricks.com>
#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other

## Description

Convert `SnapshotManagerFactory` from a Java utility class to a Scala
object and accept `Option[CatalogTable]`. Scala callers can pass catalog
metadata directly, while Java callers use Scala `Option`. Preserve
catalog selection, lookup timing, exceptions, and lazy path-based
fallback.

Keep the factory scoped to the v2 connector. Adapt the existing cache
tests to scoped Scala-object spying, add the required test dependency,
and open the Java reflection module for those tests on Java 17. Existing
test cases and assertions are unchanged.

## How was this patch tested?

Validated rebased head `dc2784b985f00d6543dd3be6a563d181e7be1b8e`
against master `ef61df0920cec80f49c2142719f823dbf626c6ad` on Java 17
with Spark 4.2:

```sh
build/sbt -DsparkVersion=4.2 \
  "sparkV2/testOnly org.apache.spark.sql.delta.v2.tablemanager.CachedSnapshotManagerSuite org.apache.spark.sql.delta.v2.snapshot.unitycatalog.UCUtilsSuite" \
  "spark/Test/compile"
```

All 42 tests passed: 35 cache tests and 7 UC utility tests. Unified
compilation, including both Java changelog callers, and `git diff
--check` passed. The rebase preserves the seven-file contribution scope
and all existing assertions.

## Does this PR introduce _any_ user-facing changes?

No.

Signed-off-by: Hao Sun <86338940+HaoSun1993@users.noreply.github.com>
[AI-assisted]

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Centralize construction of the three CDC output columns in one helper.
Preserve nullable fields for the internal Parquet read schema and
non-null fields for changelog output, matching the existing contracts.

## How was this patch tested?

- `build/sbt "sparkV2/Test/javafmtCheck" "sparkV2/testOnly
org.apache.spark.sql.delta.v2.read.cdc.CDCSchemaContextTest"`

## Does this PR introduce _any_ user-facing changes?

No.

---------

Signed-off-by: tdas <tathagata.das1565@gmail.com>
Co-authored-by: omnigent <noreply@omnigent.ai>
…o#8175)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Use `Utils.tryWithSafeFinally` in Delta iterator helpers, streaming
source
cleanup, and eager log reads. When processing and closing both fail,
preserve
the processing exception and attach the close exception as suppressed. A
close
failure still propagates when processing succeeds.

Apply the same handling when constructing a wrapped iterator fails,
while keeping
successfully constructed lazy iterators open until their owner closes
them.

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?

Added regression coverage in `LineClosableIteratorSuiteBase` for
processing
failures with and without close failures, close-only failures, wrapped
iterator
construction failures, and successful lazy iterator ownership.

`git diff --check`, `sparkV2/javafmt`, and `sparkV2/Test/javafmt`
passed.
Both Java formatter tasks completed without changing any files.

The two iterator suites passed against Spark 4.0: 32 tests, zero
failures.

```bash
build/sbt -DsparkVersion=4.0 \
  "spark/testOnly org.apache.spark.sql.delta.storage.InternalLineClosableIteratorSuite org.apache.spark.sql.delta.storage.PublicLineClosableIteratorSuite"
```

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?

Yes. If processing and cleanup both fail, callers now receive the
original
processing exception with the cleanup exception suppressed, instead of
losing
the original failure. Successful processing behavior is unchanged.

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

---------

Signed-off-by: You Zhou <yz3883@columbia.edu>
[AI-assisted]

## What changes were proposed?

Define the Delta V2 enable modes as named constants in `DeltaSQLConf`
and reuse those constants in `DeltaV2Mode`. This removes duplicate
string literals without changing defaults, validation, case handling, or
connector-selection behavior.

## How was this patch tested?

- `sparkV2/compile`
- `spark/compile`
- `DeltaV2CDFSuite` (27 tests)
- `DeltaTableRefreshAutoModeSuite` and
`DeltaTableRefreshStrictModeSuite` (72 tests)

---------

Signed-off-by: tdas <tathagata.das1565@gmail.com>
…redicate hints (delta-io#8109)

#### Which Delta project/connector is this regarding?

- [ ] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [x] Other (Sharing)

## Description

When a delta-format Delta Sharing query has one filter that can't be
converted to a json predicate (e.g. `RLIKE`/`LIKE`, or a large `IN`
list, which the optimizer turns into `InSet`), `OpConverter` throws. The
whole partition-filter or data-filter hint is then dropped, so the
sharing server can't skip any files and returns the full file list, even
though the other filters could have been used for skipping.

`DeltaSharingJsonPredicates.convert` now honors
`spark.delta.sharing.jsonPredicateHints.partialFilter.enabled`. That
conf, and partial conversion in `OpConverter`, shipped in
delta-sharing-client 1.4.1 (delta-io/delta-sharing#983), and the
parquet-format path (`RemoteDeltaFileIndex`) already uses them. When the
conf is on, `OpConverter` emits `UnsupportedOp` placeholders, and
`UnsupportedOpPruner` removes them before the hint is serialized:
- An AND keeps its supported children.
- An OR or NOT that contains an unsupported node is dropped whole.

So the hint still matches a superset of the files with matching rows,
and `UnsupportedOp` is never sent to the server. The conf applies to
both the partition and the data side of the hint. It defaults to
`false`, so behavior is unchanged unless it is enabled.

## How was this patch tested?

New `DeltaSharingFileIndexSuite` test "jsonPredicate partial filter
drops only unsupported sub-expressions". It pins the three hint confs
and asserts the exact json hint sent to the server:
- With the conf off, an unsupported `RLIKE` or a 21-value `IN` still
drops the whole data-filter side, as before.
- With the conf on:
- an unsupported AND conjunct (`RLIKE`, `InSet`, or a 21-value `IN`) is
dropped while the supported partition and data conjuncts are kept;
  - an OR containing an unsupported branch is dropped entirely;
  - a predicate with nothing supported sends no hint;
  - fully supported predicates produce the same hint as before.

Each check also asserts that exactly one file-listing call was made, so
a missing hint can't come from a cache hit.

## Does this PR introduce _any_ user-facing changes?

No. The behavior only changes when
`spark.delta.sharing.jsonPredicateHints.partialFilter.enabled` is set to
`true` (default `false`). With it on, queries with unsupported filters
can get server-side file skipping from their remaining filters.

This pull request and its description were written by Isaac.

---------

Signed-off-by: Abhijit Chakankar <abhijit.chakankar@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
…or (delta-io#8173)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

`SingleCommit.getActionsIterator` returned the actions of a commit's log
file as written. For an inline manifest commit of a table with an
adaptive metadata tree, the `AddFile` and `RemoveFile` actions are
recorded in the tree, so the iterator did not return them. Callers that
process a commit's actions one at a time, without loading them all into
memory, need the actions that `getActions` returns.

- With `DeltaSQLConf.AMT_SINGLE_COMMIT_READ_ENABLED` on,
`getActionsIterator` returns the same actions as `getActions`, in the
same order: the log file's other actions, then the file actions
reconstructed from the tree. With the conf off, it returns the log file
as written.
- The new `AMTCheckpointProviderImpl.reconstructFileActionsIterator`
returns the actions of `reconstructFileActions`, in its order, and pulls
them to the driver one partition at a time. The iterator opens the tree
only after it has read the log file's actions. `rewind()` reads both
again.
- `getActions` and `getActionsIterator` share one path. A commit is an
inline manifest commit when its first action is a `CommitInfo` whose
`lastManifestCommit` is at the commit's own version
(`CommitInfo.isAMTInlineManifestCommit`). Its tree is located from its
`Checkpoint` action, and the read fails if that action is missing.
- The test helper `getJsonOnlyChanges` now reads the log files directly.

## How was this patch tested?

New tests in `AMTSingleCommitSuite`:
- `getActionsIterator` returns the same actions after `rewind()`.
- `getActions` and `getActionsIterator` return a manifest commit's
actions in the same order.
- `reconstructFileActionsIterator` returns the actions of
`reconstructFileActions` in order, with 7 shuffle partitions.
- `getActionsIterator` returns a log commit as written, and returns the
log file as written when single-commit read is off.

The existing `getChanges` test for an inline manifest commit also checks
`getActionsIterator`.

## Does this PR introduce _any_ user-facing changes?

No.
…io#8184)

[AI-assisted]

## Description

Adds a concurrency group to the Delta Spark workflow with
`cancel-in-progress: true`. PR runs are grouped by PR number, so a new
commit cancels the previous in-progress run for the same PR.

Non-PR runs—pushes to `master` or `branch-*`, and `workflow_dispatch`
runs—fall back to `github.run_id`, giving every run a unique concurrency
group. They are therefore never cancelled, preserving a full CI result
for every master commit and maintaining master regression detection.

## Testing

- Parsed `.github/workflows/spark_test.yaml` successfully with PyYAML.
- `git diff --check` passed.
- Confirmed the final diff against `delta/master` contains only the
concurrency comment and block.

---------

Co-authored-by: omnigent <noreply@omnigent.ai>
…lta-io#8180)

[AI-assisted]

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

Merge the Java and Scala map overload implementations of
`getPartitionRow` through a shared
helper. The overload-specific behavior remains unchanged, including the
Java map size assertion,
the Scala map missing-key handling, and lazy map access for empty
partition schemas.

## How was this patch tested?

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

- `build/sbt "sparkV2/Test/javafmtCheck"`
- `build/sbt "sparkV2/testOnly
org.apache.spark.sql.delta.v2.utils.PartitionUtilsTest"`
  (23 test cases)

## Does this PR introduce _any_ user-facing changes?

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

No.

---------

Signed-off-by: tdas <tathagata.das1565@gmail.com>
…8181)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Re-enable `incremental: commit file gap between versions,
failOnDataLoss=false succeeds`
in `DeltaV2SourceSuite` by moving it from `FailingTests` to
`PassingTests`.
Remove the obsolete comment that describes this case as unsupported.

This restores regression coverage for streaming across a gap between
commit versions
when `failOnDataLoss=false`.

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?

`git diff --check` passed. Tests were not run locally because this
change only
re-enables an existing test; execution is left to the Spark CI workflow.

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?

No. This change only updates test coverage.

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

Signed-off-by: You Zhou <yz3883@columbia.edu>
#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

The Delta protocol calls these tables catalog-managed, and the table
feature is `catalogManaged`. Comments in the Spark connector still say
"catalog-owned", "Catalog Owned" or "CatalogOwned tables". This PR
changes that prose to "catalog-managed".

## How was this patch tested?

Comment-only change.

## Does this PR introduce _any_ user-facing changes?

No.
…s definitions (delta-io#8158)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Stacked on delta-io#8151; review the last commit.

Renames the `CatalogOwnedTableFeature` and `CatalogOwnedTableUtils`
objects to `CatalogManagedTableFeature` and `CatalogManagedTableUtils`.
The feature name in the protocol stays `catalogManaged`.

The old names stay as aliases, in the `delta` package object and in a
new `coordinatedcommits` package object, so the callers keep compiling
until the PRs stacked on this one move them to the new names.
`UCDeltaCatalogClientImpl.scala` moves to the new name here.

## How was this patch tested?

Rename only, no new tests. Apart from the aliases and the line wrapping,
every changed token is an old name changed to the new one.

## Does this PR introduce _any_ user-facing changes?

No.
#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Record substantive Delta V2 snapshot loads, history requests, file-state
construction,
and table-manager cache lifecycle operations through the existing
operation hooks.
Normalize operation names under `delta.v2.` and attribute events to the
table path
without requiring a DeltaLog-backed provider. Cache timing uses a shared
elapsed-time helper.

Keep `KernelContext` focused on filesystem options and its LogStore.
Remove the unused
table-path constructor/factory argument and update the production and
test callers;
engine creation does not use that argument. Keep configuration
materialization scoped
to the active session with table options overlaid.

Path and payload construction for table-scoped events is guarded so
non-fatal
telemetry failures preserve the caller's control flow and original
exception.
Ordinary cache hits, snapshot freshness decisions, cleanup behavior, and
exceptions
retain their existing behavior.

This is the root of the operations stack: delta-io#8067, delta-io#8068. It is based
directly on master
and can be reviewed independently of the diagnostics stack (delta-io#8062,
delta-io#8066).
Design agreement is tracked in delta-io#8065 and remains pending.

## How was this patch tested?

Both `sparkV2/Test/compile` and `spark/Test/compile` passed. Six
affected suites
passed all 92 tests with zero failures or skips: KernelContextSuite (7),
CachedSnapshotManagerSuite (35), UCManagedTableSnapshotManagerSuite
(10),
DeltaV2SnapshotSuite (23), KernelSnapshotUtilsSuite (5), and
ApplyV2ReadOptionsSuite (12).

Style checks passed for all changed Scala files.

Whitespace checks pass. CI must rerun on the updated head.

## Does this PR introduce _any_ user-facing changes?

Yes. Delta V2 operation hooks gain consistent names and table
attribution.
Query results and the transaction-log format are unchanged.

---------

Signed-off-by: Zheng Hu <openinx@gmail.com>
…ts (delta-io#8182)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

The V2 scan Java tests cast the built scan to DeltaV2Scan in about 90
places. A failed cast gives a ClassCastException that does not say which
scan the builder built.

Add DeltaV2TestBase.asDeltaV2Scan, which checks the type and fails with
the class name of the scan, and use it in DeltaV2ScanTest,
DeltaV2ScanBuilderTest, and DeltaV2BatchTest. The test assertions do not
change.

## How was this patch tested?

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

Existing tests

## Does this PR introduce _any_ user-facing changes?

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->
No

Signed-off-by: Hari Kishore Chaparala <hchapara@uci.edu>
Co-authored-by: Isaac <no-reply@databricks.com>
…eltaV2MicroBatchStream (delta-io#8187)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

This PR starts to share the offset logic of the DSv1 streaming source
`DeltaSource` with the DSv2 streaming source `DeltaV2MicroBatchStream`.
Each PR moves one `DeltaSource` method, unchanged, into a shared trait,
and deletes the `DeltaV2MicroBatchStream` copy.

This PR adds the trait `DeltaSourceOffsetLogic`, which both sources mix
in, and moves `checkNonAdditiveSchemaChanges` into it.
`DeltaV2MicroBatchStream` now also runs the
`assert(!trackingMetadataChange)` check that `DeltaSource` has. Every
`DeltaV2MicroBatchStream` caller already skips the check while it tracks
metadata.

## How was this patch tested?

Existing tests. No test file changes.

## Does this PR introduce _any_ user-facing changes?

No.
#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other

## Description

`SnapshotManagementParallelListingSuite` registers its test coordinator
for `spark_catalog`. If another catalog is current, its unqualified
table name creates the table elsewhere and bypasses that coordinator.
Qualify the test table name and use an explicit catalog-qualified
identifier when opening the Delta log so the listing reconciliation
assertions exercise the intended coordinator.

## How was this patch tested?

- `git diff --check` passed.
- The local `spark/testOnly
org.apache.spark.sql.delta.SnapshotManagementParallelListingSuite` run
could not start because the sbt launcher download was unavailable. The
suite will run in CI.

## Does this PR introduce _any_ user-facing changes?

No.

Signed-off-by: Eric Tseng <52102337+EricTsengTy@users.noreply.github.com>
delta-io#8170)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description
Support querying versionless CDF for delta sharing clients with delta
format.
<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?
UTs
<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?
No
<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

---------

Co-authored-by: Omar Elhadidy <omar.elhadidy@databricks.com>
…a-io#8157)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Stacked on delta-io#8158; review the last commit.

Renames the `CatalogOwnedUsageLogs` object, which holds the op types of
catalog-managed tables, to `CatalogManagedUsageLogs`. The
`coordinatedcommits` package object keeps the old name as an alias. The
op type values, such as `delta.catalogOwned.commitToUcEtagRetry`, stay
the same.

## How was this patch tested?

Rename only, no new tests. Apart from the aliases and the line wrapping,
every changed token is an old name changed to the new one.

## Does this PR introduce _any_ user-facing changes?

No.
…builders (delta-io#8113)

[AI-assisted]

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Extracts the shared row-tracking file metadata lookup, missing-value
validation, and long conversion used by the V2 row ID and row commit
version value setter builders. Exception types and messages remain
unchanged.

## How was this patch tested?

- `build/sbt "sparkV2/Compile/javafmtCheckAll"`
- `build/sbt "sparkV2/testOnly
org.apache.spark.sql.delta.v2.read.metadata.MetadataStructReadFunctionTest
org.apache.spark.sql.delta.v2.read.metadata.MetadataStructSchemaContextTest
org.apache.spark.sql.delta.v2.read.metadata.MetadataValueSetterTest
org.apache.spark.sql.delta.v2.V2RowTrackingReadTest"`

## Does this PR introduce _any_ user-facing changes?

No.

---------

Signed-off-by: tdas <tathagata.das1565@gmail.com>
… have deletion vectors (delta-io#8190)

#### Which Delta project/connector is this regarding?

- [x] Spark

## Description

`DeletionVectorsTableFeature.validateDropInvariants` treated an unknown
DV count as zero.
`numDeletionVectorsOpt` is unknown when DVs are no longer writable and
the snapshot has no checksum
with the count, for example after a RESTORE commit. In that case DROP
FEATURE deletionVectors
succeeded while files still had deletion vectors.

This change checks the files themselves
(`DeletionVectorUtils.isTableDVFree`) when the count is
unknown.

## How was this patch tested?

Tested with a scenario that drops the feature after a RESTORE leaves the
DV count unknown while
files still have DVs.
Without this change DROP FEATURE succeeds; with it, DROP FEATURE fails
with
`DELTA_FEATURE_DROP_CONFLICT_REVALIDATION_FAIL`.

## Does this PR introduce _any_ user-facing changes?

No.

Co-authored-by: Isaac <no-reply@databricks.com>
delta-io#8194)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

A clustered table can be clustered by a field inside a struct, for
example `a.b`. DROP COLUMNS rejects a drop of a clustering column, but
it compares only whole names.

`DROP COLUMNS (a)` drops the struct `a`, and `a.b` with it. The check
misses that, because `"a"` is not `"a.b"`. The table is then clustered
by a column that is gone, and later writes, DESCRIBE DETAIL and OPTIMIZE
fail with `DELTA_CANNOT_RESOLVE_CLUSTERING_COLUMN`.

The check now also rejects a drop of a struct that holds a clustering
column: it matches when the name parts of a dropped column are a prefix
of the name parts of a clustering column.

## How was this patch tested?

New test in `ClusteredTableDDLSuite`: on a table clustered by `a.b`,
`DROP COLUMNS (a)`, `(A)` and `(a.b)` fail with
`DELTA_UNSUPPORTED_DROP_CLUSTERING_COLUMN`, and `DROP COLUMNS (a.c)`
succeeds and keeps `a.b` as the clustering column.

## Does this PR introduce _any_ user-facing changes?

Yes. `DROP COLUMNS` of a struct that holds a clustering column now fails
with `DELTA_UNSUPPORTED_DROP_CLUSTERING_COLUMN`. Before, it succeeded
and left the table clustered by a missing column.
)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Make `DeltaDataFrameWriterV2Suite` easier to reuse with other table
providers while
preserving its existing Delta expectations:

- Extract partition assertions into overridable `assertPartitionedById`
and
  `assertUnpartitioned` helpers.
- Use the existing `createTableSQL` and `writeFormat` helpers in the
literal-string
  overwrite tests instead of hardcoded provider names.
- Remove an unused import.

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?

`git apply --check` and `git diff --check` passed. The test suite has
not been run
in this checkout.

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?

No. This only refactors test scaffolding; the default assertions and
provider
remain unchanged.

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

Signed-off-by: Tejas Maire <36109575+tmaire111@users.noreply.github.com>
…elta-io#8121)

[AI-assisted]

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

`DeltaV2ScanUtils.newScanBuilder` was a pass-through to
`DeltaV2ScanBuilder.create`, which only derived the snapshot manager
from the table manager (`tableManager.snapshotManager(catalogTable)`)
and called the `DeltaV2ScanBuilder` constructor. Two factory layers did
one job.

This PR removes the extra layer:
- `DeltaV2ScanUtils.newScanBuilder` now constructs the
`DeltaV2ScanBuilder` directly, with the same arguments `create` used. It
stays the single entry point because `DeltaV2ScanBuilder` is
`private[read]` and its production caller, `DeltaV2Table`, lives in
another package. It also returns only the `ScanBuilder` interface.
- `DeltaV2ScanBuilder.create` is deleted.
- `DeltaV2ScanBuilderTest` now builds its scan builder through
`DeltaV2ScanUtils.newScanBuilder`, the same path `DeltaV2Table` uses.

This is a pure refactor with no behavior change.

## How was this patch tested?

Existing tests:
- `build/sbt "sparkV2/Test/javafmtCheck" "sparkV2/javafmtCheckAll"`
passes.
- `build/sbt "sparkV2/testOnly
org.apache.spark.sql.delta.v2.read.DeltaV2ScanBuilderTest
org.apache.spark.sql.delta.v2.read.DeltaV2ScanTest"` passes all 120 test
cases: 35 in `DeltaV2ScanBuilderTest` and 85 in `DeltaV2ScanTest`.

## Does this PR introduce _any_ user-facing changes?

No.

This pull request and its description were written by Isaac.

Signed-off-by: tdas <tathagata.das1565@gmail.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: omnigent <noreply@omnigent.ai>
…lta-io#8118)

[AI-assisted]

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Clarify that the limit-aware scan receives partition-only filters
because `build()` only sets `effectiveLimit` when there are no residual
data filters.

## How was this patch tested?

- `sparkV2/Compile/compileIncremental`
- `sparkV2/Compile/javafmtCheckAll`
- `sparkV2/Compile/scalafmtCheckAll` (blocked by pre-existing formatting
failures)

## Does this PR introduce _any_ user-facing changes?

No.

Signed-off-by: tdas <tathagata.das1565@gmail.com>
…ts (delta-io#8202)

## Summary

- Run coordinator retry and `commitLarge` failure tests against
catalog-managed Delta tables.
- Preserve the retry limits, exception checks, and failure telemetry
assertions.
- Remove a legacy property-based commit-directory test and mark four
coordinator cases as expected failures in the V2 interop suite.

## Testing

- `git diff --check`
- Focused sbt test could not start because the sbt launcher download
failed in the local checkout. Public CI will run the suite.

Signed-off-by: Eric Tseng <52102337+EricTsengTy@users.noreply.github.com>
…Coordinator* (delta-io#8153)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Stacked on delta-io#8157; review the last commit.

Renames `CatalogOwnedCommitCoordinatorBuilder` and
`CatalogOwnedCommitCoordinatorProvider` to
`CatalogManagedCommitCoordinatorBuilder` and
`CatalogManagedCommitCoordinatorProvider`. The `coordinatedcommits`
package object keeps both old names as aliases.

## How was this patch tested?

Rename only, no new tests. Apart from the aliases and the line wrapping,
every changed token is an old name changed to the new one.

## Does this PR introduce _any_ user-facing changes?

No.
…nabled (delta-io#8205)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Adds a required `isPreviewCompatible` parameter to
`AMTUtils.amtSupported` and `AMTUtils.amtEnabled`, so every caller
states whether it handles `adaptiveMetadata-preview` tables. With
`false`, preview tables don't count as AMT tables;
`adaptiveMetadata-dev` tables behave as before. New code paths, such as
`tightStats`, pass `false` so they don't run on preview tables, which
older clients still read and write.

Every existing caller passes `true`, so this PR doesn't change behavior.
The single-argument `amtEnabled(snapshot)` overload is removed; callers
use `amtEnabled(snapshot, isPreviewCompatible)`.

## How was this patch tested?

`AMTUtilsSuite` checks every feature and AMT property case with the flag
set to `true` and to `false`. `AdaptiveMetadataTableFeatureSuite` checks
the snapshot form on real tables: with `false`, only
`adaptiveMetadata-dev` tables count as AMT tables.

## Does this PR introduce _any_ user-facing changes?

No.
zikangh and others added 29 commits November 25, 2026 05:22
delta-io#8327)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

`DeltaSink` calls `txn.readWholeTable()` when the micro-batch plan reads
the sink table, so that a concurrent DELETE, UPDATE or MERGE on that
table conflicts with the stream's commit. The check matched only V1
reads (`DeltaTable(index)`). When the batch read the sink table through
the V2 connector (a V2 stream of the sink table, or a static V2 read),
the commit was a blind append. A concurrent DELETE was then not
detected, and the stream could commit rows computed from deleted data.

This PR adds arms for `DataSourceV2Relation` (a static read) and
`StreamingDataSourceV2ScanRelation` (the stream) over a
`DeltaV2TableMarker`. They compare the V2 table's table id and qualified
data path with the sink log's, the same pair `DeltaLog.isSameLogAs`
compares for V1 reads, so no `DeltaLog` is created for the V2 table.
`DeltaV2TableMarker` gets a `compositeId` accessor for this.
`DeltaV2Table` takes the id from the snapshot it loaded and qualifies
its table path with Hadoop, as `DeltaLog` does, because the Kernel
engine can resolve symbolic links in its path and Hadoop does not.

## How was this patch tested?

Streaming tests that read the sink table through the V2 connector and
write it to a path:
- A stream that reads its sink table, with a DELETE committed while the
sink transaction writes: the batch fails with a concurrent-append
conflict, and the deleted row is not written back.
- A stream-static join with the sink table: the commit has
`isBlindAppend=false`.
- A stream that reads the sink table through a symbolic link: the batch
fails with the same conflict.
- A stream of another table, or of a copy of the sink table at another
path: the commit stays a blind append.

## Does this PR introduce _any_ user-facing changes?

Yes. A stream that reads its own sink table through the V2 connector now
commits with a whole-table read, the same as a V1 read. A concurrent
DELETE, UPDATE or MERGE on the sink table now fails the batch with a
concurrent-append conflict. Before, the batch committed as a blind
append.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
…ta-io#8328)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Share metadata and protocol action collection between the V1 and V2
streaming sources.
The four common collectors live in the
`DeltaSourceMetadataEvolutionSupport` companion
object; only `collectActions` depends on the streaming backend. Both
backends interleave
commit and action reads, and V2 closes both iterators on completion or
early exit.

The range collectors materialize their results with `.toList` before
closing the iterator.
Single-version collectors return the first matching action.

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?

Added and moved regression coverage for duplicate actions,
single-version reads,
eager range collection, protocol validation, commit/action interleaving,
iterator
cleanup, and version ranges. Local tests were not run for this update.

Both `build/sbt "sparkV2/javafmt"` and `build/sbt
"sparkV2/Test/javafmt"` completed
successfully. The test formatter updated three files; those changes are
included.

`build/sbt -DsparkVersion=4.2 "sparkV2/Test/compile"` passed after
restoring
the protocol exception import. No tests were executed.

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?

Yes, in action collection and failure timing:

- **V1 on Scala 2.12 now matches V1 on Scala 2.13 and V2:** range
collection is eager.
This can increase memory use and surface a later read failure before
validation of
  an earlier action. V1 on Scala 2.13 already collected eagerly.
- **V2 now matches V1:** range collectors retain duplicate
metadata/protocol actions,
and single-version collectors return the first match without necessarily
reading
malformed trailing actions. The previous V2 collectors rejected
duplicates.
- **V2 now matches V1:** collectors no longer perform an additional
historical
  `protocolRead` validation for each encountered protocol action.
- **V2 now matches V1:** action buffering uses
`LOG_SIZE_IN_MEMORY_THRESHOLD`
instead of always streaming with a zero threshold. This changes memory
use and
  when parsing failures can occur.
- **V2 now matches V1:** iterator and I/O failures propagate directly
instead of
  being wrapped in `RuntimeException("Failed to process commits", ...)`.

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

---------

Signed-off-by: You Zhou <yz3883@columbia.edu>
…delta-io#8326)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g.,
'[WIP][Spark] Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
-->

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

This PR teaches every reader of an AMT checkpoint to understand
non-content sidecars. The [Iceberg V4 metadata
RFC](https://github.com/delta-io/delta/blob/master/protocol_rfcs/iceberg-v4-metadata.md)
lets a checkpoint action carry its set transactions and domain metadata
either inline or in typed parquet sidecars (`SidecarFile` with `type =
txn` or `type = domainMetadata`, under `_delta_log/_sidecars/`), or
split across both, with each key in exactly one place. Having the read
side in place means that once a writer starts producing such sidecars,
readers do not silently lose txns or domains: streaming idempotency
(`txnVersion`), row tracking, clustering and every user domain keep
reading the full set. No checkpoint bytes change, and reading is always
on with no conf.

## How was this patch tested?

New `AMTNonContentSidecarSuite`. Since no writer produces sidecars yet,
each test writes the sidecar parquet files itself and serves a snapshot
from a checkpoint rebuilt with its txns and user domains moved into
those sidecars. It covers: no checkpoint writes sidecars even with 150
txns and domains; the union of inline and sidecar entries in
`setTransactions`, `domainMetadata` and `stateDS`, with the same live
files; later commits that update a sidecar txn and remove a sidecar
domain; a kind split across inline entries and sidecars; an untagged
sidecar; a row of the wrong type; the incremental writer reading old
sidecars and writing their entries inline; and the incremental writer
failing on a txn or domain key duplicated across inline entries and
sidecars.

## Does this PR introduce _any_ user-facing changes?

No.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
… DeltaSource (delta-io#8337)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

This PR continues to share the offset logic of the DSv1 streaming source
`DeltaSource` with the DSv2 streaming source `DeltaV2MicroBatchStream`.

This PR makes the non-CDC `getFileChanges` path of
`DeltaV2MicroBatchStream` read each commit once, as `DeltaSource` does.
`processCommitToIndexedFiles` now gets the commit's actions with
`DeltaSource.createRewindableActionIterator`, validates them, and then
rewinds the same iterator for the indexed files. Before, it opened the
commit file twice. A commit below
`spark.databricks.delta.streaming.logSizeInMemoryThreshold` is read once
and kept in memory; a larger commit is read again, as in `DeltaSource`.
The CDC path and `StreamingHelper` do not change.

## How was this patch tested?


`DeltaV2MicroBatchStreamTest.fileChangesReadEachCommitOnceWhenItFitsInMemory`
counts the log file reads at the default threshold and at 0, also for a
batch that ends at the start of a commit.

## Does this PR introduce _any_ user-facing changes?

Each change makes the DSv2 streaming source behave like the DSv1 source.
The files, their order and the offsets do not change.
- Driver memory: a non-CDC commit whose log file is below
`spark.databricks.delta.streaming.logSizeInMemoryThreshold` (default 128
MB) is now read once, and its parsed actions stay in driver memory while
the DSv2 source emits the commit's files: one commit at a time, two for
a moment when it opens the next commit. Before, the DSv2 source read
each commit twice and kept no actions in memory. Set the conf to 0 to
get the old behavior.
- Conf read timing: the DSv2 source reads this threshold from
`spark.sessionState.conf` for each commit, as the DSv1 source does, so a
change applies from the next commit. Most other DSv2 settings come from
the `SQLConf` that the source captures at construction.
- End commit of a batch: when a batch ends at `(v, BASE_INDEX)`, the
DSv2 source now reads and parses all of commit `v` if `v` is below the
threshold. Before, it read only the start of `v`. So a read or parse
error anywhere in `v` now fails this batch.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
…ange (delta-io#8296)

#### Which Delta project/connector is this regarding?

- [ ] Spark
- [ ] Standalone
- [ ] Flink
- [x] Kernel
- [ ] Other (fill in here)

## Description

A `CommitRange` built with `withCommitRangeValidation(false)` is meant
for callers that want the raw commit files of a version range, the way
DeltaLog lists them, rather than a validated, action-readable range.
Until now it still behaved like a validated range in several ways: it
rejected a reversed range, rejected an empty one, resolved gaps by
failing at build time, and could not tell "the log ends here" from "a
version in the middle is missing". Callers moving from DeltaLog's raw
commit-file listing therefore saw different results.

With this change a relaxed range follows DeltaLog's raw commit-file
listing:

- A reversed range given with an explicit end boundary (`start > end`)
and an empty range (no commit at or after the start) are accepted. An
empty range with no end is anchored at `endVersion = startVersion`.
Without an explicit end boundary, the start must still not exceed
`maxEndVersion` or `maxCatalogVersion`, as before.
- `getCommitFiles()` reports a missing version lazily, from `hasNext()`,
and only when a later commit that was actually observed proves it is
missing. That is the next commit in the range, or the first commit after
it. A missing suffix with no later commit is not an error. This is
controlled by `withFailOnDataLoss(boolean)`; with it off, the available
files are yielded across gaps.
- The file listing stops at the end version, or right after the first
commit past it, instead of reading further than the proof needs.

Relaxed ranges list through a separate path,
`getRelaxedDeltasForVersionRange`, which `CommitRangeFactory.create()`
picks when validation is off. The validated listing functions are
unchanged, and relaxed ranges still reject action iteration. The change
adds no public API; `CommitRange` and `CommitRangeBuilder` only get
Javadoc updates.

## How was this patch tested?

`CommitRangeBuilderSuite` covers every relaxed case in one table, each
run with `failOnDataLoss` true and false: bounded, unbounded, reversed
and empty ranges, and catalog-managed ranges with staged commits. Other
tests check that the listing stops early, that the end version is
anchored for an empty range, and that a staged commit takes priority
over a published one. The start-version and start-timestamp
`withMaxEndVersion` checks run with validation on and off.

From the repository root:

```bash
build/sbt "kernelApi/testOnly io.delta.kernel.internal.CommitRangeBuilderSuite"
build/sbt kernelApi/javafmtCheck
```

## Does this PR introduce _any_ user-facing changes?

Only for ranges built with `withCommitRangeValidation(false)`, compared
with current master: reversed (with an explicit end boundary) and empty
ranges now build, and `getCommitFiles()` reports a missing version from
`hasNext()` only when a later observed commit proves it. Ranges with
validation on behave as before, and there are no new public methods.

---------

Signed-off-by: Thinh Bui <26578143+thinh2@users.noreply.github.com>
…nagedTestBaseSuite (delta-io#8320)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Moves `CloneTableSQLSuite`, `CloneTableSuiteBase`,
`RestoreTableSuiteBase`, `DeltaTimeTravelSuite`,
`DescribeDeltaDetailSuite`, `DescribeDeltaHistorySuite` from
`CatalogOwnedTestBaseSuite` to `CatalogManagedTestBaseSuite`, the new
name of the test base (delta-io#8314). The old name is an empty sub-trait of the
new one, so the suites keep the same members.

## How was this patch tested?

Rename only, no new tests.

## Does this PR introduce _any_ user-facing changes?

No.
…er overload change (delta-io#8338)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

`AMTCheckpointProvider.apply` no longer takes a `spark` argument since
delta-io#8325, but `AMTNonContentSidecarSuite` from delta-io#8326 still passes one, so
the Spark test sources on master do not compile. This PR drops the
argument.

## How was this patch tested?

`spark/Test/compile` succeeds and `AMTNonContentSidecarSuite` passes.

## Does this PR introduce _any_ user-facing changes?

No.

This pull request and its description were written by Isaac.
…elta-io#8255)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Internal checks of the V2 connector threw bare JVM exceptions
(`IllegalArgumentException`, `IllegalStateException`,
`NullPointerException`), so the user saw an error without an error class
or SQLSTATE.

This PR:
- Adds the error class `DELTA_V2_INTERNAL_ERROR` (SQLSTATE `XXKDS`) with
the subclasses `ILLEGAL_ARGUMENT`, `ILLEGAL_STATE` and
`UNSUPPORTED_OPERATION`. The messages have no parameters, so no internal
text reaches the user.
- Adds `DeltaErrors.deltaV2IllegalArgument`, `deltaV2IllegalState` and
`deltaV2UnsupportedOperation`. The detail of the failed check stays in
the cause for debugging. Each helper returns a Delta exception of the
same Java type as the exception it replaces, so callers that catch that
type still work.
- Uses them for the internal checks in `DeltaV2Snapshot` and
`DeltaV2ScanBuilder` (a negative pushed limit).
`DeletionVectorSchemaContext` keeps its `IllegalArgumentException`: a
user can create a column with the deletion-vector column's name, so an
internal error class does not fit there.

## How was this patch tested?

`DeltaV2SnapshotSuite` checks the error class, the SQLSTATE and the
cause of the new errors.

## Does this PR introduce _any_ user-facing changes?

Yes. These internal failures now raise
`DELTA_V2_INTERNAL_ERROR.<subclass>` with SQLSTATE `XXKDS` instead of a
bare JVM exception. The Java exception types are unchanged.
#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

AMT writes Iceberg's `tight_stats` as `false` for every entry and reads
it back as `tightBounds`, so a file's `tightStats` doesn't survive a
manifest round trip. Entries now keep it:

- `tight_stats` holds `tightStats`, and is null when the stats lack it.
Entries without stats, such as manifest pointers, keep `false`.
- `tightBounds` has no Iceberg counterpart and is dropped. A file
without `tightStats` reads back with `tightBounds = false`, which is
never wrong. On tables whose stats have no `tightStats`, such as
`adaptiveMetadata-preview` tables, `tightBounds` is still read from
`tight_stats`, as before. Keeping `tightBounds` in a separate field of
the entry is a TODO.
- An entry without `content_stats` reads back with `tightBounds` from
its `tight_stats`, both as the stats JSON and through
`AMTContentStats.parsedStats`.

So a file with `tightStats` reads back with it and with no
`tightBounds`, and stays tight through AMT checkpoints.

## How was this patch tested?

`AMTContentStatsSuite` round-trips every combination of the two flags,
and checks that an `adaptiveMetadata-preview` entry reads its
`tight_stats` back as `tightBounds`. `AMTTightStatsSuite` checks that
files widened by deletion vectors keep `tightStats`, and that files
without it read back with `tightBounds = false`, through inline,
deferred incremental and deferred full checkpoints.
`AMTCheckpointTestBase` gets an `amtTableFeature` hook, which defaults
to `adaptiveMetadata-preview`.

## Does this PR introduce _any_ user-facing changes?

No.

This pull request and its description were written by Isaac.
…delta-io#8331)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

`SuiteGeneratorConfig.TEST_GROUPS` was a single `lazy val` that built
every `TestGroup` inline, so its initializer grew with each new group
and was approaching the JVM 64 KB method size limit (bytecode
instrumentation such as code coverage makes it larger still).

This change moves each group into its own `private def` and has
`TEST_GROUPS` list them in the original order, so each group compiles to
its own small method. There is no behavior change: `TEST_GROUPS`
contains the same groups in the same order, and the generated suites are
unchanged.

## How was this patch tested?

Existing tests. The suite generator produces identical output, and the
generated-suites validation still passes.

## Does this PR introduce _any_ user-facing changes?

No.

This pull request and its description were written by Isaac.
<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Remove the unused `getVersion`, `getProtocol`, and `getCommitInfo`
methods from
`StreamingHelper` now that action collection lives in the streaming
backends.
Remove the unused import from `DeltaV2MicroBatchStream` and update the
helper's
documentation. Keep the utilities used by changelog readers.

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?

Verified that the removed methods have no remaining callers and that
`git diff --check` passes. Both `build/sbt sparkV2/javafmt` and
`build/sbt sparkV2/Test/javafmt` passed with no formatting changes.
Tests were not run locally; this change removes unused code and will be
validated by CI.

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?

No.

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

Signed-off-by: You Zhou <yz3883@columbia.edu>
…nd DeltaV2MicroBatchStream (delta-io#8341)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

This PR continues to share the offset logic of the DSv1 streaming source
`DeltaSource` with the DSv2 streaming source `DeltaV2MicroBatchStream`.

This PR moves the per-commit loop of `getFileChanges`
(`filterAndIndexDeltaLogs`) from `DeltaSource` into the shared trait
`DeltaSourceOffsetLogic`, and `DeltaV2MicroBatchStream` calls it instead
of its own copy (`filterDeltaLogs` and `processCommitToIndexedFiles`). A
new `DeltaStreamingBackend.closeCommitsWithFiles` lets each backend
decide whether closing the files also closes the commits: the DSv1
backend returns the files unchanged, and the DSv2 backend closes its
Kernel commits.

## How was this patch tested?

New tests:
`DeltaV2StreamingBackendTest.closeCommitsWithFilesClosesFilesAndCommits`
and `DeltaLogStreamingBackendSuite` "closeCommitsWithFiles returns the
files unchanged".

## Does this PR introduce _any_ user-facing changes?

Each change makes the DSv2 streaming source behave like the DSv1 source.
The files, their order and the offsets do not change.
- An `IOException` while reading a commit's actions now reaches the
caller of `getFileChanges`, `latestOffset` and `planInputPartitions` as
the original exception. Before, the commit scan wrapped it in
`RuntimeException("Failed to process commit at version N")`, and
`planInputPartitions` wrapped any `IOException` of the scan in
`UncheckedIOException`.
- For an initial snapshot, the schema checks of each commit get the
scan's start version as the batch start, as in the DSv1 source. Before,
they got the next version. This changes only a log line.

This pull request and its description were written by Isaac.
…r class" (delta-io#8343)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Reverts delta-io#8255.

The subclass names it added to `DELTA_V2_INTERNAL_ERROR`
(`ILLEGAL_ARGUMENT`, `ILLEGAL_STATE`, `UNSUPPORTED_OPERATION`) repeat
the Java exception type instead of saying what went wrong. Error class
names are hard to change once they ship, so this takes them out until we
have better names.

## How was this patch tested?

Clean revert. The tree is identical to master before delta-io#8255 (5adad73).

## Does this PR introduce _any_ user-facing changes?

No. delta-io#8255 is not in a release. The internal checks in `DeltaV2Snapshot`
and `DeltaV2ScanBuilder` go back to throwing the plain JVM exceptions
they threw before delta-io#8255.

Signed-off-by: Xin Huang <xin.huang@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
…elta-io#8300)

## Description

A Delta Sharing snapshot query builds a local delta log from the
`getFiles` response. It writes two blocks to the BlockManager (the
`_delta_log` listing and the version 0 json file) and registers the
files' pre-signed urls in `CachedTableManager`.

This change adds
`DeltaSharingLogFileSystem.isSnapshotDeltaLogReusable(customTablePath)`,
which tells whether that log can still be read without rebuilding it:
its urls are still in `CachedTableManager`, and both of its blocks are
still in the BlockManager. Neither implies the other:
`CachedTableManager` evicts idle or expiring entries while the blocks
stay, and blocks can be dropped while the urls are cached. Any error
during the check returns false.

`constructLocalDeltaLogAtVersionZero` now gets its block paths from the
same helper as the check, so the two agree.

Nothing calls the check yet; a follow-up uses it to let an identical
snapshot query reuse an earlier query's delta log instead of calling
`getFiles` again.

## How was this patch tested?

`DeltaSharingDeltaLogBuilderSuite`: the check is true right after a log
is built. It is false once the urls are evicted while the blocks remain,
and false when only the `0.json` block, or only the `_delta_log` listing
block, is dropped while the urls are cached.

## Does this PR introduce _any_ user-facing change?

No.
…Provider (delta-io#8348)

## Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Follow-up to delta-io#8325, which removed the per-row AMT checkpoint provider.
`ColumnarAMTCheckpointProvider` was the only provider left, so its body
moves into `AMTCheckpointProvider`, which becomes `final` and takes the
root info. `ColumnarAMTCheckpointProvider` is removed.

## How was this patch tested?

Existing AMT suites. No behavior change.

## Does this PR introduce _any_ user-facing changes?

No.
…nd DeltaV2MicroBatchStream (delta-io#8349)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

This PR continues to share the offset logic of the DSv1 streaming source
`DeltaSource` with the DSv2 streaming source `DeltaV2MicroBatchStream`.

This PR moves the start and end filters of `getFileChanges` from
`DeltaSource` into two helpers of the shared trait
`DeltaSourceOffsetLogic`, `filterFilesAfterStartOffset` and
`takeFilesUntilEndOffset`, and `DeltaV2MicroBatchStream` calls them
instead of its own copy.

## How was this patch tested?

Existing tests. No test file changes.

## Does this PR introduce _any_ user-facing changes?

No. The DSv2 start filter now uses the DSv1 check (`version >
fromVersion || index > fromIndex`) instead of `version > fromVersion ||
(version == fromVersion && index > fromIndex)`. Both give the same
result, because `getFileChanges` returns no file below `fromVersion`.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
-->

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Adds `AMTTypeWideningSuite`. For each type change that Delta type
widening supports, it widens a data column and a partition column of an
AMT table with `ALTER COLUMN TYPE`. With inline incremental, deferred
incremental and deferred full trees, it checks the table schema, the
tree's metadata, the rows written before the change, and the types that
the manifests store.

## How was this patch tested?

This PR adds tests only.

## Does this PR introduce _any_ user-facing changes?

No.
…or (delta-io#8333)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Says catalog-managed in the shared test code and in the upgrade error:

1. `catalogOwnedCoordinatorBackfillBatchSize` becomes
`catalogManagedCoordinatorBackfillBatchSize`. Suites still override the
old name, so it stays, and the new member returns it by default. The
readers in `CatalogManagedTestBaseSuite` move to the new name.
2. `catalogOwnedDefaultCreationEnabledInTests` becomes
`catalogManagedDefaultCreationEnabledInTests`.
`CatalogOwnedPropertySuite`, the one suite that overrides it, now
overrides the new name. The old name stays as a `final def` that returns
the new one.
3. Seven `CatalogOwnedEnablementSuite` test names say CatalogManaged.
4. The error for upgrading an existing table to catalog-managed, a
`NotImplementedException` in `OptimisticTransaction`, says
CatalogManaged, and `CatalogOwnedEnablementSuite` and
`UCDeltaTableAlterTest` check the new text.
5. `CatalogOwnedPropertySuite` says catalog-managed in its private
helpers, its test names and its comments.
6. The unused old-name aliases `CatalogOwnedCommitCoordinatorBuilder`
and `CatalogOwnedUsageLogs` are deleted.
7. Five test-base methods say catalog-managed, and the suites that call
them move to the new names.
`deleteCatalogOwnedTableFromCommitCoordinator(tableName)` stays as a
`final def` that calls the new one, for `ClusteredTableTestUtils`.
8. The suites that read the batch size move to
`catalogManagedCoordinatorBackfillBatchSize`.

## How was this patch tested?

Rename only, no new tests.

## Does this PR introduce _any_ user-facing changes?

No.
…hStream (delta-io#8354)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

This PR continues to share the offset logic of the DSv1 streaming source
`DeltaSource` with the DSv2 streaming source `DeltaV2MicroBatchStream`.

This PR moves `getFileChanges` from `DeltaSource` into the shared trait
`DeltaSourceOffsetLogic`. The trait reads the initial snapshot through a
new required member `getSnapshotAt`, with the DSv1 signature, and
`DeltaV2MicroBatchStream` calls the shared method instead of its own
copy.

## How was this patch tested?

New test
`DeltaV2MicroBatchStreamTest.getSnapshotAtReturnsInCommitTimestampLikeDsv1`.
It checks that DSv1 and DSv2 `getSnapshotAt` return the same in-commit
timestamp, with and without a checksum file, and that the
initial-snapshot read of `getFileChanges` returns the same files.

## Does this PR introduce _any_ user-facing changes?

No. DSv2 now writes the DSv1 INFO log "Getting file changes for
delta_log_path=..." with the time taken. On tables with in-commit
timestamps, DSv2 `getSnapshotAt` now reads the in-commit timestamp of
the snapshot, as DSv1 does.

This pull request and its description were written by Isaac.

Co-authored-by: Isaac <no-reply@databricks.com>
…ta-io#8351)

<!--
Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md
2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]
Your PR title ...'.
  3. Be sure to keep the PR description updated to reflect all changes.
  4. Please write your PR title to summarize what this PR proposes.
5. If possible, provide a concise example to reproduce the issue for a
faster review.
6. If applicable, include the corresponding issue number in the PR title
and link it in the body.
-->

#### Which Delta project/connector is this regarding?
<!--
Please add the component selected below to the beginning of the pull
request title
For example: [Spark] Title of my pull request
-->

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Delta V2 reads can lose generated metadata when a table contains a user
column named
`_metadata`. Allow Spark to rename the generated struct to `__metadata`
(or another
non-conflicting name), and identify it by its metadata marker and
logical name throughout
schema construction and scan selection. User columns retain their values
and names.

Restore the generated struct's marker when Spark nested schema pruning
drops it, using
the table schema to distinguish generated metadata from stored user
columns. Add coverage
for file metadata, multiple name collisions, column mapping, and direct
batch reads.
Collision tests verify `file_path` with name and ID column mapping;
support for reading
row-tracking metadata with column mapping is tracked separately in
delta-io#8355.

<!--
- Describe what this PR changes.
- Describe why we need the change.
 
If this PR resolves an issue be sure to include "Resolves #XXX" to
correctly link and close the issue upon merge.
-->

## How was this patch tested?

- Added unit and integration regression coverage, including nested
pruning enabled and disabled,
case-sensitive resolution, and distinct values for user and generated
metadata.
- Java formatting was checked with Google Java Format 1.7; `git diff
--check` passes.
- The regression test simulates marker loss during nested schema
pruning.
- CI results for the updated collision assertions are pending.

<!--
If tests were added, say they were added here. Please make sure to test
the changes thoroughly including negative and positive cases if
possible.
If the changes were tested in any way other than unit tests, please
clarify how you tested step by step (ideally copy and paste-able, so
that other reviewers can test and check, and descendants can verify in
the future).
If the changes were not tested, please explain why.
-->

## Does this PR introduce _any_ user-facing changes?

Yes. Delta V2 reads preserve user `_metadata` columns while exposing
generated file metadata,
such as `file_path`, under a non-conflicting name.

<!--
If yes, please clarify the previous behavior and the change this PR
proposes - provide the console output, description and/or an example to
show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change
compared to the released Delta Lake versions or within the unreleased
branches such as master.
If no, write 'No'.
-->

---------

Signed-off-by: You Zhou <yz3883@columbia.edu>
…hing (delta-io#8329)

## Description

AMT discovery decides whether to cache the root's rows in memory by
comparing the root's entry count with `amt.rootCache.maxNumEntries`.
Until now it read the root Parquet file's footer to get that count. This
PR records the count when the root is written and reads it from the
checkpoint instead.

- `ContentRoot` gets a `numRootEntries` tag and an accessor for it.
- The full writer (both the promoted single-leaf root and the multi-leaf
root) and the incremental writer record the number of entries in the
root they write.
- `loadRootFromCheckpoint` caches root rows only when `numRootEntries`
is present and below the threshold. A root written before this change
has no tag, so its rows are not cached and the root is read from storage
as before.

## How was this patch tested?

Updated `AMTSnapshotDiscoverySuite`:
- A new test covers root prefetch with each combination of the
`numLeaves` and `numRootEntries` tags present or absent, above and below
the cache threshold.
- The cache threshold test reads the entry count from the recorded tag
and checks it against the actual number of rows in the root.

## Does this PR introduce _any_ user-facing changes?

No.

Co-authored-by: Jinhua Song <jinhua.song@databricks.com>
…ame for AMT tables (delta-io#8357)

#### Which Delta project/connector is this regarding?
- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Adds `DeltaLog.loadChangesDf`, the distributed counterpart of
`getChanges`. It returns the actions over a version range as a DataFrame
of the log schema plus a commit version column.

When `AMT_SINGLE_COMMIT_READ_ENABLED` is on, the AddFile and RemoveFile
actions of an inline AMT manifest commit come from its tree instead of
its log file. Callers that already know the versions of the inline
manifest commits can pass them as a hint so that only those log files
are read to locate the trees.

The manifest reader now takes the change manifests of a tree
(`changeManifests`) and reads them in one pass, and the change-file
helpers are renamed to change-entry names accordingly.

## How was this patch tested?

New tests in `AMTSingleCommitSuite`.

## Does this PR introduce _any_ user-facing changes?

No.
#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Deletes `CatalogOwnedCommitCoordinatorProvider` and
`CatalogOwnedTableUtils`. They are aliases that kept the old
catalog-owned names compiling while the code moved to
`CatalogManagedCommitCoordinatorProvider` and
`CatalogManagedTableUtils`, and nothing uses them now. They were all of
`coordinatedcommits/package.scala`, so the PR deletes the file.

## How was this patch tested?

No new tests. The build fails if any code still uses the aliases.

## Does this PR introduce _any_ user-facing changes?

No.
…a-io#8359)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

Says catalog-managed in the shared test bases and suites:

1. `isCatalogOwnedTest` becomes `isCatalogManagedTest`. The suites that
override it now override the new name, and the old name stays as a
`final def` that returns the new one.
2. `withClassicCheckpointPolicyForCatalogOwned` becomes
`withClassicCheckpointPolicyForCatalogManaged`, and its callers move.
3. The suites that read `catalogOwnedDefaultCreationEnabledInTests` read
`catalogManagedDefaultCreationEnabledInTests`.
4. Local names say catalog-managed: two local vals, three table names in
`OptimisticTransactionSuite`, and three test names.

## How was this patch tested?

Rename only, no new tests.

## Does this PR introduce _any_ user-facing changes?

No.
#### Which Delta project/connector is this regarding?

- [x] Spark

## Description

Reused one frozen checkpoint per layout and mode across AMT discovery
cache-threshold checks, avoiding repeated checkpoint preparation. Every
threshold, session and API still compares complete state-action rows,
with RDD deserialization checked at cached and uncached boundaries.

Historical pre-export Runtime measurements, not public-suite timings.

| Complete Runtime `AMTSnapshotDiscoverySuite` | Before | After |
Improvement |
| --- | ---: | ---: | ---: |
| Command wall, median (range) | 334.397 s (330.773–338.022) | 311.031 s
(309.294–312.767) | 7.0% shorter |

## How was this patch tested?

Public suite execution and timing have not run. Source inspection
confirms the complete state-action comparisons remain across thresholds,
sessions and APIs.

## Does this PR introduce _any_ user-facing changes?

No.

<details>
<summary>Measurement scope</summary>

Two local Runtime runs per revision, including five shards and
setup/teardown. Measured parent
`abe5907cde90984ab2a55cfa6c9d7dbc06e30a49` against candidate
`4d4c2fa17370b3fdf47ebd7298c0a98c1c9be50d`. These historical samples
establish no public-suite, family-wide, CPU or CI critical-path savings.

Agent: Costly Tests - Sql4 | Session:
01a1f461-64c7-7622-933f-dc510b70ad3d
</details>

Signed-off-by: Cyrus Najmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
Co-authored-by: Cyrus Najmabadi <4564579+CyrusNajmabadi@users.noreply.github.com>
…o .json remains in it (delta-io#8361)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

`findLastCompleteCheckpointBefore` searches backward in windows of 1000
versions. Each window's listing stopped only at a delta or checkpoint
file past the window's end. In a version range that holds only `.crc` or
compacted delta files (for example when a cleanup deleted their `.json`
and kept the `.crc`), the listing ran to the end of that range in every
window, so the search read the range once per window.

The listing now also stops at `.crc` and compacted delta files past the
window's end, so each window reads only its own files. The change is
behind
`spark.databricks.delta.findLastCompleteCheckpoint.stopAtNonDeltaFiles.enabled`
(default true).

## How was this patch tested?

New cases in `FindLastCompleteCheckpointSuite`: with 3000 versions that
have only a `.crc` (or only a compacted delta file) below the checkpoint
search, the search scans 3209 files instead of 8606, and finds the same
checkpoint with the flag on and off.

## Does this PR introduce _any_ user-facing changes?

No
…cal name is another column's physical name (delta-io#8317)

#### Which Delta project/connector is this regarding?

- [x] Spark
- [ ] Standalone
- [ ] Flink
- [ ] Kernel
- [ ] Other (fill in here)

## Description

On a column mapping table, the stats of the columns named in
`delta.dataSkippingStatsColumns` were looked up in the written data by
their logical name if the data had a column with that name, and by their
physical name otherwise. The written data uses physical names. Upgrading
a table to column mapping keeps its existing column names as physical
names, so `RENAME COLUMN amount TO amount_old` followed by `ADD COLUMNS
(amount INT)` gave the new `amount` the stats of `amount_old`, and data
skipping could then prune files that contain matching rows.

Each `StatisticsCollection` now declares whether its data uses physical
names (`outputUsesPhysicalNames`): the writer's data does, a snapshot's
does not. The named stats columns take their physical names for
physically named data and keep their logical names otherwise, without
looking at the data's column names.

## How was this patch tested?

New tests in `StatsCollectionSuite`:
- Re-adding a renamed column's old name with the same type, with another
type (TIMESTAMP where it was STRING), with a nested stats column (`s.x`
after renaming the struct `s`), with a nested field re-added inside its
struct, with the whole struct as the stats column, and with names
containing `.,!@#$%^`; and two columns that swap names. Each checks the
stored MIN/MAX and filtered queries.
- On such a table: the stats that UPDATE, MERGE and OPTIMIZE write, MIN
and MAX answered from the stats, and recomputed stats matching the
written ones.

The `convertToPhysicalName` test is updated to its new signature.

## Does this PR introduce _any_ user-facing changes?

No.

---------

Co-authored-by: Isaac <no-reply@databricks.com>
VACUUM discovers files by shallow-listing the table root, distributing
that first level across the cluster, and then recursing each first-level
directory in a single task. The `_change_data` directory (Change Data
Feed files) is one of those first-level directories and mirrors the
table's partitioning, so it can hold a large fraction of the table's
files. Recursing it inline leaves a single task listing that entire
subtree while the rest of the cluster is idle -- often the tail of VACUUM
on tables with CDF enabled.

This lists `_change_data` as a separate listing branch: it is excluded
from the main table listing and listed via its own `recursiveListDirs`
call. Its sub-directories then get their own repartition + parallel
recursion, and because the two branches are unioned Spark schedules them
concurrently. The `_change_data` directory entry itself is emitted so
empty-directory cleanup behaves exactly as before.

The set of files considered by VACUUM is identical; only the listing
parallelism differs. Gated by
spark.databricks.delta.vacuum.listing.changeDataDirSeparately.enabled
(default true); when the table has no `_change_data` directory the
original single-call listing path is used unchanged.

Tests: a listing test asserts the separate-branch decomposition returns
exactly the same files and directories as the inline listing, and an
end-to-end VACUUM test asserts the same untracked files (including one
nested deep under `_change_data`) are removed whether the config is on or
off.

Relates to delta-io#2201 (improving VACUUM listing parallelism).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…UM listing

Review follow-up:
- hiddenDirNameFilter applies at every listing depth, so matching
  `_change_data` there also hid directories such as
  `part=1/_change_data/`, and their untracked files were no longer
  vacuumed. Add firstLevelHiddenDirNameFilter to recursiveListDirs
  (default: hide nothing). It is applied only in the first, non-recursive
  listing. VACUUM passes `_ == CDC_LOCATION` there and leaves
  hiddenDirNameFilter unchanged.
- Replace exists + getFileStatus with one getFileStatus that catches
  FileNotFoundException. The separate branch is used only when
  `_change_data` is a directory, and the same status is reused for the
  directory entry.
- Drop the listing test that rebuilt the union by hand. The end-to-end
  VACUUM test (conf on and off) now also creates
  `part=1/_change_data/orphan.txt`. With the conf on, it fails without
  this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Eunjin Song <sezruby@gmail.com>
@sezruby
sezruby force-pushed the vacuum-list-change-data-separately branch from b029242 to 877daa4 Compare November 28, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.