Skip to content

Commit 6905b16

Browse files
authored
Merge 341b501 into 7a1a682
2 parents 7a1a682 + 341b501 commit 6905b16

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
@@ -124,6 +124,15 @@ class TJsonSerializer: public TBaseSerializer {
124124
return result;
125125
}
126126

127+
static NJson::TJsonValue UuidToJson(const TCell& cell) {
128+
TStringStream ss;
129+
ui16 dw[8];
130+
Y_ABORT_UNLESS(cell.Size() == 16);
131+
cell.CopyDataInto((char*)dw);
132+
NUuid::UuidToString(dw, ss);
133+
return NJson::TJsonValue(ss.Str());
134+
}
135+
127136
static NJson::TJsonValue ToJson(const TCell& cell, NScheme::TTypeInfo type) {
128137
if (cell.IsNull()) {
129138
return NJson::TJsonValue(NJson::JSON_NULL);
@@ -185,7 +194,7 @@ class TJsonSerializer: public TBaseSerializer {
185194
case NScheme::NTypeIds::Pg:
186195
return NJson::TJsonValue(PgToString(cell.AsBuf(), type));
187196
case NScheme::NTypeIds::Uuid:
188-
return NJson::TJsonValue(NUuid::UuidBytesToString(cell.Data()));
197+
return UuidToJson(cell);
189198
default:
190199
Y_ABORT("Unexpected type");
191200
}

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
}
@@ -854,8 +854,8 @@ Y_UNIT_TEST_SUITE(CdcStreamChangeCollector) {
854854
}
855855

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

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)