Skip to content

Commit d04225d

Browse files
authored
Decimal migration fix for columnshard (#9625)
1 parent b429de0 commit d04225d

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

ydb/core/scheme/scheme_types_proto.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ TTypeInfoMod TypeInfoModFromProtoColumnType(ui32 typeId, const NKikimrProto::TTy
4242
return res;
4343
}
4444
case NTypeIds::Decimal: {
45-
Y_ABORT_UNLESS(typeInfo, "no type info for decimal type");
46-
TTypeInfoMod res = {
47-
.TypeInfo = {{typeInfo->GetDecimalPrecision(), typeInfo->GetDecimalScale()}},
48-
.TypeMod = {}
49-
};
45+
ui32 precision, scale;
46+
if (!typeInfo) {
47+
precision = DECIMAL_PRECISION;
48+
scale = DECIMAL_SCALE;
49+
} else {
50+
precision = typeInfo->GetDecimalPrecision();
51+
scale = typeInfo->GetDecimalScale();
52+
}
53+
TTypeInfoMod res = {{TDecimalType(precision, scale)}, {}};
5054
return res;
5155
}
5256
default: {

ydb/core/tx/datashard/datashard_user_table.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,8 @@ void TUserTable::ParseProto(const NKikimrSchemeOp::TTableDescription& descr)
266266
for (const auto& col : descr.GetColumns()) {
267267
TUserColumn& column = Columns[col.GetId()];
268268
if (column.Name.empty()) {
269-
std::optional<NKikimrProto::TTypeInfo> typeInfo;
270-
if (col.HasTypeInfo()) {
271-
typeInfo = col.GetTypeInfo();
272-
} else if (col.GetTypeId() == NScheme::NTypeIds::Decimal) {
273-
// Migration from table with no decimal typeInfo
274-
typeInfo = NKikimr::NScheme::DefaultDecimalProto();
275-
} else {
276-
typeInfo = {};
277-
}
278-
279-
auto typeInfoMod = NScheme::TypeInfoModFromProtoColumnType(col.GetTypeId(), typeInfo ? &*typeInfo : nullptr);
269+
auto typeInfoMod = NScheme::TypeInfoModFromProtoColumnType(col.GetTypeId(),
270+
col.HasTypeInfo() ? &col.GetTypeInfo() : nullptr);
280271
column = TUserColumn(typeInfoMod.TypeInfo, typeInfoMod.TypeMod, col.GetName());
281272
}
282273
column.Family = col.GetFamily();

0 commit comments

Comments
 (0)