diff options
author | shumkovnd <shumkovnd@yandex-team.com> | 2023-07-07 15:19:14 +0300 |
---|---|---|
committer | shumkovnd <shumkovnd@yandex-team.com> | 2023-07-07 15:19:14 +0300 |
commit | 76a5265d21865586aabff683651e23913fd41f85 (patch) | |
tree | f78ab9523ce2743374b3a6c32914c73fefc998fd | |
parent | db453fcee2d1a458593a85c47365b9d348c0cd5c (diff) | |
download | ydb-76a5265d21865586aabff683651e23913fd41f85.tar.gz |
KIKIMR-17412: fix printing statistics in script request
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp | 8 | ||||
-rw-r--r-- | ydb/public/lib/ydb_cli/commands/ydb_yql.cpp | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp b/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp index c3c2055701c..1e0d35ef284 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_service_scripting.cpp @@ -152,6 +152,14 @@ void TCommandExecuteYqlScript::PrintResponse(NScripting::TExecuteYqlResult& resu const TMaybe<NTable::TQueryStats>& stats = result.GetStats(); if (stats.Defined()) { Cout << Endl << "Statistics:" << Endl << stats->ToString(); + + auto fullStats = stats->GetPlan(); + if (fullStats) { + Cout << Endl << "Full statistics:" << Endl; + + TQueryPlanPrinter queryPlanPrinter(OutputFormat, /* analyzeMode */ true); + queryPlanPrinter.Print(*fullStats); + } } } diff --git a/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp b/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp index 45f70f8e510..47ca6a47067 100644 --- a/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp +++ b/ydb/public/lib/ydb_cli/commands/ydb_yql.cpp @@ -175,6 +175,7 @@ int TCommandYql::RunCommand(TConfig& config, const TString &script) { bool TCommandYql::PrintResponse(NScripting::TYqlResultPartIterator& result) { TStringStream statsStr; + TMaybe<TString> fullStats; { ui32 currentIndex = 0; TResultSetPrinter printer(OutputFormat, &IsInterrupted); @@ -203,6 +204,10 @@ bool TCommandYql::PrintResponse(NScripting::TYqlResultPartIterator& result) { if (streamPart.HasQueryStats()) { const auto& queryStats = streamPart.GetQueryStats(); statsStr << Endl << queryStats.ToString() << Endl; + + if (queryStats.GetPlan()) { + fullStats = queryStats.GetPlan(); + } } } } // TResultSetPrinter destructor should be called before printing stats @@ -211,6 +216,13 @@ bool TCommandYql::PrintResponse(NScripting::TYqlResultPartIterator& result) { Cout << Endl << "Statistics:" << statsStr.Str(); } + if (fullStats) { + Cout << Endl << "Full statistics:" << Endl; + + TQueryPlanPrinter queryPlanPrinter(OutputFormat, /* analyzeMode */ true); + queryPlanPrinter.Print(*fullStats); + } + if (IsInterrupted()) { Cerr << "<INTERRUPTED>" << Endl; return false; |