Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bcb787b
[Spark][DEDUP] Remove unused SchemaUtils.convertKernelSchemaToSparkSc…
tdas Nov 16, 2026
34858de
[Spark] Make all nested output fields nullable on Delta writes (#8171)
ala Nov 16, 2026
ed65441
[Spark] Reconstruct AMT commit change files per state reconstruction …
dhruvarya-db Nov 16, 2026
426d277
[Spark] Convert SnapshotManagerFactory to Scala (#8055)
HaoSun1993 Nov 16, 2026
94cdbbc
[Spark][DEDUP] Single helper for V2 CDC output schema (#8116)
tdas Nov 16, 2026
6a413d1
[Spark] Preserve processing failures during iterator cleanup (#8175)
PorridgeSwim Nov 17, 2026
65938df
[Spark][DEDUP] Use shared Delta V2 enable mode constants (#8110)
tdas Nov 17, 2026
f6944f6
[Sharing] Prune unsupported sub-expressions from Delta Sharing json p…
chakankardb Nov 17, 2026
e7261c2
[Spark] Reconstruct AMT file actions in SingleCommit.getActionsIterat…
geraintcjy Nov 17, 2026
54e2ff0
[Infra] Cancel in-progress Delta Spark CI runs on new commits (#8184)
tdas Nov 17, 2026
f7443c1
[Spark][DEDUP] Merge getPartitionRow map overload implementations (#8…
tdas Nov 17, 2026
6477066
[Spark] Re-enable the V2 streaming failOnDataLoss gap test (#8181)
PorridgeSwim Nov 17, 2026
8e80854
[Spark] Say catalog-managed in comments (#8151)
xzhseh Nov 17, 2026
090e698
[Spark] Rename the CatalogOwnedTableFeature and CatalogOwnedTableUtil…
xzhseh Nov 17, 2026
df10b54
[Spark] Attribute Delta V2 snapshot and cache operations (#8067)
openinx Nov 17, 2026
01c3d5a
[Spark] Use one helper to get the DeltaV2Scan in the V2 scan Java tes…
hariuserx Nov 17, 2026
638f6db
[Spark] Share checkNonAdditiveSchemaChanges between DeltaSource and D…
zikangh Nov 17, 2026
7603824
[Spark] Fix snapshot listing test catalog selection (#8188)
EricTsengTy Nov 17, 2026
83c3340
[SPARK] Support verionless CDF in delta sharing delta format response…
Omar-Saleh Nov 17, 2026
99823f8
[Spark] Rename CatalogOwnedUsageLogs to CatalogManagedUsageLogs (#8157)
xzhseh Nov 17, 2026
a75a415
[Spark][DEDUP] Share row-tracking metadata lookup in V2 value setter …
tdas Nov 17, 2026
79ca851
[Spark] Fix DROP FEATURE deletionVectors succeeding while files still…
sumeet-db Nov 17, 2026
ba79b1b
[Spark] Reject DROP COLUMNS of a struct that holds a clustering colum…
sumeet-db Nov 17, 2026
2929265
[Spark] Make writer V2 test assertions and setup reusable (#8183)
tmaire111 Nov 17, 2026
44ddab5
[Spark][DEDUP] Drop the redundant DeltaV2ScanBuilder.create factory (…
tdas Nov 17, 2026
3b1bb78
[Spark][DEDUP] Clarify partition-only guarantee for pushed limits (#8…
tdas Nov 17, 2026
cdb1915
[Spark] Cover catalog-managed coordinator failures in transaction tes…
EricTsengTy Nov 17, 2026
15b622a
[Spark] Rename CatalogOwnedCommitCoordinator* to CatalogManagedCommit…
xzhseh Nov 17, 2026
41f7964
[Spark] Require isPreviewCompatible in AMTUtils.amtSupported and amtE…
ctring Nov 18, 2026
be6041c
[Sharing] Remove spark.sql.delta.sharing.enableAutoResolveForCdf (#8206)
linzhou-db Nov 18, 2026
e364662
[Sharing] Remove spark.sql.delta.sharing.cdfStreamingAutoResolveRespo…
linzhou-db Nov 18, 2026
fd8c620
[Spark] Allow AMT leaves that mix live files and tombstones (#8208)
ctring Nov 18, 2026
456d716
[Spark] Reuse the written AMT root rows for the next commit (#8172)
PhilPlato Nov 18, 2026
965a3c0
[Spark] Use CatalogManagedTableFeature (#8154)
xzhseh Nov 18, 2026
febd8a4
[Flink] Preserve transaction identity when restoring checkpoints (#8203)
timothyw553 Nov 18, 2026
832db36
[Spark][DEDUP] Follow-up: cover metadata schema conversion (#8215)
tdas Nov 18, 2026
b8c6bbf
[Kernel] Make checkpoint search batch size configurable (#8201)
thinh2 Nov 18, 2026
d33d2f8
[Spark] Preserve resolved partition names during V2 column pruning (#…
PorridgeSwim Nov 18, 2026
6e2494f
[Spark] Validate protocols while reading V2 streaming commits (#8219)
HaoSun1993 Nov 18, 2026
a3781e5
[Spark] Build the AMT content stats JSON from a typed stats struct (#…
dhruvarya-db Nov 18, 2026
a74e849
[Spark] Test that a re-added column does not take a dropped column's …
geraintcjy Nov 18, 2026
fa86aa5
[Spark] Consolidate AMT back-reference tests (#8195)
CyrusNajmabadi Nov 18, 2026
fbc776d
[Spark] Share AMT snapshot test fixtures (#8196)
CyrusNajmabadi Nov 18, 2026
685eec2
[Spark] Support ALTER TABLE ... REPLACE PARTITIONED BY WITH CLUSTER BY
sezruby Nov 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/spark_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ on:
description: Optional suffix to force a distinct Spark Maven cache key
required: false
type: string

# Cancel superseded runs on the same PR when new commits are pushed. Non-PR runs (pushes to
# master / branch-*, manual dispatches) fall back to the unique run_id, so they are never
# cancelled and every commit to master gets its own full CI result.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true

# Source-build jobs are commented out while all supported Spark versions use releases.
# With no snapshot versions, enabled source-build jobs appear as skipped.
# The merge bot can report these checks as failures and confuse contributors.
Expand Down
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,10 @@ lazy val sparkV2 = {
CrossSparkVersions.sparkDependentSettings(sparkVersion),
exportJars := true, // Export as JAR to avoid classpath conflicts

Test / javaOptions ++= Seq("-ea"),
Test / javaOptions ++= Seq("-ea", "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED"),
libraryDependencies ++= junit5TestDependencies ++ Seq(
"org.mockito" % "mockito-inline" % "4.11.0" % "test",
"org.mockito" %% "mockito-scala" % "1.17.14" % "test",
"org.apache.spark" %% "spark-sql" % sparkArtifactVersion.value % "provided",
"org.apache.spark" %% "spark-core" % sparkArtifactVersion.value % "provided",
"org.apache.spark" %% "spark-catalyst" % sparkArtifactVersion.value % "provided",
Expand Down
30 changes: 17 additions & 13 deletions flink/src/main/java/io/delta/flink/sink/DeltaCommitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,8 @@ public class DeltaCommitter implements Committer<DeltaCommittable> {

private static final Logger LOG = LoggerFactory.getLogger(DeltaCommitter.class);

// All committables should have the same job id as the committer.
// For simplicity, we get the job id from constructor.
private final String jobId;
// The task prefix attached to checkpoint id when multiple sink instances presents
private final int taskIndex;
// Uniquely identify the committer in DeltaLog transaction identifier
private final String committerId;

private final DeltaTable deltaTable;
private final DeltaSinkConf conf;
Expand All @@ -76,14 +71,11 @@ public class DeltaCommitter implements Committer<DeltaCommittable> {
private volatile long lastCommitDurationMs;

private DeltaCommitter(
String jobId,
int taskIndex,
DeltaTable deltaTable,
DeltaSinkConf conf,
SinkCommitterMetricGroup metricGroup) {
this.jobId = jobId;
this.taskIndex = taskIndex;
this.committerId = String.format("%s-%d", jobId, taskIndex);

this.deltaTable = deltaTable;
this.conf = conf;
Expand All @@ -96,7 +88,17 @@ private DeltaCommitter(
public void commit(Collection<CommitRequest<DeltaCommittable>> committables)
throws IOException, InterruptedException {
LOG.debug("Starting commit");
sortCommittablesByCheckpointId(committables).forEach(this::commitForSingleCheckpointId);
committables.stream()
.collect(
Collectors.groupingBy(
request -> request.getCommittable().getJobId(),
LinkedHashMap::new,
Collectors.toList()))
.values()
.forEach(
requests ->
sortCommittablesByCheckpointId(requests)
.forEach(this::commitForSingleCheckpointId));
}

@Override
Expand All @@ -111,6 +113,9 @@ private void commitForSingleCheckpointId(
if (committables.isEmpty()) {
return;
}
// Restored work must keep the transaction identity of the job that created it.
String committerId =
String.format("%s-%d", committables.get(0).getCommittable().getJobId(), taskIndex);
LOG.debug("Committing {} committables on checkpoint {}", committables.size(), checkpointId);
metricGroup.getNumCommittablesTotalCounter().inc(committables.size());

Expand Down Expand Up @@ -203,16 +208,16 @@ private TreeMap<Long, List<CommitRequest<DeltaCommittable>>> sortCommittablesByC
}

public static final class Builder {
private String jobId;
private int taskIndex;
private DeltaTable deltaTable;
private DeltaSinkConf conf;
private SinkCommitterMetricGroup metricGroup;

public Builder() {}

/** @deprecated The job ID is read from each committable. This method has no effect. */
@Deprecated
public Builder withJobId(String jobId) {
this.jobId = jobId;
return this;
}

Expand All @@ -237,12 +242,11 @@ public Builder withMetricGroup(SinkCommitterMetricGroup metricGroup) {
}

public DeltaCommitter build() {
Objects.requireNonNull(jobId, "jobId must not be null");
Objects.requireNonNull(deltaTable, "deltaTable must not be null");
Objects.requireNonNull(metricGroup, "metricGroup must not be null");
Objects.requireNonNull(conf, "conf must not be null");

return new DeltaCommitter(jobId, taskIndex, deltaTable, conf, metricGroup);
return new DeltaCommitter(taskIndex, deltaTable, conf, metricGroup);
}
}
}
1 change: 0 additions & 1 deletion flink/src/main/java/io/delta/flink/sink/DeltaSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public SinkWriter<RowData> createWriter(WriterInitContext context) {
public Committer<DeltaCommittable> createCommitter(CommitterInitContext context) {
this.deltaTable.open();
return new DeltaCommitter.Builder()
.withJobId(context.getJobInfo().getJobId().toString())
.withTaskIndex(context.getTaskInfo().getIndexOfThisSubtask())
.withDeltaTable(deltaTable)
.withConf(conf)
Expand Down
119 changes: 119 additions & 0 deletions flink/src/test/java/io/delta/flink/sink/DeltaCommitterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@
import io.delta.flink.TestHelper;
import io.delta.flink.table.HadoopTable;
import io.delta.flink.table.LocalFileSystemTable;
import io.delta.kernel.TableManager;
import io.delta.kernel.data.Row;
import io.delta.kernel.defaults.engine.DefaultEngine;
import io.delta.kernel.internal.SnapshotImpl;
import io.delta.kernel.internal.actions.AddFile;
import io.delta.kernel.internal.actions.SingleAction;
import io.delta.kernel.internal.util.Utils;
import io.delta.kernel.types.*;
import io.delta.kernel.utils.CloseableIterable;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;
import org.apache.flink.api.connector.sink2.Committer;
import org.apache.flink.api.connector.sink2.mocks.MockCommitRequest;
import org.apache.flink.runtime.metrics.groups.InternalSinkCommitterMetricGroup;
import org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups;
import org.apache.hadoop.conf.Configuration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

/** JUnit test suite for {@link DeltaCommitter}. */
class DeltaCommitterTest extends TestHelper {
Expand Down Expand Up @@ -102,6 +111,116 @@ void testCommitWithSingleCheckpointToAnEmptyTable() {
});
}

@ParameterizedTest
@CsvSource({"false, false", "true, false", "true, true"})
void testRestoreWithNewJobId(boolean alreadyCommitted, boolean removed) {
withTempDir(
dir -> {
StructType schema = new StructType().add("id", IntegerType.INTEGER);
HadoopTable table = new HadoopTable(dir.toURI(), Map.of(), schema, List.of());
table.open();
try {
DeltaSinkConf conf = new DeltaSinkConf(schema, Map.of());
DeltaCommitter original =
new DeltaCommitter.Builder()
.withDeltaTable(table)
.withTaskIndex(3)
.withJobId("original-job")
.withMetricGroup(metricGroup)
.withConf(conf)
.build();
DeltaCommittable pending =
new DeltaCommittable(
"original-job",
"test-operator",
1L,
List.of(dummyAddFileRow(schema, 1, Map.of())),
new WriterResultContext());
DeltaCommittable.Serializer serializer = new DeltaCommittable.Serializer();
byte[] checkpoint = serializer.serialize(pending);
if (alreadyCommitted) {
original.commit(List.of(new MockCommitRequest<>(pending)));
}
if (removed) {
List<Row> removes = new ArrayList<>();
verifyTableContent(
dir.toString(),
(version, files, props) ->
files.forEach(
file ->
removes.add(
SingleAction.createRemoveFileSingleAction(
file.toRemoveFileRow(true, Optional.empty())))));
table.commit(
CloseableIterable.inMemoryIterable(Utils.toCloseableIterator(removes.iterator())),
"maintenance",
1L,
Map.of());
}

DeltaCommitter restored =
new DeltaCommitter.Builder()
.withDeltaTable(table)
.withTaskIndex(3)
.withMetricGroup(metricGroup)
.withConf(conf)
.build();
DeltaCommittable recovered =
serializer.deserialize(serializer.getVersion(), checkpoint);
restored.commit(List.of(new MockCommitRequest<>(recovered)));
SnapshotImpl snapshot =
(SnapshotImpl) TableManager.loadSnapshot(dir.toString()).build(table.getEngine());
assertEquals(
Optional.of(1L),
snapshot.getLatestTransactionVersion(table.getEngine(), "original-job-3"));
assertEquals(
Optional.empty(),
snapshot.getLatestTransactionVersion(table.getEngine(), "restored-job-3"));
long expectedVersion = removed ? 2L : 1L;
int expectedFiles = removed ? 0 : 1;
verifyTableContent(
dir.toString(),
(version, files, props) -> {
assertEquals(expectedVersion, version);
assertEquals(
expectedFiles, StreamSupport.stream(files.spliterator(), false).count());
});

// Defensive coverage: submit different job IDs with the same checkpoint number.
// Flink 2.3 normally commits each checkpoint manager separately.
DeltaCommittable fresh =
new DeltaCommittable(
"restored-job",
"test-operator",
1L,
List.of(dummyAddFileRow(schema, 1, Map.of())),
new WriterResultContext());
for (int attempt = 0; attempt < 2; attempt++) {
restored.commit(
List.of(new MockCommitRequest<>(recovered), new MockCommitRequest<>(fresh)));
snapshot =
(SnapshotImpl) TableManager.loadSnapshot(dir.toString()).build(table.getEngine());
assertEquals(
Optional.of(1L),
snapshot.getLatestTransactionVersion(table.getEngine(), "original-job-3"));
assertEquals(
Optional.of(1L),
snapshot.getLatestTransactionVersion(table.getEngine(), "restored-job-3"));
verifyTableContent(
dir.toString(),
(version, files, props) -> {
assertEquals(expectedVersion + 1, version);
assertEquals(
expectedFiles + 1,
StreamSupport.stream(files.spliterator(), false).count());
});
}
} finally {
table.close();
}
});
}

@Test
void testCommitWithMultipleCheckpoints() {
withTempDir(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ public interface SnapshotBuilder {
*/
SnapshotBuilder atVersion(long version);

/**
* Sets the number of versions searched per batch when finding a checkpoint for a snapshot.
*
* <p>Smaller batches can reduce listing work for tables with frequent or multipart checkpoints.
* Larger batches can avoid extra listing calls when checkpoints are sparse. If a batch has no
* complete checkpoint, Kernel continues searching older batches. The default batch size is 1000
* versions.
*
* @param batchSize the number of versions per search batch; must be positive
* @return this builder configured with the search batch size
*/
SnapshotBuilder withCheckpointSearchBatchSize(int batchSize);

/**
* Configures the builder to resolve the table at a specific timestamp.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static io.delta.kernel.internal.TableConfig.LOG_RETENTION;
import static io.delta.kernel.internal.snapshot.MetadataCleanup.cleanupExpiredLogs;
import static io.delta.kernel.internal.tablefeatures.TableFeatures.CHECKPOINT_PROTECTION_W_FEATURE;
import static io.delta.kernel.internal.util.Preconditions.checkArgument;
import static io.delta.kernel.internal.util.Utils.singletonCloseableIterator;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -56,6 +57,9 @@ public class Checkpointer {

private static final int READ_LAST_CHECKPOINT_FILE_MAX_RETRIES = 3;

/** Default number of versions searched per batch when finding a checkpoint. */
public static final int DEFAULT_CHECKPOINT_SEARCH_BATCH_SIZE = 1000;

/** The name of the last checkpoint file */
public static final String LAST_CHECKPOINT_FILE_NAME = "_last_checkpoint";

Expand Down Expand Up @@ -173,39 +177,36 @@ public static Optional<CheckpointInstance> getLatestCompleteCheckpointFromList(

/** Find the last complete checkpoint before (strictly less than) a given version. */
public static Optional<CheckpointInstance> findLastCompleteCheckpointBefore(
Engine engine, Path tableLogPath, long version) {
return findLastCompleteCheckpointBeforeHelper(engine, tableLogPath, version)._1;
Engine engine, Path tableLogPath, long version, int batchSize) {
return findLastCompleteCheckpointBeforeHelper(engine, tableLogPath, version, batchSize)._1;
}

/**
* Helper method for `findLastCompleteCheckpointBefore` which also return the number of files
* searched. This helps in testing
*/
public static Tuple2<Optional<CheckpointInstance>, Long> findLastCompleteCheckpointBeforeHelper(
Engine engine, Path tableLogPath, long version) {
Engine engine, Path tableLogPath, long version, int batchSize) {
checkArgument(batchSize > 0, "checkpoint search batch size must be > 0");
CheckpointInstance upperBoundCheckpoint = new CheckpointInstance(version);
logger.info("Try to find the last complete checkpoint before version {}", version);

// This is a just a tracker for testing purposes
long numberOfFilesSearched = 0;
long currentVersion = version;

// Some cloud storage APIs make a calls to fetch 1000 at a time.
// To make use of that observation and to avoid making more listing calls than
// necessary, list 1000 at a time (backwards from the given version). Search
// within that list if a checkpoint is found. If found stop, otherwise list the previous
// 1000 entries. Repeat until a checkpoint is found or there are no more delta commits.
// Multipart checkpoints can add many files per version. Start each pass at most batchSize
// versions before currentVersion, and search earlier if no complete checkpoint is found.
while (currentVersion >= 0) {
try {
long searchLowerBound = Math.max(0, currentVersion - 1000);
CloseableIterator<FileStatus> deltaLogFileIter =
wrapEngineExceptionThrowsIO(
() ->
engine
.getFileSystemClient()
.listFrom(FileNames.listingPrefix(tableLogPath, searchLowerBound)),
"Listing from %s",
FileNames.listingPrefix(tableLogPath, searchLowerBound));
long searchLowerBound = Math.max(0, currentVersion - batchSize);
try (CloseableIterator<FileStatus> deltaLogFileIter =
wrapEngineExceptionThrowsIO(
() ->
engine
.getFileSystemClient()
.listFrom(FileNames.listingPrefix(tableLogPath, searchLowerBound)),
"Listing from %s",
FileNames.listingPrefix(tableLogPath, searchLowerBound))) {

List<CheckpointInstance> checkpoints = new ArrayList<>();
while (deltaLogFileIter.hasNext()) {
Expand Down Expand Up @@ -250,7 +251,10 @@ public static Tuple2<Optional<CheckpointInstance>, Long> findLastCompleteCheckpo
latestCheckpoint.get());
return new Tuple2<>(latestCheckpoint, numberOfFilesSearched);
}
currentVersion -= 1000; // search for checkpoint in previous 1000 entries
if (searchLowerBound == 0) {
break;
}
currentVersion -= batchSize;
} catch (IOException e) {
String msg =
String.format(
Expand Down
Loading