summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpechatnov <[email protected]>2025-09-08 16:23:58 +0300
committerpechatnov <[email protected]>2025-09-08 16:44:52 +0300
commit2e28ab2b8c2f904adf31f8e71b2c5e034d316493 (patch)
treea5c067677fa7adf3c1f8ad2346b2fb61e798d5e2
parentdc27f8321390f4b66da6a20a5d84cfa1744e63b1 (diff)
Null TTableSchemaPtr is serialized as entity
Сейчас если TTableSchemaPtr в yson struct-ах null, то крэшится сериализатор. А в целом для TIntrusivePtr пишется entity. Делаю чтобы для TTableSchemaPtr тоже писался entity commit_hash:1dde88b3e775a8d542141c775c45585d50526c3a
-rw-r--r--yt/yt/client/table_client/schema_serialization_helpers.cpp2
-rw-r--r--yt/yt/client/table_client/unittests/serialization_ut.cpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/yt/yt/client/table_client/schema_serialization_helpers.cpp b/yt/yt/client/table_client/schema_serialization_helpers.cpp
index e39cae7dc3a..33e40702544 100644
--- a/yt/yt/client/table_client/schema_serialization_helpers.cpp
+++ b/yt/yt/client/table_client/schema_serialization_helpers.cpp
@@ -330,7 +330,7 @@ void Deserialize(TTableSchema& schema, TYsonPullParserCursor* cursor)
void Serialize(const TTableSchemaPtr& schema, IYsonConsumer* consumer)
{
- Serialize(*schema, consumer);
+ NYTree::Serialize<TTableSchema>(schema, consumer);
}
void Deserialize(TTableSchemaPtr& schema, INodePtr node)
diff --git a/yt/yt/client/table_client/unittests/serialization_ut.cpp b/yt/yt/client/table_client/unittests/serialization_ut.cpp
index c3cc622b3e3..038d791b59a 100644
--- a/yt/yt/client/table_client/unittests/serialization_ut.cpp
+++ b/yt/yt/client/table_client/unittests/serialization_ut.cpp
@@ -42,6 +42,21 @@ TEST(TSchemaSerialization, ParseUsingNodeAndSerialize)
R"RR({"$attributes":{"strict":true,"unique_keys":false},"$value":[{"name":"a","required":false,"type":"int64","type_v3":{"type_name":"optional","item":"int64"}},{"stable_name":"b","deleted":true}]})RR");
}
+TEST(TSchemaSerialization, ParseEntityUsingNodeAndSerialize)
+{
+ NYT::NFormats::TFormat format(NFormats::EFormatType::Json);
+
+ TBlobOutput buffer;
+ auto consumer = CreateConsumerForFormat(format, NFormats::EDataType::Structured, &buffer);
+
+ Serialize(TTableSchemaPtr{}, consumer.get());
+ consumer->Flush();
+ auto ref = buffer.Flush();
+ auto buf = ref.ToStringBuf();
+
+ EXPECT_EQ(TString(buf.data(), buf.size()), "null");
+}
+
TEST(TSchemaSerialization, Cursor)
{
const char* schemaString = "<strict=%true;unique_keys=%false>"