Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ydb/core/kqp/session_actor/kqp_session_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,13 +789,18 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor>, IActorExce
void OnSuccessCompileRequest() {
if (QueryState->GetAction() == NKikimrKqp::QUERY_ACTION_EXPLAIN) {
TVector<IKqpGateway::TPhysicalTxData> txs;
std::map<TString, TString> secureParams;
bool isValidParams = true;
auto txAlloc = std::make_shared<TTxAllocatorState>(AppData()->FunctionRegistry, AppData()->TimeProvider, AppData()->RandomProvider);
const auto& parameters = QueryState->GetYdbParameters();
QueryState->QueryData = std::make_shared<TQueryData>(txAlloc);
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);
Expand All @@ -810,6 +815,7 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor>, 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<TUserRequestContext>("", Settings.Database, SessionId);
tasksGraph.GetMeta().SecureParams = std::move(secureParams);

// Resolve tables
{
Expand Down Expand Up @@ -871,7 +877,7 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor>, 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.
}
}
Expand Down
26 changes: 26 additions & 0 deletions ydb/core/kqp/ut/federated_query/datastreams/datastreams_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading