Skip to content

Commit

Permalink
Decimal migration fix for columnshard (#9625)
Browse files Browse the repository at this point in the history
  • Loading branch information
azevaykin authored Sep 23, 2024
1 parent b429de0 commit d04225d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
14 changes: 9 additions & 5 deletions ydb/core/scheme/scheme_types_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ TTypeInfoMod TypeInfoModFromProtoColumnType(ui32 typeId, const NKikimrProto::TTy
return res;
}
case NTypeIds::Decimal: {
Y_ABORT_UNLESS(typeInfo, "no type info for decimal type");
TTypeInfoMod res = {
.TypeInfo = {{typeInfo->GetDecimalPrecision(), typeInfo->GetDecimalScale()}},
.TypeMod = {}
};
ui32 precision, scale;
if (!typeInfo) {
precision = DECIMAL_PRECISION;
scale = DECIMAL_SCALE;
} else {
precision = typeInfo->GetDecimalPrecision();
scale = typeInfo->GetDecimalScale();
}
TTypeInfoMod res = {{TDecimalType(precision, scale)}, {}};
return res;
}
default: {
Expand Down
13 changes: 2 additions & 11 deletions ydb/core/tx/datashard/datashard_user_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,8 @@ void TUserTable::ParseProto(const NKikimrSchemeOp::TTableDescription& descr)
for (const auto& col : descr.GetColumns()) {
TUserColumn& column = Columns[col.GetId()];
if (column.Name.empty()) {
std::optional<NKikimrProto::TTypeInfo> typeInfo;
if (col.HasTypeInfo()) {
typeInfo = col.GetTypeInfo();
} else if (col.GetTypeId() == NScheme::NTypeIds::Decimal) {
// Migration from table with no decimal typeInfo
typeInfo = NKikimr::NScheme::DefaultDecimalProto();
} else {
typeInfo = {};
}

auto typeInfoMod = NScheme::TypeInfoModFromProtoColumnType(col.GetTypeId(), typeInfo ? &*typeInfo : nullptr);
auto typeInfoMod = NScheme::TypeInfoModFromProtoColumnType(col.GetTypeId(),
col.HasTypeInfo() ? &col.GetTypeInfo() : nullptr);
column = TUserColumn(typeInfoMod.TypeInfo, typeInfoMod.TypeMod, col.GetName());
}
column.Family = col.GetFamily();
Expand Down

0 comments on commit d04225d

Please sign in to comment.