Skip to content

Commit 9c0a054

Browse files
authored
Fix for Decimal PK in CDC (#14286)
1 parent 5157271 commit 9c0a054

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

ydb/core/tx/datashard/datashard_ut_change_exchange.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,6 +2067,23 @@ Y_UNIT_TEST_SUITE(Cdc) {
20672067
});
20682068
}
20692069

2070+
Y_UNIT_TEST(DecimalKey) {
2071+
const auto table = TShardedTableOptions()
2072+
.Columns({
2073+
{"decimal1_key", "Decimal(1, 0)", true, false},
2074+
{"decimal35_key", "Decimal(35, 10)", true, false},
2075+
{"decimal_value", "Decimal", false , false},
2076+
});
2077+
TopicRunner::Read(table, Updates(NKikimrSchemeOp::ECdcStreamFormatJson), {
2078+
R"(
2079+
UPSERT INTO `/Root/Table` (decimal1_key, decimal35_key, decimal_value)
2080+
VALUES (CAST("5.0" AS Decimal(1, 0)), CAST("355555555555555.321" AS Decimal(35, 10)), CAST("4.321" AS Decimal(22, 9)));
2081+
)",
2082+
}, {
2083+
R"({"update":{"decimal_value":"4.321"},"key":["5","355555555555555.321"]})",
2084+
});
2085+
}
2086+
20702087
// Schema snapshots
20712088
using TActionFunc = std::function<ui64(TServer::TPtr)>;
20722089

ydb/core/tx/scheme_board/cache.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,11 +1007,9 @@ class TSchemeCache: public TMonitorableActor<TSchemeCache> {
10071007

10081008
schema.reserve(pqConfig.PartitionKeySchemaSize());
10091009
for (const auto& keySchema : pqConfig.GetPartitionKeySchema()) {
1010-
if (keySchema.GetTypeId() == NScheme::NTypeIds::Pg) {
1011-
schema.push_back(NScheme::TTypeInfo(NPg::TypeDescFromPgTypeId(keySchema.GetTypeInfo().GetPgTypeId())));
1012-
} else {
1013-
schema.push_back(NScheme::TTypeInfo(keySchema.GetTypeId()));
1014-
}
1010+
auto typeInfoMod = NScheme::TypeInfoModFromProtoColumnType(keySchema.GetTypeId(),
1011+
keySchema.HasTypeInfo() ? &keySchema.GetTypeInfo() : nullptr);
1012+
schema.push_back(NScheme::TTypeInfo(typeInfoMod.TypeInfo));
10151013
}
10161014

10171015
partitioning.reserve(pqDesc.PartitionsSize());

0 commit comments

Comments
 (0)