Skip to content

Commit 459f38a

Browse files
authored
Merge 7d46123 into 6d9da7e
2 parents 6d9da7e + 7d46123 commit 459f38a

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

ydb/core/tx/datashard/change_record_cdc_serializer.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ class TJsonSerializer: public TBaseSerializer {
122122
return result;
123123
}
124124

125+
static NJson::TJsonValue UuidToJson(const TCell& cell) {
126+
TStringStream ss;
127+
ui16 dw[8];
128+
Y_ABORT_UNLESS(cell.Size() == 16);
129+
cell.CopyDataInto((char*)dw);
130+
NUuid::UuidToString(dw, ss);
131+
return NJson::TJsonValue(ss.Str());
132+
}
133+
125134
static NJson::TJsonValue ToJson(const TCell& cell, NScheme::TTypeInfo type) {
126135
if (cell.IsNull()) {
127136
return NJson::TJsonValue(NJson::JSON_NULL);
@@ -184,7 +193,7 @@ class TJsonSerializer: public TBaseSerializer {
184193
// TODO: support pg types
185194
Y_ABORT("pg types are not supported");
186195
case NScheme::NTypeIds::Uuid:
187-
return NJson::TJsonValue(NUuid::UuidBytesToString(cell.Data()));
196+
return UuidToJson(cell);
188197
default:
189198
Y_ABORT("Unexpected type");
190199
}

ydb/core/tx/datashard/datashard_ut_change_collector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ struct TStructRecordBase {
276276
inserter(name, cell.AsValue<ui32>());
277277
} else if constexpr (std::is_same_v<T, TUuidHolder>) {
278278
TStringStream ss;
279-
NUuid::UuidBytesToString(cell.Data(), ss);
279+
NUuid::UuidBytesToString(TString(cell.Data(), cell.Size()), ss);
280280
inserter(name, TUuidHolder(ss.Str()));
281281
}
282282
}
@@ -851,8 +851,8 @@ Y_UNIT_TEST_SUITE(CdcStreamChangeCollector) {
851851
}
852852

853853
Y_UNIT_TEST(InsertSingleUuidRow) {
854-
Run<TUuidHolder>("/Root/path", UuidTable(), KeysOnly(), "INSERT INTO `/Root/path` (key, value) VALUES (Uuid(\"65df1ec1-a97d-47b2-ae56-3c023da6ee8c\"), 10);", {
855-
{"keys_stream", {TStructRecordBase<TUuidHolder>(NTable::ERowOp::Upsert, {{"key", TUuidHolder("65df1ec1-a97d-47b2-ae56-3c023da6ee8c")}})}},
854+
Run<TUuidHolder>("/Root/path", UuidTable(), KeysOnly(), "INSERT INTO `/Root/path` (key, value) VALUES (Uuid(\"65df1ec1-0000-47b2-ae56-3c023da6ee8c\"), 10);", {
855+
{"keys_stream", {TStructRecordBase<TUuidHolder>(NTable::ERowOp::Upsert, {{"key", TUuidHolder("65df1ec1-0000-47b2-ae56-3c023da6ee8c")}})}},
856856
});
857857
}
858858

ydb/public/lib/idx_test/idx_test_data_provider.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ NYdb::TValue CreateOptionalValue(const TColumn& column, const TRandomValueProvid
6363
value.OptionalJson(TString(sb));
6464
}
6565
break;
66+
case EPrimitiveType::Uuid:
67+
value.OptionalUuid(TUuidValue(rvp.RandomUi64(), rvp.RandomUi64()));
68+
break;
6669
default:
6770
Y_ABORT_UNLESS(false, "unimplemented");
6871
}

ydb/tests/functional/replication/main.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Y_UNIT_TEST_SUITE(Replication)
6060
{
6161
const TString query = "UPSERT INTO ProducerUuidValue (Key,Key2,v01,v02,v03) VALUES"
6262
"(1, "
63-
"CAST(\"5b99a330-04ef-4f1a-9b64-ba6d5f44ea00\" as Uuid), "
64-
"CAST(\"5b99a330-04ef-4f1a-9b64-ba6d5f44ea01\" as Uuid), "
65-
"UNWRAP(CAST(\"5b99a330-04ef-4f1a-9b64-ba6d5f44ea02\" as Uuid)), "
63+
"CAST(\"00078af5-0000-0000-6c0b-040000000000\" as Uuid), "
64+
"CAST(\"00078af5-0000-0000-6c0b-040000000001\" as Uuid), "
65+
"UNWRAP(CAST(\"00078af5-0000-0000-6c0b-040000000002\" as Uuid)), "
6666
"CAST(\"311111111113.222222223\" as Double) "
6767
");";
6868
auto res = s.ExecuteDataQuery(query, TTxControl::BeginTx().CommitTx()).GetValueSync();
@@ -90,9 +90,9 @@ Y_UNIT_TEST_SUITE(Replication)
9090
UNIT_ASSERT_C(sessionResult.IsSuccess(), sessionResult.GetIssues().ToString());
9191

9292
auto s = sessionResult.GetSession();
93-
TUuidValue expectedKey2("5b99a330-04ef-4f1a-9b64-ba6d5f44ea00");
94-
TUuidValue expectedV1("5b99a330-04ef-4f1a-9b64-ba6d5f44ea01");
95-
TUuidValue expectedV2("5b99a330-04ef-4f1a-9b64-ba6d5f44ea02");
93+
TUuidValue expectedKey2("00078af5-0000-0000-6c0b-040000000000");
94+
TUuidValue expectedV1("00078af5-0000-0000-6c0b-040000000001");
95+
TUuidValue expectedV2("00078af5-0000-0000-6c0b-040000000002");
9696
double expectedV3 = 311111111113.222222223;
9797
ui32 attempt = 10;
9898
while (--attempt) {

0 commit comments

Comments
 (0)