File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
providers/yt/gateway/native Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -187,8 +187,31 @@ void FillSpec(NYT::TNode& spec,
187
187
}
188
188
}
189
189
190
+ NYT::TNode annotations;
190
191
if (auto val = settings->Annotations .Get (cluster)) {
191
- spec[" annotations" ] = *val;
192
+ annotations = NYT::TNode::CreateMap (val.Get ()->AsMap ());
193
+ } else {
194
+ annotations = NYT::TNode::CreateMap ();
195
+ }
196
+
197
+ // merge annotations from attributes
198
+ if (auto attrs = execCtx.Session_ ->OperationOptions_ .AttrsYson .GetOrElse (TString ())) {
199
+ NYT::TNode node = NYT::NodeFromYsonString (attrs);
200
+ if (auto attrAnnotations = node.AsMap ().FindPtr (" yt_annotations" )) {
201
+ if (!attrAnnotations->IsMap ()) {
202
+ throw yexception () << " Operation attribute \" yt_annotations\" should be a map" ;
203
+ }
204
+ for (const auto & [k, v] : attrAnnotations->AsMap ()) {
205
+ auto it = annotations.AsMap ().find (k);
206
+ if (it == annotations.AsMap ().end ()) {
207
+ annotations[k] = v;
208
+ }
209
+ }
210
+ }
211
+ }
212
+
213
+ if (!annotations.Empty ()) {
214
+ spec[" annotations" ] = std::move (annotations);
192
215
}
193
216
194
217
if (auto val = settings->StartedBy .Get (cluster)) {
Original file line number Diff line number Diff line change @@ -507,6 +507,7 @@ int RunMain(int argc, const char* argv[])
507
507
TString opId;
508
508
IQStoragePtr qStorage;
509
509
TQContext qContext;
510
+ TString ysonAttrs;
510
511
511
512
NLastGetopt::TOpts opts = NLastGetopt::TOpts::Default ();
512
513
opts.AddLongOption (' p' , " program" , " Program to execute (use '-' to read from stdin)" )
@@ -670,6 +671,7 @@ int RunMain(int argc, const char* argv[])
670
671
.Optional ()
671
672
.RequiredArgument (" ENDPOINT" )
672
673
.StoreResult (&tokenAccessorEndpoint);
674
+ opts.AddLongOption (" yson-attrs" , " Provide operation yson attribues" ).StoreResult (&ysonAttrs);
673
675
opts.AddHelpOption (' h' );
674
676
675
677
opts.SetFreeArgsNum (0 );
@@ -1069,6 +1071,10 @@ int RunMain(int argc, const char* argv[])
1069
1071
runOptions.LineageStream = &Cout;
1070
1072
}
1071
1073
1074
+ if (ysonAttrs) {
1075
+ program->SetOperationAttrsYson (ysonAttrs);
1076
+ }
1077
+
1072
1078
int result = RunProgram (std::move (program), runOptions, clusters, sqlFlags);
1073
1079
if (res.Has (" metrics" )) {
1074
1080
NProto::TMetricsRegistrySnapshot snapshot;
You can’t perform that action at this time.
0 commit comments