mq: reserve the day partition field's name in a topic's table layout

The spec partitions by day(_ts) under the name _ts_day, and Iceberg only
lets a partition field share a column's name when it is that column's
identity. A topic with its own _ts_day field mapped fine and then failed
the table create with an invalid partition spec. Schema now refuses the
name up front, with the system columns, saying it is reserved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-01 17:32:37 -08:00
1 parent f0557105f1
commit 667084ee77
2 files changed
+15 -4

No files matched your search

+6 -4
View File
@@ -59,8 +59,8 @@ func Schema(recordType *schema_pb.RecordType) (*iceberg.Schema, error) {
fields = append(fields, iceberg.NestedField{Name: ValueColumn, Type: iceberg.PrimitiveTypes.Binary})
} else {
for _, field := range recordType.Fields {
if isSystemColumn(field.Name) {
return nil, fmt.Errorf("field %s: name is reserved for a system column", field.Name)
if isReservedName(field.Name) {
return nil, fmt.Errorf("field %s: name is reserved for a system column or partition field", field.Name)
}
mapped, err := mapField(field)
if err != nil {
@@ -72,9 +72,11 @@ func Schema(recordType *schema_pb.RecordType) (*iceberg.Schema, error) {
return iceberg.AssignFreshSchemaIDs(iceberg.NewSchema(0, fields...), nil)
}
func isSystemColumn(name string) bool {
// isReservedName reports a name the table layout itself uses: a partition
// field sharing a column's name only binds when it is that column's identity.
func isReservedName(name string) bool {
switch name {
case PartitionColumn, OffsetColumn, TsNsColumn, TsColumn, KeyColumn, ValueColumn:
case PartitionColumn, OffsetColumn, TsNsColumn, TsColumn, KeyColumn, ValueColumn, TsDayField:
return true
}
return false
+9
View File
@@ -256,6 +256,15 @@ func TestCheckSchema(t *testing.T) {
}
}
// A field named like a partition field would make the spec unbindable, so the
// schema refuses it up front.
func TestSchemaReservesPartitionFieldNames(t *testing.T) {
_, err := Schema(&schema_pb.RecordType{Fields: []*schema_pb.Field{scalarField(TsDayField, schema_pb.ScalarType_INT32, false)}})
if err == nil || !strings.Contains(err.Error(), "reserved") {
t.Fatalf("got %v, want %s refused as reserved", err, TsDayField)
}
}
// Topics whose names only split differently own different tables.
func TestTopicPropertyValueIsUnambiguous(t *testing.T) {
if a, b := TopicPropertyValue(topic.NewTopic("a.b", "c")), TopicPropertyValue(topic.NewTopic("a", "b.c")); a == b {