Skip to content

Commit 7cf464f

Browse files
committed
fix: Correct errors in update Properties implementation
1 parent 6f802aa commit 7cf464f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/iceberg/update/update_properties.cc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,18 @@ UpdateProperties& UpdateProperties::Remove(const std::string& key) {
7373
Result<PendingUpdate::ApplyResult> UpdateProperties::Apply() {
7474
ICEBERG_RETURN_UNEXPECTED(CheckErrors());
7575

76-
auto iter = updates_.find(TableProperties::kFormatVersion.key());
76+
std::unordered_map<std::string, std::string> new_properties;
77+
for (const auto& [key, value] : transaction_->current().properties.configs()) {
78+
if (!removals_.contains(key)) {
79+
new_properties[key] = value;
80+
}
81+
}
82+
83+
for (const auto& [key, value] : updates_) {
84+
new_properties[key] = value;
85+
}
86+
87+
auto iter = new_properties.find(TableProperties::kFormatVersion.key());
7788
if (iter != updates_.end()) {
7889
int parsed_version = 0;
7990
const auto& val = iter->second;
@@ -97,7 +108,7 @@ Result<PendingUpdate::ApplyResult> UpdateProperties::Apply() {
97108

98109
if (auto schema = transaction_->current().Schema(); schema.has_value()) {
99110
ICEBERG_RETURN_UNEXPECTED(
100-
MetricsConfig::VerifyReferencedColumns(updates_, *schema.value()));
111+
MetricsConfig::VerifyReferencedColumns(new_properties, *schema.value()));
101112
}
102113

103114
ApplyResult result;

src/iceberg/update/update_properties.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ class ICEBERG_EXPORT UpdateProperties : public PendingUpdate {
4343
///
4444
/// The key can not be marked for previous removal and reserved property keys will be
4545
/// ignored.
46+
/// \param key The property key to set
47+
/// \param value The property value to set
48+
/// \return Reference to this UpdateProperties for chaining
4649
UpdateProperties& Set(const std::string& key, const std::string& value);
4750

4851
/// \brief Marks a property for removal.
4952
///
50-
/// The key can not be already marked for removal.
51-
///
5253
/// \param key The property key to remove
5354
/// \return Reference to this UpdateProperties for chaining
5455
UpdateProperties& Remove(const std::string& key);

0 commit comments

Comments
 (0)