@@ -98,7 +98,9 @@ checked<std::nullopt_t, fill_errc> check_schema_compat(
98
98
// Returns true if successful, false if the fill is incomplete because the
99
99
// table schema does not have all the necessary fields. The latter is a
100
100
// signal that the caller needs to add the schema to the table.
101
- checked<bool , schema_manager::errc> apply_evolution_rules (
101
+ using schema_update_required
102
+ = ss::bool_class<struct schema_update_required_tag >;
103
+ checked<schema_update_required, schema_manager::errc> apply_evolution_rules (
102
104
const iceberg::table_identifier& table_id,
103
105
const iceberg::table_metadata& table_meta,
104
106
const iceberg::schema& schema,
@@ -121,10 +123,10 @@ checked<bool, schema_manager::errc> apply_evolution_rules(
121
123
vlog (datalake_log.warn , " Type mismatch with table {}" , table_id);
122
124
return schema_manager::errc::not_supported;
123
125
case fill_errc::schema_evolution_needed:
124
- return false ;
126
+ return schema_update_required::yes ;
125
127
}
126
128
}
127
- return true ;
129
+ return schema_update_required::no ;
128
130
}
129
131
130
132
} // namespace
@@ -261,11 +263,11 @@ catalog_schema_manager::ensure_table_schema(
261
263
// Make a copy so that we still have the original struct in case we
262
264
// need to log it on the error path.
263
265
auto merged_schema_with_evo = merged_schema_struct_type.copy ();
264
- auto get_res = apply_evolution_rules (
266
+ auto evo_res = apply_evolution_rules (
265
267
table_id, txn.table (), *current_schema, merged_schema_with_evo);
266
- if (get_res .has_error ()) {
267
- co_return get_res .error ();
268
- } else if (get_res .value ()) {
268
+ if (evo_res .has_error ()) {
269
+ co_return evo_res .error ();
270
+ } else if (evo_res .value () == schema_update_required::no ) {
269
271
vlog (
270
272
datalake_log.error ,
271
273
" Applying evolution rules on merged schema resulted in a "
@@ -294,11 +296,11 @@ catalog_schema_manager::ensure_table_schema(
294
296
} else {
295
297
// Apply evolution rules from current schema to writer schema.
296
298
auto type_copy = writer_struct_type.copy ();
297
- auto get_res = apply_evolution_rules (
299
+ auto evo_res = apply_evolution_rules (
298
300
table_id, txn.table (), *current_schema, type_copy);
299
- if (get_res .has_error ()) {
300
- co_return get_res .error ();
301
- } else if (!get_res .value ()) {
301
+ if (evo_res .has_error ()) {
302
+ co_return evo_res .error ();
303
+ } else if (evo_res .value () == schema_update_required::yes ) {
302
304
new_schema.emplace (std::move (type_copy));
303
305
}
304
306
}
0 commit comments