@@ -106,6 +106,9 @@ struct TRunOptions {
106
106
TString User;
107
107
TMaybe<TString> BindingsFile;
108
108
NYson::EYsonFormat ResultsFormat;
109
+ bool ValidateOnly = false ;
110
+ bool LineageOnly = false ;
111
+ IOutputStream* LineageStream = nullptr ;
109
112
bool OptimizeOnly = false ;
110
113
bool PeepholeOnly = false ;
111
114
bool TraceOpt = false ;
@@ -334,7 +337,14 @@ int RunProgram(TProgramPtr program, const TRunOptions& options, const THashMap<T
334
337
}
335
338
336
339
TProgram::TStatus status = TProgram::TStatus::Error;
337
- if (options.OptimizeOnly ) {
340
+ if (options.ValidateOnly ) {
341
+ Cout << " Validate program..." << Endl;
342
+ status = program->Validate (options.User );
343
+ } else if (options.LineageOnly ) {
344
+ Cout << " Calculate lineage..." << Endl;
345
+ auto config = TOptPipelineConfigurator (program, options.PrintPlan , options.TracePlan );
346
+ status = program->LineageWithConfig (options.User , config);
347
+ } else if (options.OptimizeOnly ) {
338
348
Cout << " Optimize program..." << Endl;
339
349
auto config = TOptPipelineConfigurator (program, options.PrintPlan , options.TracePlan );
340
350
status = program->OptimizeWithConfig (options.User , config);
@@ -350,7 +360,7 @@ int RunProgram(TProgramPtr program, const TRunOptions& options, const THashMap<T
350
360
}
351
361
return 1 ;
352
362
}
353
- program->Print (options.ExprOut , options.TracePlan );
363
+ program->Print (options.ExprOut , (options. ValidateOnly || options. LineageOnly ) ? nullptr : options.TracePlan );
354
364
355
365
Cout << " Getting results..." << Endl;
356
366
if (program->HasResults ()) {
@@ -363,6 +373,13 @@ int RunProgram(TProgramPtr program, const TRunOptions& options, const THashMap<T
363
373
yson.OnEndList ();
364
374
}
365
375
376
+ if (options.LineageStream ) {
377
+ if (auto st = program->GetLineage ()) {
378
+ TStringInput in (*st);
379
+ NYson::ReformatYsonStream (&in, options.LineageStream , NYson::EYsonFormat::Pretty);
380
+ }
381
+ }
382
+
366
383
if (options.StatisticsStream ) {
367
384
if (auto st = program->GetStatistics (true )) {
368
385
TStringInput in (*st);
@@ -463,6 +480,14 @@ int RunMain(int argc, const char* argv[])
463
480
opts.AddLongOption (" udfs-dir" , " Load all shared libraries with UDFs found"
464
481
" in given directory" )
465
482
.StoreResult (&udfsDir);
483
+ opts.AddLongOption (" validate" , " validate expression" )
484
+ .Optional ()
485
+ .NoArgument ()
486
+ .SetFlag (&runOptions.ValidateOnly );
487
+ opts.AddLongOption (" lineage" , " lineage expression" )
488
+ .Optional ()
489
+ .NoArgument ()
490
+ .SetFlag (&runOptions.LineageOnly );
466
491
opts.AddLongOption (' O' , " optimize" , " optimize expression" )
467
492
.Optional ()
468
493
.NoArgument ()
@@ -911,6 +936,10 @@ int RunMain(int argc, const char* argv[])
911
936
}
912
937
}
913
938
939
+ if (runOptions.LineageOnly ) {
940
+ runOptions.LineageStream = &Cout;
941
+ }
942
+
914
943
int result = RunProgram (std::move (program), runOptions, clusters);
915
944
if (res.Has (" metrics" )) {
916
945
NProto::TMetricsRegistrySnapshot snapshot;
0 commit comments