Skip to content
Open
Show file tree
Hide file tree
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 @@ -52,6 +52,7 @@
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.spark.JobGroupInfo;
import org.apache.iceberg.util.FileSystemWalker;
import org.apache.iceberg.util.LocationUtil;
import org.apache.iceberg.util.Pair;
import org.apache.iceberg.util.PropertyUtil;
import org.apache.iceberg.util.Tasks;
Expand Down Expand Up @@ -225,7 +226,12 @@ public DeleteOrphanFilesSparkAction usePrefixListing(boolean newUsePrefixListing
private Dataset<String> filteredCompareToFileList() {
Dataset<Row> files = compareToFileList;
if (location != null) {
files = files.filter(files.col(FILE_PATH).startsWith(location));
String strippedLocation = LocationUtil.stripTrailingSlash(location);
String locationWithTrailingSlash =
strippedLocation.endsWith(LocationUtil.PATH_SEPARATOR)
? strippedLocation
: strippedLocation + LocationUtil.PATH_SEPARATOR;
files = files.filter(files.col(FILE_PATH).startsWith(locationWithTrailingSlash));
}
return files
.filter(files.col(LAST_MODIFIED).lt(new Timestamp(olderThanTimestamp)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,10 @@ public void testCompareToFileList() throws IOException {
assertThat(actualRecords).as("Rows must match").isEqualTo(expectedRecords);

List<FilePathLastModifiedRecord> outsideLocationMockFiles =
Lists.newArrayList(new FilePathLastModifiedRecord("/tmp/mock1", new Timestamp(0L)));
Lists.newArrayList(
new FilePathLastModifiedRecord("/tmp/mock1", new Timestamp(0L)),
new FilePathLastModifiedRecord(
tableLocation + "-backup/mock1.parquet", new Timestamp(0L)));

Dataset<Row> compareToFileListWithOutsideLocation =
spark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.spark.JobGroupInfo;
import org.apache.iceberg.util.FileSystemWalker;
import org.apache.iceberg.util.LocationUtil;
import org.apache.iceberg.util.Pair;
import org.apache.iceberg.util.PropertyUtil;
import org.apache.iceberg.util.Tasks;
Expand Down Expand Up @@ -225,7 +226,12 @@ public DeleteOrphanFilesSparkAction usePrefixListing(boolean newUsePrefixListing
private Dataset<String> filteredCompareToFileList() {
Dataset<Row> files = compareToFileList;
if (location != null) {
files = files.filter(files.col(FILE_PATH).startsWith(location));
String strippedLocation = LocationUtil.stripTrailingSlash(location);
String locationWithTrailingSlash =
strippedLocation.endsWith(LocationUtil.PATH_SEPARATOR)
? strippedLocation
: strippedLocation + LocationUtil.PATH_SEPARATOR;
files = files.filter(files.col(FILE_PATH).startsWith(locationWithTrailingSlash));
}
return files
.filter(files.col(LAST_MODIFIED).lt(new Timestamp(olderThanTimestamp)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,10 @@ public void testCompareToFileList() throws IOException {
assertThat(actualRecords).as("Rows must match").isEqualTo(expectedRecords);

List<FilePathLastModifiedRecord> outsideLocationMockFiles =
Lists.newArrayList(new FilePathLastModifiedRecord("/tmp/mock1", new Timestamp(0L)));
Lists.newArrayList(
new FilePathLastModifiedRecord("/tmp/mock1", new Timestamp(0L)),
new FilePathLastModifiedRecord(
tableLocation + "-backup/mock1.parquet", new Timestamp(0L)));

Dataset<Row> compareToFileListWithOutsideLocation =
spark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.spark.JobGroupInfo;
import org.apache.iceberg.util.FileSystemWalker;
import org.apache.iceberg.util.LocationUtil;
import org.apache.iceberg.util.Pair;
import org.apache.iceberg.util.PropertyUtil;
import org.apache.iceberg.util.Tasks;
Expand Down Expand Up @@ -225,7 +226,12 @@ public DeleteOrphanFilesSparkAction usePrefixListing(boolean newUsePrefixListing
private Dataset<String> filteredCompareToFileList() {
Dataset<Row> files = compareToFileList;
if (location != null) {
files = files.filter(files.col(FILE_PATH).startsWith(location));
String strippedLocation = LocationUtil.stripTrailingSlash(location);

@RussellSpitzer RussellSpitzer Jun 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why don't we just always add the separator here? What does the check below get us?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

    LocationUtil.stripTrailingSlash(location) + LocationUtil.PATH_SEPARATOR;

String locationWithTrailingSlash =
strippedLocation.endsWith(LocationUtil.PATH_SEPARATOR)
? strippedLocation
: strippedLocation + LocationUtil.PATH_SEPARATOR;
files = files.filter(files.col(FILE_PATH).startsWith(locationWithTrailingSlash));
}
return files
.filter(files.col(LAST_MODIFIED).lt(new Timestamp(olderThanTimestamp)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,10 @@ public void testCompareToFileList() throws IOException {
assertThat(actualRecords).as("Rows must match").isEqualTo(expectedRecords);

List<FilePathLastModifiedRecord> outsideLocationMockFiles =
Lists.newArrayList(new FilePathLastModifiedRecord("/tmp/mock1", new Timestamp(0L)));
Lists.newArrayList(
new FilePathLastModifiedRecord("/tmp/mock1", new Timestamp(0L)),
new FilePathLastModifiedRecord(
tableLocation + "-backup/mock1.parquet", new Timestamp(0L)));

Dataset<Row> compareToFileListWithOutsideLocation =
spark
Expand Down
Loading