Skip to content

Commit 7071acb

Browse files
committed
fix: properly propagate errors in MetricsConfig validation
The previous code had a logic error when checking the result of FindFieldByName(). It used: if (!field.has_value() || !field.value().has_value()) This was incorrect because: 1. If FindFieldByName() returns an error (Result contains an error), field.has_value() would be false, but the error was not propagated 2. field.value() returns std::optional<std::reference_wrapper<...>>, so the second check was redundant and confusing Fixed by using ICEBERG_ASSIGN_OR_RAISE to properly propagate any errors from FindFieldByName(), then checking if the returned optional contains a value. This matches the pattern used throughout the rest of the codebase and ensures errors are properly handled.
1 parent cf0fd37 commit 7071acb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/iceberg/metrics_config.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Status MetricsConfig::VerifyReferencedColumns(
3636
}
3737
auto field_name =
3838
std::string_view(key).substr(TableProperties::kMetricModeColumnConfPrefix.size());
39-
auto field = schema.FindFieldByName(field_name);
40-
if (!field.has_value() || !field.value().has_value()) {
39+
ICEBERG_ASSIGN_OR_RAISE(auto field, schema.FindFieldByName(field_name));
40+
if (!field.has_value()) {
4141
return ValidationFailed(
4242
"Invalid metrics config, could not find column {} from table prop {} in "
4343
"schema {}",

0 commit comments

Comments
 (0)