Skip to content

Commit 9f0cd19

Browse files
authored
Tests for Decimal PK (#14284)
1 parent 5ca4cf9 commit 9f0cd19

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

ydb/core/tx/replication/service/table_writer_ut.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,29 @@ Y_UNIT_TEST_SUITE(LocalTableWriter) {
126126
}));
127127
}
128128

129+
Y_UNIT_TEST(DecimalKeys) {
130+
TEnv env;
131+
env.GetRuntime().SetLogPriority(NKikimrServices::REPLICATION_SERVICE, NLog::PRI_DEBUG);
132+
133+
env.CreateTable("/Root", *MakeTableDescription(TTestTableDescription{
134+
.Name = "Table",
135+
.KeyColumns = {"key"},
136+
.Columns = {
137+
{.Name = "key", .Type = "Decimal(1,0)"},
138+
{.Name = "value", .Type = "Decimal(35,10)"},
139+
},
140+
}));
141+
142+
auto writer = env.GetRuntime().Register(CreateLocalTableWriter(env.GetPathId("/Root/Table")));
143+
env.Send<TEvWorker::TEvHandshake>(writer, new TEvWorker::TEvHandshake());
144+
145+
env.Send<TEvWorker::TEvPoll>(writer, new TEvWorker::TEvData("TestSource", {
146+
TRecord(1, R"({"key":["1.0"], "update":{"value":"155555555555555.321"}})"),
147+
TRecord(2, R"({"key":["2.0"], "update":{"value":"255555555555555.321"}})"),
148+
TRecord(3, R"({"key":["3.0"], "update":{"value":"355555555555555.321"}})"),
149+
}));
150+
}
151+
129152
THolder<TEvService::TEvTxIdResult> MakeTxIdResult(const TMap<TRowVersion, ui64>& result) {
130153
auto ev = MakeHolder<TEvService::TEvTxIdResult>();
131154

ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,57 @@ value {
17231723
TestGetImport(runtime, txId, "/MyRoot");
17241724
}
17251725

1726+
Y_UNIT_TEST(ExportImportDecimalKey) {
1727+
TTestBasicRuntime runtime;
1728+
TTestEnv env(runtime, TTestEnvOptions().EnableTablePgTypes(true));
1729+
ui64 txId = 100;
1730+
1731+
TestCreateTable(runtime, ++txId, "/MyRoot", R"_(
1732+
Name: "Table"
1733+
Columns { Name: "key" Type: "Decimal(2,1)" }
1734+
Columns { Name: "value" Type: "Decimal(35,10)" }
1735+
KeyColumnNames: ["key"]
1736+
)_");
1737+
env.TestWaitNotification(runtime, txId);
1738+
1739+
const std::pair<ui64, ui64> decimal2 = NYql::NDecimal::MakePair(NYql::NDecimal::FromString("32.1", 2, 1));
1740+
const std::pair<ui64, ui64> decimal35 = NYql::NDecimal::MakePair(NYql::NDecimal::FromString("555555555555555.123456789", 35, 10));
1741+
UploadRow(runtime, "/MyRoot/Table", 0, {1}, {2},
1742+
{TCell::Make<std::pair<ui64, ui64>>(decimal2)}, {TCell::Make<std::pair<ui64, ui64>>(decimal35)});
1743+
1744+
TPortManager portManager;
1745+
const ui16 port = portManager.GetPort();
1746+
1747+
TS3Mock s3Mock({}, TS3Mock::TSettings(port));
1748+
UNIT_ASSERT(s3Mock.Start());
1749+
1750+
TestExport(runtime, ++txId, "/MyRoot", Sprintf(R"(
1751+
ExportToS3Settings {
1752+
endpoint: "localhost:%d"
1753+
scheme: HTTP
1754+
items {
1755+
source_path: "/MyRoot/Table"
1756+
destination_prefix: "Backup1"
1757+
}
1758+
}
1759+
)", port));
1760+
env.TestWaitNotification(runtime, txId);
1761+
TestGetExport(runtime, txId, "/MyRoot");
1762+
1763+
TestImport(runtime, ++txId, "/MyRoot", Sprintf(R"(
1764+
ImportFromS3Settings {
1765+
endpoint: "localhost:%d"
1766+
scheme: HTTP
1767+
items {
1768+
source_prefix: "Backup1"
1769+
destination_path: "/MyRoot/Restored"
1770+
}
1771+
}
1772+
)", port));
1773+
env.TestWaitNotification(runtime, txId);
1774+
TestGetImport(runtime, txId, "/MyRoot");
1775+
}
1776+
17261777
Y_UNIT_TEST(ExportImportUuid) {
17271778
TTestBasicRuntime runtime;
17281779
TTestEnv env(runtime, TTestEnvOptions().EnableTablePgTypes(true));

0 commit comments

Comments
 (0)