Skip to content

Commit 39d78c1

Browse files
committed
Fix CTAS explain crash (#19053)
1 parent 1cf95a5 commit 39d78c1

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

.github/config/muted_ya.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ydb/core/kqp/ut/olap KqpOlapWrite.TierDraftsGCWithRestart
4646
ydb/core/kqp/ut/olap [*/*] chunk chunk
4747
ydb/core/kqp/ut/query KqpAnalyze.AnalyzeTable+ColumnStore
4848
ydb/core/kqp/ut/query KqpAnalyze.AnalyzeTable-ColumnStore
49+
ydb/core/kqp/ut/query KqpLimits.StreamWrite+Allowed
4950
ydb/core/kqp/ut/query KqpStats.DeferredEffects+UseSink
5051
ydb/core/kqp/ut/query KqpStats.SysViewClientLost
5152
ydb/core/kqp/ut/scheme KqpOlapScheme.TenThousandColumns

ydb/core/kqp/common/compilation/events.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct TEvCompileRequest: public TEventLocal<TEvCompileRequest, TKqpEvents::EvCo
2020
TKqpDbCountersPtr dbCounters, const TGUCSettings::TPtr& gUCSettings, const TMaybe<TString>& applicationName,
2121
std::shared_ptr<std::atomic<bool>> intrestedInResult, const TIntrusivePtr<TUserRequestContext>& userRequestContext, NLWTrace::TOrbit orbit = {},
2222
TKqpTempTablesState::TConstPtr tempTablesState = nullptr, bool collectDiagnostics = false, TMaybe<TQueryAst> queryAst = Nothing(),
23-
bool split = false, NYql::TExprContext* splitCtx = nullptr, NYql::TExprNode::TPtr splitExpr = nullptr)
23+
bool split = false, std::shared_ptr<NYql::TExprContext> splitCtx = nullptr, NYql::TExprNode::TPtr splitExpr = nullptr)
2424
: UserToken(userToken)
2525
, ClientAddress(clientAddress)
2626
, Uid(uid)
@@ -39,8 +39,8 @@ struct TEvCompileRequest: public TEventLocal<TEvCompileRequest, TKqpEvents::EvCo
3939
, CollectDiagnostics(collectDiagnostics)
4040
, QueryAst(queryAst)
4141
, Split(split)
42-
, SplitCtx(splitCtx)
43-
, SplitExpr(splitExpr)
42+
, SplitCtx(std::move(splitCtx))
43+
, SplitExpr(std::move(splitExpr))
4444
{
4545
Y_ENSURE(Uid.Defined() != Query.Defined());
4646
}
@@ -70,7 +70,7 @@ struct TEvCompileRequest: public TEventLocal<TEvCompileRequest, TKqpEvents::EvCo
7070
TMaybe<TQueryAst> QueryAst;
7171
bool Split = false;
7272

73-
NYql::TExprContext* SplitCtx = nullptr;
73+
std::shared_ptr<NYql::TExprContext> SplitCtx = nullptr;
7474
NYql::TExprNode::TPtr SplitExpr = nullptr;
7575
};
7676

@@ -80,7 +80,7 @@ struct TEvRecompileRequest: public TEventLocal<TEvRecompileRequest, TKqpEvents::
8080
TKqpDbCountersPtr dbCounters, const TGUCSettings::TPtr& gUCSettings, const TMaybe<TString>& applicationName,
8181
std::shared_ptr<std::atomic<bool>> intrestedInResult, const TIntrusivePtr<TUserRequestContext>& userRequestContext,
8282
NLWTrace::TOrbit orbit = {}, TKqpTempTablesState::TConstPtr tempTablesState = nullptr, TMaybe<TQueryAst> queryAst = Nothing(),
83-
bool split = false, NYql::TExprContext* splitCtx = nullptr, NYql::TExprNode::TPtr splitExpr = nullptr)
83+
bool split = false, std::shared_ptr<NYql::TExprContext> splitCtx = nullptr, NYql::TExprNode::TPtr splitExpr = nullptr)
8484
: UserToken(userToken)
8585
, ClientAddress(clientAddress)
8686
, Uid(uid)
@@ -96,8 +96,8 @@ struct TEvRecompileRequest: public TEventLocal<TEvRecompileRequest, TKqpEvents::
9696
, IntrestedInResult(std::move(intrestedInResult))
9797
, QueryAst(queryAst)
9898
, Split(split)
99-
, SplitCtx(splitCtx)
100-
, SplitExpr(splitExpr)
99+
, SplitCtx(std::move(splitCtx))
100+
, SplitExpr(std::move(splitExpr))
101101
{
102102
}
103103

@@ -121,7 +121,7 @@ struct TEvRecompileRequest: public TEventLocal<TEvRecompileRequest, TKqpEvents::
121121
TMaybe<TQueryAst> QueryAst;
122122
bool Split = false;
123123

124-
NYql::TExprContext* SplitCtx = nullptr;
124+
std::shared_ptr<NYql::TExprContext> SplitCtx = nullptr;
125125
NYql::TExprNode::TPtr SplitExpr = nullptr;
126126
};
127127

ydb/core/kqp/compile_service/kqp_compile_actor.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
5454
NWilson::TTraceId traceId, TKqpTempTablesState::TConstPtr tempTablesState, bool collectFullDiagnostics,
5555
bool perStatementResult,
5656
ECompileActorAction compileAction, TMaybe<TQueryAst> queryAst,
57-
NYql::TExprContext* splitCtx,
57+
std::shared_ptr<NYql::TExprContext> splitCtx,
5858
NYql::TExprNode::TPtr splitExpr)
5959
: Owner(owner)
6060
, ModuleResolverState(moduleResolverState)
@@ -71,14 +71,14 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
7171
, Config(MakeIntrusive<TKikimrConfiguration>())
7272
, QueryServiceConfig(queryServiceConfig)
7373
, CompilationTimeout(TDuration::MilliSeconds(tableServiceConfig.GetCompileTimeoutMs()))
74+
, SplitCtx(std::move(splitCtx))
75+
, SplitExpr(std::move(splitExpr))
7476
, UserRequestContext(userRequestContext)
7577
, CompileActorSpan(TWilsonKqp::CompileActor, std::move(traceId), "CompileActor")
7678
, TempTablesState(std::move(tempTablesState))
7779
, CollectFullDiagnostics(collectFullDiagnostics)
7880
, CompileAction(compileAction)
7981
, QueryAst(std::move(queryAst))
80-
, SplitCtx(splitCtx)
81-
, SplitExpr(splitExpr)
8282
{
8383
Config->Init(kqpSettings->DefaultSettings.GetDefaultSettings(), QueryId.Cluster, kqpSettings->Settings, false);
8484

@@ -270,15 +270,15 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
270270

271271
case NKikimrKqp::QUERY_TYPE_SQL_GENERIC_QUERY:
272272
prepareSettings.ConcurrentResults = false;
273-
AsyncCompileResult = KqpHost->PrepareGenericQuery(QueryRef, prepareSettings, SplitExpr);
273+
AsyncCompileResult = KqpHost->PrepareGenericQuery(QueryRef, prepareSettings, SplitExpr.get());
274274
break;
275275

276276
case NKikimrKqp::QUERY_TYPE_SQL_GENERIC_CONCURRENT_QUERY:
277-
AsyncCompileResult = KqpHost->PrepareGenericQuery(QueryRef, prepareSettings, SplitExpr);
277+
AsyncCompileResult = KqpHost->PrepareGenericQuery(QueryRef, prepareSettings, SplitExpr.get());
278278
break;
279279

280280
case NKikimrKqp::QUERY_TYPE_SQL_GENERIC_SCRIPT:
281-
AsyncCompileResult = KqpHost->PrepareGenericScript(QueryRef, prepareSettings, SplitExpr);
281+
AsyncCompileResult = KqpHost->PrepareGenericScript(QueryRef, prepareSettings, SplitExpr.get());
282282
break;
283283

284284
default:
@@ -319,7 +319,7 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
319319

320320
KqpHost = CreateKqpHost(Gateway, QueryId.Cluster, QueryId.Database, Config, ModuleResolverState->ModuleResolver,
321321
FederatedQuerySetup, UserToken, GUCSettings, QueryServiceConfig, ApplicationName, AppData(ctx)->FunctionRegistry,
322-
false, false, std::move(TempTablesState), nullptr, SplitCtx, UserRequestContext);
322+
false, false, std::move(TempTablesState), nullptr, SplitCtx.get(), UserRequestContext);
323323

324324
IKqpHost::TPrepareSettings prepareSettings;
325325
prepareSettings.DocumentApiRestricted = QueryId.Settings.DocumentApiRestricted;
@@ -600,6 +600,8 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
600600
TDuration CompileCpuTime;
601601
TInstant RecompileStartTime;
602602
TActorId TimeoutTimerActorId;
603+
std::shared_ptr<NYql::TExprContext> SplitCtx;
604+
NYql::TExprNode::TPtr SplitExpr;
603605
TIntrusivePtr<IKqpGateway> Gateway;
604606
TIntrusivePtr<IKqpHost> KqpHost;
605607
TIntrusivePtr<IKqpHost::IAsyncQueryResult> AsyncCompileResult;
@@ -617,9 +619,6 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
617619
bool PerStatementResult;
618620
ECompileActorAction CompileAction;
619621
TMaybe<TQueryAst> QueryAst;
620-
621-
NYql::TExprContext* SplitCtx = nullptr;
622-
NYql::TExprNode::TPtr SplitExpr = nullptr;
623622
};
624623

625624
void ApplyServiceConfig(TKikimrConfiguration& kqpConfig, const TTableServiceConfig& serviceConfig) {
@@ -667,15 +666,15 @@ IActor* CreateKqpCompileActor(const TActorId& owner, const TKqpSettings::TConstP
667666
const TMaybe<TString>& applicationName, const TIntrusivePtr<TUserRequestContext>& userRequestContext,
668667
NWilson::TTraceId traceId, TKqpTempTablesState::TConstPtr tempTablesState,
669668
ECompileActorAction compileAction, TMaybe<TQueryAst> queryAst, bool collectFullDiagnostics,
670-
bool perStatementResult, NYql::TExprContext* splitCtx, NYql::TExprNode::TPtr splitExpr)
669+
bool perStatementResult, std::shared_ptr<NYql::TExprContext> splitCtx, NYql::TExprNode::TPtr splitExpr)
671670
{
672671
return new TKqpCompileActor(owner, kqpSettings, tableServiceConfig, queryServiceConfig,
673672
moduleResolverState, counters, gUCSettings, applicationName,
674673
uid, query, userToken, clientAddress, dbCounters,
675674
federatedQuerySetup, userRequestContext,
676675
std::move(traceId), std::move(tempTablesState), collectFullDiagnostics,
677676
perStatementResult, compileAction, std::move(queryAst),
678-
splitCtx, splitExpr);
677+
std::move(splitCtx), std::move(splitExpr));
679678
}
680679

681680
} // namespace NKqp

ydb/core/kqp/compile_service/kqp_compile_service.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct TKqpCompileRequest {
5252
const TIntrusivePtr<TUserRequestContext>& userRequestContext, NLWTrace::TOrbit orbit = {}, NWilson::TSpan span = {},
5353
TKqpTempTablesState::TConstPtr tempTablesState = {},
5454
TMaybe<TQueryAst> queryAst = {},
55-
NYql::TExprContext* splitCtx = nullptr,
55+
std::shared_ptr<NYql::TExprContext> splitCtx = nullptr,
5656
NYql::TExprNode::TPtr splitExpr = nullptr)
5757
: Sender(sender)
5858
, Query(std::move(query))
@@ -70,8 +70,8 @@ struct TKqpCompileRequest {
7070
, TempTablesState(std::move(tempTablesState))
7171
, IntrestedInResult(std::move(intrestedInResult))
7272
, QueryAst(std::move(queryAst))
73-
, SplitCtx(splitCtx)
74-
, SplitExpr(splitExpr)
73+
, SplitCtx(std::move(splitCtx))
74+
, SplitExpr(std::move(splitExpr))
7575
{}
7676

7777
TActorId Sender;
@@ -93,7 +93,7 @@ struct TKqpCompileRequest {
9393
std::shared_ptr<std::atomic<bool>> IntrestedInResult;
9494
TMaybe<TQueryAst> QueryAst;
9595

96-
NYql::TExprContext* SplitCtx;
96+
std::shared_ptr<NYql::TExprContext> SplitCtx;
9797
NYql::TExprNode::TPtr SplitExpr;
9898

9999
bool FindInCache = true;

ydb/core/kqp/compile_service/kqp_compile_service.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ IActor* CreateKqpCompileActor(const TActorId& owner, const TKqpSettings::TConstP
170170
TMaybe<TQueryAst> queryAst = {},
171171
bool collectFullDiagnostics = false,
172172
bool PerStatementResult = false,
173-
NYql::TExprContext* ctx = nullptr,
173+
std::shared_ptr<NYql::TExprContext> ctx = nullptr,
174174
NYql::TExprNode::TPtr expr = nullptr);
175175

176176
IActor* CreateKqpCompileRequestActor(const TActorId& owner, const TIntrusiveConstPtr<NACLib::TUserToken>& userToken, const TMaybe<TString>& uid,

ydb/core/kqp/session_actor/kqp_query_state.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ std::unique_ptr<TEvKqp::TEvCompileRequest> TKqpQueryState::BuildCompileSplittedR
404404
return std::make_unique<TEvKqp::TEvCompileRequest>(UserToken, ClientAddress, uid, std::move(query), false,
405405
false, perStatementResult, compileDeadline, DbCounters, gUCSettingsPtr, ApplicationName, std::move(cookie),
406406
UserRequestContext, std::move(Orbit), TempTablesState, GetCollectDiagnostics(), statementAst,
407-
false, SplittedCtx.get(), SplittedExprs.at(NextSplittedExpr));
407+
false, SplittedCtx, SplittedExprs.at(NextSplittedExpr));
408408
}
409409

410410
bool TKqpQueryState::ProcessingLastStatementPart() {

0 commit comments

Comments
 (0)