Skip to content

Commit 70e029b

Browse files
committed
feat(schema): clarify error for types that cannot have a default value
The unknown/variant/geometry/geography branch reported "{type} fields must default to null", which is ambiguous for the unknown type (reads as "unrecognized fields") and awkwardly interpolates a parametrized type (e.g. geometry(srid:...)) into a categorical sentence. Reword to "type {} cannot have a default value" and align with the sibling "Invalid {} value for {}: ..." messages.
1 parent 2efca23 commit 70e029b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/iceberg/schema_field.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Status ValidateDefault(const SchemaField& field, const Literal& value,
142142
case TypeId::kVariant:
143143
case TypeId::kGeometry:
144144
case TypeId::kGeography:
145-
return InvalidSchema("Invalid {} value for {}: {} fields must default to null",
145+
return InvalidSchema("Invalid {} value for {}: type {} cannot have a default value",
146146
kind, field.name(), *field.type());
147147
default:
148148
break;

src/iceberg/test/schema_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ TEST(SchemaTest, ValidateRejectsDefaultOnNonPrimitiveAndMustBeNullTypes) {
242242
auto status =
243243
geo_default.Validate(iceberg::TableMetadata::kSupportedTableFormatVersion);
244244
ASSERT_THAT(status, iceberg::IsError(iceberg::ErrorKind::kInvalidSchema));
245-
EXPECT_THAT(status, iceberg::HasErrorMessage("must default to null"));
245+
EXPECT_THAT(status, iceberg::HasErrorMessage("cannot have a default value"));
246246
}
247247

248248
TEST(SchemaTest, ReassignIdsPreservesDefaultValues) {

0 commit comments

Comments
 (0)