@@ -418,6 +418,32 @@ TEST_F(UpdateSchemaDefaultValueTest, UpdateColumnDefaultDifferentScaleDecimalFai
418418 EXPECT_THAT (result, HasErrorMessage (" Cannot cast default value" ));
419419}
420420
421+ TEST_F (UpdateSchemaDefaultValueTest, AddColumnWithOutOfPrecisionDecimalDefaultFails) {
422+ // A same-scale decimal default whose unscaled value exceeds the column precision is
423+ // rejected here, rather than being relabeled and later rejected by the JSON parser when
424+ // the metadata is read back.
425+ ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateSchema ());
426+ update->AddColumn (" new_col" , decimal (4 , 2 ), " A decimal column" ,
427+ Literal::Decimal (1234567 , 9 , 2 ));
428+
429+ auto result = update->Apply ();
430+ EXPECT_THAT (result, IsError (ErrorKind::kValidationFailed ));
431+ EXPECT_THAT (result, HasErrorMessage (" Cannot cast default value" ));
432+ }
433+
434+ TEST_F (UpdateSchemaDefaultValueTest, AddColumnWithTypedNullDecimalDefaultFails) {
435+ // A typed null default carries decimal type metadata but no Decimal payload; the
436+ // same-scale fast path must not read a Decimal out of it (which would be undefined),
437+ // so it falls through and is rejected as a null default.
438+ ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateSchema ());
439+ update->AddColumn (" new_col" , decimal (18 , 2 ), " A decimal column" ,
440+ Literal::Null (decimal (18 , 2 )));
441+
442+ auto result = update->Apply ();
443+ EXPECT_THAT (result, IsError (ErrorKind::kValidationFailed ));
444+ EXPECT_THAT (result, HasErrorMessage (" Cannot cast default value" ));
445+ }
446+
421447TEST_F (UpdateSchemaTest, AddMultipleColumns) {
422448 ICEBERG_UNWRAP_OR_FAIL (auto update, table_->NewUpdateSchema ());
423449 update->AddColumn (" col1" , int32 (), " First column" )
0 commit comments