diff options
author | Iuliia Sidorina <ulya.sidorina@gmail.com> | 2022-05-24 18:54:20 +0300 |
---|---|---|
committer | Iuliia Sidorina <ulya.sidorina@gmail.com> | 2022-05-24 18:54:20 +0300 |
commit | 2816f26da8d88e8e58e41f73be11bff1b8940e11 (patch) | |
tree | 6e0f00af20ea97e86f7e4f464d6ce0dcbd7ef293 | |
parent | 4c1ff8f909a40a88b9b698d6350792dbc029fccb (diff) | |
download | ydb-2816f26da8d88e8e58e41f73be11bff1b8940e11.tar.gz |
KIKIMR-14951: simplify cli output for execute --stats full command
refactor(cli): simplify output for execute --stats full command
ref:e8c35e3ab38d47eab1bde312ffef1a389c36d2f8
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp index 2f94b2fc03..5395b4994a 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_table.cpp @@ -503,7 +503,8 @@ int TCommandExecuteQuery::ExecuteScanQuery(TConfig& config) { void TCommandExecuteQuery::PrintScanQueryResponse(NTable::TScanQueryPartIterator& result) { SetInterruptHandlers(); - TStringStream statsStr; + TMaybe<TString> stats; + TMaybe<TString> fullStats; { TResultSetPrinter printer(OutputFormat, &IsInterrupted); @@ -522,18 +523,23 @@ void TCommandExecuteQuery::PrintScanQueryResponse(NTable::TScanQueryPartIterator if (streamPart.HasQueryStats()) { const auto& queryStats = streamPart.GetQueryStats(); - statsStr << Endl << queryStats.ToString(false) << Endl; + stats = queryStats.ToString(); - auto plan = queryStats.GetPlan(); - if (plan) { - statsStr << "Full statistics:" << Endl << *plan << Endl; + if (queryStats.GetPlan()) { + fullStats = queryStats.GetPlan(); } } } } // TResultSetPrinter destructor should be called before printing stats - if (statsStr.Size()) { - Cout << Endl << "Statistics:" << statsStr.Str(); + if (stats) { + Cout << Endl << "Statistics:" << Endl << *stats; + } + + if (fullStats) { + Cout << Endl << "Full statistics:" << Endl; + TQueryPlanPrinter queryPlanPrinter(EOutputFormat::Pretty, /* analyzeMode */ true); + queryPlanPrinter.Print(*fullStats); } if (IsInterrupted()) { |