From 5c0a85fe7c0344466926b10c53db3ee53213e346 Mon Sep 17 00:00:00 2001 From: Pisarenko Grigoriy Date: Fri, 31 Oct 2025 18:19:20 +0300 Subject: [PATCH 1/2] Fixed uncaught exception in external sources explain --- ydb/core/kqp/session_actor/kqp_session_actor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ydb/core/kqp/session_actor/kqp_session_actor.cpp b/ydb/core/kqp/session_actor/kqp_session_actor.cpp index 60b79ab89bb8..b61115e38a61 100644 --- a/ydb/core/kqp/session_actor/kqp_session_actor.cpp +++ b/ydb/core/kqp/session_actor/kqp_session_actor.cpp @@ -789,6 +789,7 @@ class TKqpSessionActor : public TActorBootstrapped, IActorExce void OnSuccessCompileRequest() { if (QueryState->GetAction() == NKikimrKqp::QUERY_ACTION_EXPLAIN) { TVector txs; + std::map secureParams; bool isValidParams = true; auto txAlloc = std::make_shared(AppData()->FunctionRegistry, AppData()->TimeProvider, AppData()->RandomProvider); const auto& parameters = QueryState->GetYdbParameters(); @@ -796,6 +797,10 @@ class TKqpSessionActor : public TActorBootstrapped, IActorExce QueryState->QueryData->ParseParameters(parameters); for (const auto& tx : QueryState->PreparedQuery->GetTransactions()) { + for (const auto& secretName : tx->GetSecretNames()) { + secureParams.emplace(secretName, ""); + } + txs.emplace_back(tx, QueryState->QueryData); try { QueryState->QueryData->PrepareParameters(tx, QueryState->PreparedQuery, txAlloc->TypeEnv); @@ -810,6 +815,7 @@ class TKqpSessionActor : public TActorBootstrapped, IActorExce auto tasksGraph = TKqpTasksGraph(Settings.Database, txs, txAlloc, {}, Settings.TableService.GetAggregationConfig(), RequestCounters, {}); tasksGraph.GetMeta().AllowOlapDataQuery = Settings.TableService.GetAllowOlapDataQuery(); tasksGraph.GetMeta().UserRequestContext = QueryState ? QueryState->UserRequestContext : MakeIntrusive("", Settings.Database, SessionId); + tasksGraph.GetMeta().SecureParams = std::move(secureParams); // Resolve tables { @@ -871,7 +877,7 @@ class TKqpSessionActor : public TActorBootstrapped, IActorExce tasksGraph.BuildAllTasks({}, resourcesSnapshot, nullptr, nullptr); // TODO: fill tasks count into result // Cerr << tasksGraph.DumpToString(); - } catch (const yexception&) { + } catch (const std::exception&) { // TODO: send warning to user that we failed to estimate number of tasks. } } From e88dc3a629e0efdc38ab7ba19ecf0bf74cde1afd Mon Sep 17 00:00:00 2001 From: Pisarenko Grigoriy Date: Fri, 31 Oct 2025 18:34:01 +0300 Subject: [PATCH 2/2] Added unit test --- .../datastreams/datastreams_ut.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ydb/core/kqp/ut/federated_query/datastreams/datastreams_ut.cpp b/ydb/core/kqp/ut/federated_query/datastreams/datastreams_ut.cpp index 54f2a16271a7..1d8a9f35617e 100644 --- a/ydb/core/kqp/ut/federated_query/datastreams/datastreams_ut.cpp +++ b/ydb/core/kqp/ut/federated_query/datastreams/datastreams_ut.cpp @@ -1077,6 +1077,32 @@ Y_UNIT_TEST_SUITE(KqpFederatedQueryDatastreams) { } } + Y_UNIT_TEST_F(ExplainReadTopicBasic, TStreamingTestFixture) { + const TString sourceName = "sourceName"; + const TString topicName = "topicName"; + CreateTopic(topicName); + + CreatePqSourceBasicAuth(sourceName); + + const auto result = GetQueryClient()->ExecuteQuery(fmt::format( + "SELECT * FROM `{source}`.`{topic}`", + "source"_a=sourceName, + "topic"_a=topicName + ), TTxControl::NoTx(), TExecuteQuerySettings().ExecMode(EExecMode::Explain)).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::SUCCESS); + + const auto& stats = result.GetStats(); + UNIT_ASSERT(stats); + + const auto& plan = stats->GetPlan(); + UNIT_ASSERT(plan); + UNIT_ASSERT_STRING_CONTAINS(*plan, sourceName); + + const auto& ast = stats->GetAst(); + UNIT_ASSERT(ast); + UNIT_ASSERT_STRING_CONTAINS(*ast, sourceName); + } + Y_UNIT_TEST_F(InsertTopicBasic, TStreamingTestFixture) { TString sourceName = "sourceName"; TString inputTopicName = "inputTopicName";