Skip to content

Commit 0f8ebb5

Browse files
author
ermolovd
committed
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
1 parent 2ab257c commit 0f8ebb5

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

yt/cpp/mapreduce/client/operation.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -975,12 +975,15 @@ void CreateOutputTable(
975975
const TRichYPath& path)
976976
{
977977
Y_ENSURE(path.Path_, "Output table is not set");
978-
Create(
979-
preparer.GetClientRetryPolicy()->CreatePolicyForGenericRequest(),
980-
preparer.GetContext(), preparer.GetTransactionId(), path.Path_, NT_TABLE,
981-
TCreateOptions()
982-
.IgnoreExisting(true)
983-
.Recursive(true));
978+
if (!path.Create_.Defined()) {
979+
// If `create` attribute is defined
980+
Create(
981+
preparer.GetClientRetryPolicy()->CreatePolicyForGenericRequest(),
982+
preparer.GetContext(), preparer.GetTransactionId(), path.Path_, NT_TABLE,
983+
TCreateOptions()
984+
.IgnoreExisting(true)
985+
.Recursive(true));
986+
}
984987
}
985988

986989
void CreateOutputTables(

yt/cpp/mapreduce/interface/common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,14 @@ struct TRichYPath
11241124
/// Allows to start cross-transactional operations.
11251125
FLUENT_FIELD_OPTION(TTransactionId, TransactionId);
11261126

1127+
///
1128+
/// @brief Wether to create operation output path.
1129+
///
1130+
/// If set to `true` output path is created by YT server.
1131+
/// If set to `false` output path is not created explicitly (and operation will fail if it doesn't exist)
1132+
/// If attribute is not set output path is created by this library using explicit master call.
1133+
FLUENT_FIELD_OPTION(bool, Create);
1134+
11271135
using TRenameColumnsDescriptor = THashMap<TString, TString>;
11281136

11291137
/// Specifies columnar mapping which will be applied to columns before transfer to job.

yt/cpp/mapreduce/interface/serialize.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ void Serialize(const TRichYPath& path, NYson::IYsonConsumer* consumer)
471471
.DoIf(path.Cluster_.Defined(), [&] (TFluentAttributes fluent) {
472472
fluent.Item("cluster").Value(*path.Cluster_);
473473
})
474+
.DoIf(path.Create_.Defined(), [&] (TFluentAttributes fluent) {
475+
fluent.Item("create").Value(*path.Create_);
476+
})
474477
.EndAttributes()
475478
.Value(path.Path_);
476479
}
@@ -503,6 +506,7 @@ void Deserialize(TRichYPath& path, const TNode& node)
503506
DESERIALIZE_ATTR("rename_columns", path.RenameColumns_);
504507
DESERIALIZE_ATTR("bypass_artifact_cache", path.BypassArtifactCache_);
505508
DESERIALIZE_ATTR("cluster", path.Cluster_);
509+
DESERIALIZE_ATTR("create", path.Create_);
506510
Deserialize(path.Path_, node);
507511
}
508512

0 commit comments

Comments
 (0)