Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.iceberg.SchemaParser;
import org.apache.iceberg.SerializableTable;
import org.apache.iceberg.Snapshot;
import org.apache.iceberg.SnapshotSummary;
import org.apache.iceberg.Table;
import org.apache.iceberg.io.CloseableIterable;
import org.apache.iceberg.io.FileIO;
Expand All @@ -50,6 +51,7 @@
import org.apache.iceberg.spark.SparkReadOptions;
import org.apache.iceberg.spark.source.SparkScan.ReadTask;
import org.apache.iceberg.spark.source.SparkScan.ReaderFactory;
import org.apache.iceberg.util.PropertyUtil;
import org.apache.iceberg.util.SnapshotUtil;
import org.apache.iceberg.util.TableScanUtil;
import org.apache.iceberg.util.Tasks;
Expand Down Expand Up @@ -111,8 +113,12 @@ public Offset latestOffset() {
}

Snapshot latestSnapshot = table.currentSnapshot();
return new StreamingOffset(
latestSnapshot.snapshotId(), Iterables.size(latestSnapshot.addedFiles(table.io())), false);
long addedFilesCount = PropertyUtil.propertyAsLong(latestSnapshot.summary(), SnapshotSummary.ADDED_FILES_PROP, -1);
// If snapshotSummary doesn't have SnapshotSummary.ADDED_FILES_PROP, iterate through addedFiles iterator to find
// addedFilesCount.
addedFilesCount = addedFilesCount == -1 ? Iterables.size(latestSnapshot.addedFiles()) : addedFilesCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I see, good point we cannot just put Iterables.size(latestSnapshot.addedFiles()) as the input to the last method otherwise it will be evaluated.


return new StreamingOffset(latestSnapshot.snapshotId(), addedFilesCount, false);
}

@Override
Expand Down