Skip to content

Commit 676e1b3

Browse files
committed
test(data): lock in fast-path and filter-path routing in DeleteLoader
Adds an integration test that exercises the loader's referenced_data_file fast path with enough rows (128) to clear the consumer's 64-element sniff threshold, and an assertion on the existing mixed-paths test that locks in the filter-path routing. Documents which branch each test covers so a future refactor of PositionDeleteWriter or the loader can't silently take the wrong path.
1 parent efb1db3 commit 676e1b3

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/iceberg/test/delete_loader_test.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ TEST_F(DeleteLoaderTest, LoadPositionDeletesFiltersByDataFilePath) {
169169
{"data_b.parquet", 10},
170170
{"data_b.parquet", 20}});
171171

172+
// Mixed paths -> writer must NOT set the hint, forcing the loader's
173+
// per-row filter path. Locks the routing in case the writer behavior changes.
174+
ASSERT_FALSE(delete_file->referenced_data_file.has_value());
175+
172176
std::vector<std::shared_ptr<DataFile>> files = {delete_file};
173177

174178
// Load only positions for data_a.parquet
@@ -207,6 +211,34 @@ TEST_F(DeleteLoaderTest, LoadPositionDeletesSkipsMismatchedReferencedDataFile) {
207211
ASSERT_TRUE(result.value().IsEmpty());
208212
}
209213

214+
TEST_F(DeleteLoaderTest, LoadPositionDeletesFastPathHonorsReferencedDataFile) {
215+
// Single-file writes -> writer sets referenced_data_file -> loader takes
216+
// the zero-copy fast path. Sized above the consumer's 64-element sniff
217+
// threshold so the dispatcher's real coalesce/bulk logic runs end-to-end,
218+
// not just the small-input shortcut covered by LoadPositionDeletesSingleFile.
219+
constexpr int64_t kRowCount = 128;
220+
std::vector<std::pair<std::string, int64_t>> deletes;
221+
deletes.reserve(kRowCount);
222+
for (int64_t i = 0; i < kRowCount; ++i) {
223+
deletes.emplace_back("data.parquet", i);
224+
}
225+
auto delete_file = WritePositionDeletes("pos_deletes_fast_path.parquet", deletes);
226+
227+
ASSERT_TRUE(delete_file->referenced_data_file.has_value());
228+
ASSERT_EQ(delete_file->referenced_data_file.value(), "data.parquet");
229+
230+
std::vector<std::shared_ptr<DataFile>> files = {delete_file};
231+
auto result = loader_->LoadPositionDeletes(files, "data.parquet");
232+
ASSERT_THAT(result, IsOk());
233+
234+
auto& index = result.value();
235+
ASSERT_EQ(index.Cardinality(), kRowCount);
236+
ASSERT_TRUE(index.IsDeleted(0));
237+
ASSERT_TRUE(index.IsDeleted(kRowCount / 2));
238+
ASSERT_TRUE(index.IsDeleted(kRowCount - 1));
239+
ASSERT_FALSE(index.IsDeleted(kRowCount));
240+
}
241+
210242
TEST_F(DeleteLoaderTest, LoadPositionDeletesRejectsDV) {
211243
auto dv_file = std::make_shared<DataFile>(DataFile{
212244
.content = DataFile::Content::kPositionDeletes,

0 commit comments

Comments
 (0)