aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2024-09-19 21:14:13 +0300
committerermolovd <ermolovd@yandex-team.com>2024-09-19 21:25:01 +0300
commit1c463c12c42bc4a7071b8a1fc530e5b87d3dca9c (patch)
tree5ec1cd1d68ba79f7bbe31f5259e766dcb3bb4ec3
parent5ce9b712aa7fd8eacab0c51a076f9b8cacad3ca3 (diff)
downloadydb-1c463c12c42bc4a7071b8a1fc530e5b87d3dca9c.tar.gz
Fix: reset RawTypeV3, when Type is set (and vice versa)
commit_hash:af63b4f5a0c2db692a0224330b79c5088c6982dc
-rw-r--r--yt/cpp/mapreduce/interface/common.cpp21
-rw-r--r--yt/cpp/mapreduce/interface/common.h18
-rw-r--r--yt/cpp/mapreduce/interface/ut/common_ut.cpp12
3 files changed, 45 insertions, 6 deletions
diff --git a/yt/cpp/mapreduce/interface/common.cpp b/yt/cpp/mapreduce/interface/common.cpp
index 831762fa95..966be8341f 100644
--- a/yt/cpp/mapreduce/interface/common.cpp
+++ b/yt/cpp/mapreduce/interface/common.cpp
@@ -348,6 +348,7 @@ TColumnSchema& TColumnSchema::Type(const NTi::TTypePtr& type) &
{
Y_ABORT_UNLESS(type.Get(), "Cannot create column schema with nullptr type");
TypeV3_ = type;
+ RawTypeV3_ = {};
return *this;
}
@@ -355,6 +356,7 @@ TColumnSchema TColumnSchema::Type(const NTi::TTypePtr& type) &&
{
Y_ABORT_UNLESS(type.Get(), "Cannot create column schema with nullptr type");
TypeV3_ = type;
+ RawTypeV3_ = {};
return *this;
}
@@ -388,6 +390,25 @@ TColumnSchema TColumnSchema::Type(EValueType type, bool required) &&
return Type(ToTypeV3(type, required));
}
+const TMaybe<TNode>& TColumnSchema::RawTypeV3() const
+{
+ return RawTypeV3_;
+}
+
+TColumnSchema& TColumnSchema::RawTypeV3(TNode rawTypeV3) &
+{
+ RawTypeV3_ = std::move(rawTypeV3);
+ TypeV3_ = nullptr;
+ return *this;
+}
+
+TColumnSchema TColumnSchema::RawTypeV3(TNode rawTypeV3) &&
+{
+ RawTypeV3_ = std::move(rawTypeV3);
+ TypeV3_ = nullptr;
+ return *this;
+}
+
bool operator==(const TColumnSchema& lhs, const TColumnSchema& rhs)
{
return
diff --git a/yt/cpp/mapreduce/interface/common.h b/yt/cpp/mapreduce/interface/common.h
index 557f4ea6c4..d8365c32c0 100644
--- a/yt/cpp/mapreduce/interface/common.h
+++ b/yt/cpp/mapreduce/interface/common.h
@@ -649,11 +649,6 @@ public:
NTi::TTypePtr TypeV3() const;
/// @}
- ///
- /// @brief Raw yson representation of column type
- /// @deprecated Prefer to use `TypeV3` methods.
- FLUENT_FIELD_OPTION_ENCAPSULATED(TNode, RawTypeV3);
-
/// Column sort order
FLUENT_FIELD_OPTION_ENCAPSULATED(ESortOrder, SortOrder);
@@ -696,10 +691,21 @@ public:
TColumnSchema Type(EValueType type, bool required) &&;
/// @}
+ ///
+ /// @{
+ ///
+ /// @brief Raw yson representation of column type
+ /// @deprecated Prefer to use `TypeV3` methods.
+ const TMaybe<TNode>& RawTypeV3() const;
+ TColumnSchema& RawTypeV3(TNode rawTypeV3)&;
+ TColumnSchema RawTypeV3(TNode rawTypeV3)&&;
+ /// @}
+
+
private:
friend void Deserialize(TColumnSchema& columnSchema, const TNode& node);
NTi::TTypePtr TypeV3_;
- bool Required_ = false;
+ TMaybe<TNode> RawTypeV3_;
};
/// Equality check checks all fields of column schema.
diff --git a/yt/cpp/mapreduce/interface/ut/common_ut.cpp b/yt/cpp/mapreduce/interface/ut/common_ut.cpp
index 85122a97ec..f15fa22e21 100644
--- a/yt/cpp/mapreduce/interface/ut/common_ut.cpp
+++ b/yt/cpp/mapreduce/interface/ut/common_ut.cpp
@@ -351,3 +351,15 @@ TEST(TCommonTest, TableSchemaEquality)
other.UniqueKeys(false);
ASSERT_SERIALIZABLES_NE(other, schema);
}
+
+TEST(TCommonTest, ModificationLoadedSchema)
+{
+ auto schema = TTableSchema::FromNode(NodeFromYsonString(R"""(
+ [{name=foo;type_v3=string}]
+ )"""));
+ schema.MutableColumns()[0].Type(VT_INT64, true);
+
+ Cerr << NodeToYsonString(schema.ToNode()) << Endl;
+
+ ASSERT_EQ(schema.ToNode()[0]["type"].AsString(), "int64");
+}