diff --git a/go/libraries/doltcore/schema/typeinfo/typeinfo.go b/go/libraries/doltcore/schema/typeinfo/typeinfo.go index fea78d8f5d..1b69b45d53 100644 --- a/go/libraries/doltcore/schema/typeinfo/typeinfo.go +++ b/go/libraries/doltcore/schema/typeinfo/typeinfo.go @@ -134,6 +134,17 @@ type TypeInfo interface { fmt.Stringer } +// RequiresRewrite returns whether or now changing a column type from |old| to |new| requires rewriting table rows. +func RequiresRewrite(old TypeInfo, new TypeInfo) bool { + oldEnum, isOldEnum := old.ToSqlType().(sql.EnumType) + newEnum, isNewEnum := new.ToSqlType().(sql.EnumType) + if isOldEnum && isNewEnum && oldEnum.IsSubsetOf(newEnum) { + return false + } + + return true +} + // FromSqlType takes in a sql.Type and returns the most relevant TypeInfo. func FromSqlType(sqlType sql.Type) (TypeInfo, error) { if gmsExtendedType, ok := sqlType.(gmstypes.ExtendedType); ok { diff --git a/go/libraries/doltcore/sqle/tables.go b/go/libraries/doltcore/sqle/tables.go index e8fb46ea5d..a73cc933b9 100644 --- a/go/libraries/doltcore/sqle/tables.go +++ b/go/libraries/doltcore/sqle/tables.go @@ -1682,7 +1682,7 @@ func (t *AlterableDoltTable) isIncompatibleTypeChange(oldColumn *sql.Column, new if !existingCol.TypeInfo.Equals(newCol.TypeInfo) { if types.IsFormat_DOLT(t.Format()) { // This is overly broad, we could narrow this down a bit - return true + return typeinfo.RequiresRewrite(existingCol.TypeInfo, newCol.TypeInfo) } if existingCol.Kind != newCol.Kind { return true