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
23 changes: 15 additions & 8 deletions src/iceberg/test/overwrite_files_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,12 @@ TEST_F(OverwriteFilesTest, DeleteAndAddCommit) {
ICEBERG_UNWRAP_OR_FAIL(auto op, NewOverwrite());
op->DeleteFile(file_a_);
op->AddFile(file_b_);
const std::string expected_operation = op->operation();
EXPECT_THAT(op->Commit(), IsOk());

EXPECT_THAT(table_->Refresh(), IsOk());
ICEBERG_UNWRAP_OR_FAIL(auto snapshot, table_->current_snapshot());
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kOperation), expected_operation);
EXPECT_EQ(expected_operation, DataOperation::kOverwrite);
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kOperation),
DataOperation::kOverwrite);
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kAddedDataFiles), "1");
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kDeletedDataFiles), "1");
}
Expand All @@ -196,7 +195,6 @@ TEST_F(OverwriteFilesTest, EmptyCommit) {
CommitFileA();

ICEBERG_UNWRAP_OR_FAIL(auto op, NewOverwrite());
EXPECT_EQ(op->operation(), DataOperation::kOverwrite);
EXPECT_THAT(op->Commit(), IsOk());

EXPECT_THAT(table_->Refresh(), IsOk());
Expand Down Expand Up @@ -283,11 +281,12 @@ TEST_F(OverwriteFilesTest, BulkDeleteCommit) {
ICEBERG_UNWRAP_OR_FAIL(auto op, NewOverwrite());
op->DeleteFiles(data_files, delete_files);
op->AddFile(file_b_);
EXPECT_EQ(op->operation(), DataOperation::kOverwrite);
EXPECT_THAT(op->Commit(), IsOk());

EXPECT_THAT(table_->Refresh(), IsOk());
ICEBERG_UNWRAP_OR_FAIL(auto snapshot, table_->current_snapshot());
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kOperation),
DataOperation::kOverwrite);
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kDeletedDataFiles), "1");
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kAddedDataFiles), "1");
}
Expand Down Expand Up @@ -623,18 +622,26 @@ TEST_F(OverwriteFilesTest, OperationMatrix) {

int index = 0;
for (const auto& c : cases) {
SCOPED_TRACE("case index " + std::to_string(index));
auto file_to_delete =
MakeDataFile("/data/tt_del" + std::to_string(index) + ".parquet", 1L);
if (c.delete_file || c.row_filter) {
CommitFastAppend(file_to_delete);
}
ICEBERG_UNWRAP_OR_FAIL(auto op, NewOverwrite());
if (c.add) {
op->AddFile(MakeDataFile("/data/tt_add" + std::to_string(index) + ".parquet", 1L));
}
if (c.delete_file) {
op->DeleteFile(
MakeDataFile("/data/tt_del" + std::to_string(index) + ".parquet", 1L));
op->DeleteFile(file_to_delete);
}
if (c.row_filter) {
op->OverwriteByRowFilter(Expressions::Equal("x", Literal::Long(1L)));
}
EXPECT_EQ(op->operation(), c.expected) << "case index " << index;
ASSERT_THAT(op->Commit(), IsOk());
ASSERT_THAT(table_->Refresh(), IsOk());
ICEBERG_UNWRAP_OR_FAIL(auto snapshot, table_->current_snapshot());
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kOperation), c.expected);
++index;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/iceberg/test/replace_partitions_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,12 @@ class ReplacePartitionsTest : public UpdateTestBase {

TEST_F(ReplacePartitionsTest, OperationIsOverwrite) {
ICEBERG_UNWRAP_OR_FAIL(auto op, NewReplace());
EXPECT_EQ(op->operation(), DataOperation::kOverwrite);
op->AddFile(file_a_);
ASSERT_THAT(op->Commit(), IsOk());
ASSERT_THAT(table_->Refresh(), IsOk());
ICEBERG_UNWRAP_OR_FAIL(auto snapshot, table_->current_snapshot());
EXPECT_EQ(snapshot->summary.at(SnapshotSummaryFields::kOperation),
DataOperation::kOverwrite);
}

// A replace created from a transaction commits with the rest of the transaction.
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/delete_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class ICEBERG_EXPORT DeleteFiles : public MergingSnapshotUpdate {
/// \return This DeleteFiles for method chaining.
DeleteFiles& ValidateFilesExist();

protected:
std::string operation() override;

protected:
Status Validate(const TableMetadata& current_metadata,
const std::shared_ptr<Snapshot>& snapshot) override;

Expand Down
1 change: 1 addition & 0 deletions src/iceberg/update/merge_append.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ICEBERG_EXPORT MergeAppend : public MergingSnapshotUpdate {
/// \return This MergeAppend for method chaining.
MergeAppend& AppendManifest(const ManifestFile& manifest);

protected:
std::string operation() override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/overwrite_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ class ICEBERG_EXPORT OverwriteFiles : public MergingSnapshotUpdate {
/// \return This OverwriteFiles for method chaining.
OverwriteFiles& CaseSensitive(bool case_sensitive);

protected:
std::string operation() override;

protected:
Status Validate(const TableMetadata& current_metadata,
const std::shared_ptr<Snapshot>& snapshot) override;

Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/replace_partitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ class ICEBERG_EXPORT ReplacePartitions : public MergingSnapshotUpdate {
/// \return Reference to this for method chaining
ReplacePartitions& ValidateNoConflictingDeletes();

protected:
std::string operation() override;

protected:
Status Validate(const TableMetadata& current_metadata,
const std::shared_ptr<Snapshot>& snapshot) override;

Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/rewrite_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ class ICEBERG_EXPORT RewriteFiles : public MergingSnapshotUpdate {
/// \return this for method chaining
RewriteFiles& ValidateFromSnapshot(int64_t snapshot_id);

protected:
std::string operation() override;

protected:
Status Validate(const TableMetadata& current_metadata,
const std::shared_ptr<Snapshot>& snapshot) override;

Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/row_delta.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ class ICEBERG_EXPORT RowDelta : public MergingSnapshotUpdate {
/// \return This RowDelta for method chaining.
RowDelta& ValidateNoConflictingDeleteFiles();

protected:
std::string operation() override;

protected:
Status Validate(const TableMetadata& current_metadata,
const std::shared_ptr<Snapshot>& snapshot) override;

Expand Down
Loading