File tree Expand file tree Collapse file tree
providers/yt/gateway/native Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -187,8 +187,31 @@ void FillSpec(NYT::TNode& spec,
187187 }
188188 }
189189
190+ NYT::TNode annotations;
190191 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);
192215 }
193216
194217 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[])
507507 TString opId;
508508 IQStoragePtr qStorage;
509509 TQContext qContext;
510+ TString ysonAttrs;
510511
511512 NLastGetopt::TOpts opts = NLastGetopt::TOpts::Default ();
512513 opts.AddLongOption (' p' , " program" , " Program to execute (use '-' to read from stdin)" )
@@ -670,6 +671,7 @@ int RunMain(int argc, const char* argv[])
670671 .Optional ()
671672 .RequiredArgument (" ENDPOINT" )
672673 .StoreResult (&tokenAccessorEndpoint);
674+ opts.AddLongOption (" yson-attrs" , " Provide operation yson attribues" ).StoreResult (&ysonAttrs);
673675 opts.AddHelpOption (' h' );
674676
675677 opts.SetFreeArgsNum (0 );
@@ -1069,6 +1071,10 @@ int RunMain(int argc, const char* argv[])
10691071 runOptions.LineageStream = &Cout;
10701072 }
10711073
1074+ if (ysonAttrs) {
1075+ program->SetOperationAttrsYson (ysonAttrs);
1076+ }
1077+
10721078 int result = RunProgram (std::move (program), runOptions, clusters, sqlFlags);
10731079 if (res.Has (" metrics" )) {
10741080 NProto::TMetricsRegistrySnapshot snapshot;
You can’t perform that action at this time.
0 commit comments