aboutsummaryrefslogtreecommitdiffstats
path: root/yt
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2024-11-26 15:38:34 +0300
committerermolovd <ermolovd@yandex-team.com>2024-11-26 15:52:27 +0300
commit0f8ebb5baf44e7aad96d0694c3148889b9a9d2b6 (patch)
tree591cefe9a40ded248b5efd92480ec8dcb33117b9 /yt
parent2ab257cebc2f896cfe01f8bfb27ad34c644f93fe (diff)
downloadydb-0f8ebb5baf44e7aad96d0694c3148889b9a9d2b6.tar.gz
YT-23568: `create` attribute in RichYPath
* Changelog entry Type: feature Component: cpp-sdk Add support for `create` attribute in RichYPath. Don't create paths explicitly if `create` attribute is specified. commit_hash:52e77ce4cf5e21fae6d6e510ffb0edba35ec2a1d
Diffstat (limited to 'yt')
-rw-r--r--yt/cpp/mapreduce/client/operation.cpp15
-rw-r--r--yt/cpp/mapreduce/interface/common.h8
-rw-r--r--yt/cpp/mapreduce/interface/serialize.cpp4
3 files changed, 21 insertions, 6 deletions
diff --git a/yt/cpp/mapreduce/client/operation.cpp b/yt/cpp/mapreduce/client/operation.cpp
index 824b36b206..dea1275b5a 100644
--- a/yt/cpp/mapreduce/client/operation.cpp
+++ b/yt/cpp/mapreduce/client/operation.cpp
@@ -975,12 +975,15 @@ void CreateOutputTable(
const TRichYPath& path)
{
Y_ENSURE(path.Path_, "Output table is not set");
- Create(
- preparer.GetClientRetryPolicy()->CreatePolicyForGenericRequest(),
- preparer.GetContext(), preparer.GetTransactionId(), path.Path_, NT_TABLE,
- TCreateOptions()
- .IgnoreExisting(true)
- .Recursive(true));
+ if (!path.Create_.Defined()) {
+ // If `create` attribute is defined
+ Create(
+ preparer.GetClientRetryPolicy()->CreatePolicyForGenericRequest(),
+ preparer.GetContext(), preparer.GetTransactionId(), path.Path_, NT_TABLE,
+ TCreateOptions()
+ .IgnoreExisting(true)
+ .Recursive(true));
+ }
}
void CreateOutputTables(
diff --git a/yt/cpp/mapreduce/interface/common.h b/yt/cpp/mapreduce/interface/common.h
index 76df343e68..aff09c173f 100644
--- a/yt/cpp/mapreduce/interface/common.h
+++ b/yt/cpp/mapreduce/interface/common.h
@@ -1124,6 +1124,14 @@ struct TRichYPath
/// Allows to start cross-transactional operations.
FLUENT_FIELD_OPTION(TTransactionId, TransactionId);
+ ///
+ /// @brief Wether to create operation output path.
+ ///
+ /// If set to `true` output path is created by YT server.
+ /// If set to `false` output path is not created explicitly (and operation will fail if it doesn't exist)
+ /// If attribute is not set output path is created by this library using explicit master call.
+ FLUENT_FIELD_OPTION(bool, Create);
+
using TRenameColumnsDescriptor = THashMap<TString, TString>;
/// Specifies columnar mapping which will be applied to columns before transfer to job.
diff --git a/yt/cpp/mapreduce/interface/serialize.cpp b/yt/cpp/mapreduce/interface/serialize.cpp
index 519439d879..5ea65b62f1 100644
--- a/yt/cpp/mapreduce/interface/serialize.cpp
+++ b/yt/cpp/mapreduce/interface/serialize.cpp
@@ -471,6 +471,9 @@ void Serialize(const TRichYPath& path, NYson::IYsonConsumer* consumer)
.DoIf(path.Cluster_.Defined(), [&] (TFluentAttributes fluent) {
fluent.Item("cluster").Value(*path.Cluster_);
})
+ .DoIf(path.Create_.Defined(), [&] (TFluentAttributes fluent) {
+ fluent.Item("create").Value(*path.Create_);
+ })
.EndAttributes()
.Value(path.Path_);
}
@@ -503,6 +506,7 @@ void Deserialize(TRichYPath& path, const TNode& node)
DESERIALIZE_ATTR("rename_columns", path.RenameColumns_);
DESERIALIZE_ATTR("bypass_artifact_cache", path.BypassArtifactCache_);
DESERIALIZE_ATTR("cluster", path.Cluster_);
+ DESERIALIZE_ATTR("create", path.Create_);
Deserialize(path.Path_, node);
}