diff options
author | spuchin <spuchin@ydb.tech> | 2022-11-09 23:30:13 +0300 |
---|---|---|
committer | spuchin <spuchin@ydb.tech> | 2022-11-09 23:30:13 +0300 |
commit | 5bb7bca00ab0df5e03bf689cacea93090b9d9c45 (patch) | |
tree | b105446a492d79491dc67ff36294f891f604c7cc | |
parent | 1e91ddd433d2fe0ff5e1a45163e52e9c4d9bd6a0 (diff) | |
download | ydb-5bb7bca00ab0df5e03bf689cacea93090b9d9c45.tar.gz |
Remove legacy prepared query usages. ()
-rw-r--r-- | ydb/core/kqp/common/kqp_transform.h | 18 | ||||
-rw-r--r-- | ydb/core/kqp/host/kqp_host.cpp | 50 | ||||
-rw-r--r-- | ydb/core/kqp/host/kqp_host_impl.h | 32 | ||||
-rw-r--r-- | ydb/core/kqp/host/kqp_run_data.cpp | 1 | ||||
-rw-r--r-- | ydb/core/kqp/host/kqp_runner.cpp | 8 | ||||
-rw-r--r-- | ydb/core/kqp/kqp_compile_request.cpp | 18 | ||||
-rw-r--r-- | ydb/core/kqp/kqp_session_actor.cpp | 9 | ||||
-rw-r--r-- | ydb/core/kqp/kqp_worker_actor.cpp | 5 | ||||
-rw-r--r-- | ydb/core/protos/kqp.proto | 27 |
9 files changed, 23 insertions, 145 deletions
diff --git a/ydb/core/kqp/common/kqp_transform.h b/ydb/core/kqp/common/kqp_transform.h index e5b994a082..7cb4ca9bd6 100644 --- a/ydb/core/kqp/common/kqp_transform.h +++ b/ydb/core/kqp/common/kqp_transform.h @@ -87,13 +87,9 @@ struct TKqpTxLocks { using TParamValueMap = THashMap<TString, NKikimrMiniKQL::TParams>; struct TDeferredEffect { - NYql::NNodes::TMaybeNode<NYql::NNodes::TExprBase> Node; std::shared_ptr<const NKqpProto::TKqpPhyTx> PhysicalTx; TParamValueMap Params; - explicit TDeferredEffect(const NYql::NNodes::TExprBase& node) - : Node(node) {} - explicit TDeferredEffect(std::shared_ptr<const NKqpProto::TKqpPhyTx>&& physicalTx) : PhysicalTx(std::move(physicalTx)) {} }; @@ -120,15 +116,6 @@ public: private: [[nodiscard]] - bool Add(const NYql::NNodes::TExprBase& node) { - Y_UNUSED(node); - - // TODO: Remove legacy deferred effects - YQL_ENSURE(false, "Unexpected deferred effect kind (OldEngine)"); - return false; - } - - [[nodiscard]] bool Add(std::shared_ptr<const NKqpProto::TKqpPhyTx>&& physicalTx, TParamValueMap&& params) { DeferredEffects.emplace_back(std::move(physicalTx)); DeferredEffects.back().Params = std::move(params); @@ -164,11 +151,6 @@ public: } [[nodiscard]] - bool AddDeferredEffect(const NYql::NNodes::TExprBase& node) { - return DeferredEffects.Add(node); - } - - [[nodiscard]] bool AddDeferredEffect(std::shared_ptr<const NKqpProto::TKqpPhyTx> physicalTx, TParamValueMap&& params) { return DeferredEffects.Add(std::move(physicalTx), std::move(params)); } diff --git a/ydb/core/kqp/host/kqp_host.cpp b/ydb/core/kqp/host/kqp_host.cpp index 94f83f4f2f..a225b548aa 100644 --- a/ydb/core/kqp/host/kqp_host.cpp +++ b/ydb/core/kqp/host/kqp_host.cpp @@ -104,20 +104,6 @@ void FillAstAndPlan(IKqpHost::TQueryResult& queryResult, TExprNode* queryRoot, T queryResult.QueryPlan = planStream.Str(); } -void FillAstAndPlan(IKqpHost::TQueryResult& queryResult, const NKikimrKqp::TPreparedQuery& query) { - YQL_ENSURE(query.KqlsSize() == 1); - - queryResult.QueryAst = query.GetKqls(0).GetAst(); - queryResult.QueryPlan = query.GetKqls(0).GetPlan(); - - if (queryResult.QueryPlan.empty()) { - TStringStream planStream; - NYson::TYsonWriter writer(&planStream, NYson::EYsonFormat::Binary); - writer.OnEntity(); - queryResult.QueryPlan = planStream.Str(); - } -} - /* * Validate YqlScript. */ @@ -274,9 +260,6 @@ public: queryResult.Results.push_back(protoResult); } - if (!SessionCtx->Query().PrepareOnly && SessionCtx->Query().PreparedQuery->KqlsSize() == 1) { - FillAstAndPlan(queryResult, *SessionCtx->Query().PreparedQuery); - } queryResult.QueryAst = SessionCtx->Query().PreparedQuery->GetPhysicalQuery().GetQueryAst(); if (Query) { @@ -346,12 +329,9 @@ public: prepareResult.PreparingQuery->SetText(std::move(QueryText)); prepareResult.SqlVersion = SqlVersion; - if (prepareResult.PreparingQuery->GetVersion() == NKikimrKqp::TPreparedQuery::VERSION_PHYSICAL_V1) { - prepareResult.QueryPlan = SerializeExplainPlan(prepareResult.PreparingQuery->GetPhysicalQuery()); - prepareResult.QueryAst = prepareResult.PreparingQuery->GetPhysicalQuery().GetQueryAst(); - } else { - FillAstAndPlan(prepareResult, *prepareResult.PreparingQuery); - } + YQL_ENSURE(prepareResult.PreparingQuery->GetVersion() == NKikimrKqp::TPreparedQuery::VERSION_PHYSICAL_V1); + prepareResult.QueryPlan = SerializeExplainPlan(prepareResult.PreparingQuery->GetPhysicalQuery()); + prepareResult.QueryAst = prepareResult.PreparingQuery->GetPhysicalQuery().GetQueryAst(); } private: @@ -1708,12 +1688,9 @@ private: TQueryResult explainResult; explainResult.SetSuccess(); - if (prepared.PreparingQuery->GetVersion() == NKikimrKqp::TPreparedQuery::VERSION_PHYSICAL_V1) { - explainResult.QueryPlan = std::move(prepared.QueryPlan); - explainResult.QueryAst = std::move(*prepared.PreparingQuery->MutablePhysicalQuery()->MutableQueryAst()); - } else { - FillAstAndPlan(explainResult, *prepared.PreparingQuery); - } + YQL_ENSURE(prepared.PreparingQuery->GetVersion() == NKikimrKqp::TPreparedQuery::VERSION_PHYSICAL_V1); + explainResult.QueryPlan = std::move(prepared.QueryPlan); + explainResult.QueryAst = std::move(*prepared.PreparingQuery->MutablePhysicalQuery()->MutableQueryAst()); explainResult.SqlVersion = prepared.SqlVersion; return MakeKikimrResultHolder(std::move(explainResult)); }); @@ -1828,15 +1805,6 @@ private: YQL_ENSURE(!settings.CommitTx || !settings.RollbackTx); switch (preparedQuery->GetVersion()) { - case NKikimrKqp::TPreparedQuery::VERSION_V1: { - YQL_ENSURE(preparedQuery->KqlsSize() == 1); - auto& kql = preparedQuery->GetKqls(0); - YQL_ENSURE(!kql.GetSettings().GetCommitTx()); - YQL_ENSURE(!kql.GetSettings().GetRollbackTx()); - YQL_ENSURE(kql.GetSettings().GetIsolationLevel() == NKikimrKqp::ISOLATION_LEVEL_UNDEFINED); - break; - } - case NKikimrKqp::TPreparedQuery::VERSION_PHYSICAL_V1: { break; } @@ -1863,12 +1831,6 @@ private: SessionCtx->Query().Limits = settings.Limits; SessionCtx->Query().PreparedQuery = preparedQuery; - // moved to kqp_runner.cpp, ExecutePreparedQuery(...) -// if (preparedQuery->GetVersion() == NKikimrKqp::TPreparedQuery::VERSION_V1) { -// SessionCtx->Query().PreparedQuery.MutableKqls(0)->MutableSettings()->SetCommitTx(settings.CommitTx); -// SessionCtx->Query().PreparedQuery.MutableKqls(0)->MutableSettings()->SetRollbackTx(settings.RollbackTx); -// } - std::shared_ptr<const NKikimrKqp::TPreparedQuery> reply; if (replyPrepared) { reply = preparedQuery; diff --git a/ydb/core/kqp/host/kqp_host_impl.h b/ydb/core/kqp/host/kqp_host_impl.h index d3d8966b1c..1e8682cee8 100644 --- a/ydb/core/kqp/host/kqp_host_impl.h +++ b/ydb/core/kqp/host/kqp_host_impl.h @@ -244,7 +244,7 @@ public: }; inline bool NeedSnapshot(const TKqpTransactionContext& txCtx, const NYql::TKikimrConfiguration& config, bool rollbackTx, - bool commitTx, const NKqpProto::TKqpPhyQuery* physicalQuery, const NKikimrKqp::TPreparedKql* preparedKql) + bool commitTx, const NKqpProto::TKqpPhyQuery& physicalQuery) { if (*txCtx.EffectiveIsolationLevel != NKikimrKqp::ISOLATION_LEVEL_SERIALIZABLE) return false; @@ -263,28 +263,20 @@ inline bool NeedSnapshot(const TKqpTransactionContext& txCtx, const NYql::TKikim size_t readPhases = 0; bool hasEffects = false; - YQL_ENSURE(physicalQuery || preparedKql); - if (physicalQuery) { - for (const auto &tx : physicalQuery->GetTransactions()) { - switch (tx.GetType()) { - case NKqpProto::TKqpPhyTx::TYPE_COMPUTE: - // ignore pure computations - break; - - default: - ++readPhases; - break; - } + for (const auto &tx : physicalQuery.GetTransactions()) { + switch (tx.GetType()) { + case NKqpProto::TKqpPhyTx::TYPE_COMPUTE: + // ignore pure computations + break; - if (tx.GetHasEffects()) { - hasEffects = true; - } + default: + ++readPhases; + break; } - } else { - YQL_ENSURE(preparedKql); - readPhases += preparedKql->GetMkqls().size(); - hasEffects = !preparedKql->GetEffects().empty(); + if (tx.GetHasEffects()) { + hasEffects = true; + } } // We don't want snapshot when there are effects at the moment, diff --git a/ydb/core/kqp/host/kqp_run_data.cpp b/ydb/core/kqp/host/kqp_run_data.cpp index aaf3a9c6c3..fe1f3743a1 100644 --- a/ydb/core/kqp/host/kqp_run_data.cpp +++ b/ydb/core/kqp/host/kqp_run_data.cpp @@ -52,7 +52,6 @@ protected: Y_VERIFY_DEBUG(txState.DeferredEffects.Empty() || !txState.Locks.Broken()); for (const auto& effect : txState.DeferredEffects) { - YQL_ENSURE(!effect.Node); YQL_ENSURE(effect.PhysicalTx->GetType() == NKqpProto::TKqpPhyTx::TYPE_DATA); request.Transactions.emplace_back(effect.PhysicalTx, GetParamsRefMap(effect.Params)); } diff --git a/ydb/core/kqp/host/kqp_runner.cpp b/ydb/core/kqp/host/kqp_runner.cpp index 4f7465ca2d..1fa071ff8d 100644 --- a/ydb/core/kqp/host/kqp_runner.cpp +++ b/ydb/core/kqp/host/kqp_runner.cpp @@ -274,12 +274,6 @@ private: return true; } - bool ApplyTableOperations(const NKikimrKqp::TPreparedKql& kql, bool strictDml, TExprContext& ctx) { - TVector<NKqpProto::TKqpTableOp> operations(kql.GetOperations().begin(), kql.GetOperations().end()); - TVector<NKqpProto::TKqpTableInfo> tableInfos(kql.GetTableInfo().begin(), kql.GetTableInfo().end()); - return ApplyTableOperations(operations, tableInfos, strictDml, ctx); - } - bool ApplyTableOperations(const NKqpProto::TKqpPhyQuery& query, bool strictDml, TExprContext& ctx) { TVector<NKqpProto::TKqpTableOp> operations(query.GetTableOps().begin(), query.GetTableOps().end()); TVector<NKqpProto::TKqpTableInfo> tableInfos(query.GetTableInfos().begin(), query.GetTableInfos().end()); @@ -474,7 +468,7 @@ public: output = input; if (!NeedSnapshot(TxState->Tx(), *TransformCtx->Config, TransformCtx->Settings.GetRollbackTx(), - TransformCtx->Settings.GetCommitTx(),TransformCtx->PhysicalQuery.get(), nullptr)) + TransformCtx->Settings.GetCommitTx(), *TransformCtx->PhysicalQuery)) { return TStatus::Ok; } diff --git a/ydb/core/kqp/kqp_compile_request.cpp b/ydb/core/kqp/kqp_compile_request.cpp index 75ff3733c0..a89bfdad61 100644 --- a/ydb/core/kqp/kqp_compile_request.cpp +++ b/ydb/core/kqp/kqp_compile_request.cpp @@ -151,18 +151,6 @@ private: } private: - void FillTables(const NKikimrKqp::TPreparedKql& kql) { - for (const auto& tableInfo : kql.GetTableInfo()) { - TTableId tableId(tableInfo.GetTableId().GetOwnerId(), tableInfo.GetTableId().GetTableId()); - auto it = TableVersions.find(tableId); - if (it != TableVersions.end()) { - Y_ENSURE(it->second == tableInfo.GetSchemaVersion()); - } else { - TableVersions.emplace(tableId, tableInfo.GetSchemaVersion()); - } - } - } - void FillTables(const NKqpProto::TKqpPhyTx& phyTx) { for (const auto& stage : phyTx.GetStages()) { for (const auto& tableOp : stage.GetTableOps()) { @@ -181,12 +169,6 @@ private: TableVersions.clear(); switch (query.GetVersion()) { - case NKikimrKqp::TPreparedQuery::VERSION_V1: - for (const auto& kql : query.GetKqls()) { - FillTables(kql); - } - break; - case NKikimrKqp::TPreparedQuery::VERSION_PHYSICAL_V1: for (const auto& tx : query.GetPhysicalQuery().GetTransactions()) { FillTables(tx); diff --git a/ydb/core/kqp/kqp_session_actor.cpp b/ydb/core/kqp/kqp_session_actor.cpp index 93ac42b570..2463401d78 100644 --- a/ydb/core/kqp/kqp_session_actor.cpp +++ b/ydb/core/kqp/kqp_session_actor.cpp @@ -608,7 +608,8 @@ public: AcquirePersistentSnapshot(); return; } else if (NeedSnapshot(*QueryState->TxCtx, *Config, /*rollback*/ false, QueryState->Commit, - &QueryState->PreparedQuery->GetPhysicalQuery(), /*preparedKql*/ nullptr)) { + QueryState->PreparedQuery->GetPhysicalQuery())) + { AcquireMvccSnapshot(); return; } @@ -1122,7 +1123,6 @@ public: QueryState->Commited = true; for (const auto& effect : txCtx.DeferredEffects) { - YQL_ENSURE(!effect.Node); YQL_ENSURE(effect.PhysicalTx->GetType() == NKqpProto::TKqpPhyTx::TYPE_DATA); request.Transactions.emplace_back(effect.PhysicalTx, GetParamsRefMap(effect.Params)); @@ -1669,11 +1669,6 @@ public: auto& preparedQuery = compileResult->PreparedQuery; response.MutableQueryParameters()->CopyFrom(preparedQuery->GetParameters()); - - if (preparedQuery->KqlsSize() > 0) { - response.SetQueryAst(preparedQuery->GetKqls(0).GetAst()); - response.SetQueryPlan(preparedQuery->GetKqls(0).GetPlan()); - } } } diff --git a/ydb/core/kqp/kqp_worker_actor.cpp b/ydb/core/kqp/kqp_worker_actor.cpp index b4f0d24b47..6855e2d80e 100644 --- a/ydb/core/kqp/kqp_worker_actor.cpp +++ b/ydb/core/kqp/kqp_worker_actor.cpp @@ -1271,11 +1271,6 @@ private: auto& preparedQuery = compileResult->PreparedQuery; response.MutableQueryParameters()->CopyFrom(preparedQuery->GetParameters()); - - if (preparedQuery->KqlsSize() > 0) { - response.SetQueryAst(preparedQuery->GetKqls(0).GetAst()); - response.SetQueryPlan(preparedQuery->GetKqls(0).GetPlan()); - } } } diff --git a/ydb/core/protos/kqp.proto b/ydb/core/protos/kqp.proto index 65ad8a6bb9..ff69d2ca1f 100644 --- a/ydb/core/protos/kqp.proto +++ b/ydb/core/protos/kqp.proto @@ -186,7 +186,6 @@ message TTransformProfile { repeated TTransformProfile Stages = 100; } - message TKqlProfile { optional string Query = 1; repeated TMkqlProfile MkqlProfiles = 2; @@ -205,28 +204,6 @@ message TParameterBinding { optional uint32 ResultIndex = 3; } -message TPreparedMkql { - optional string Program = 1; - repeated TParameterBinding Bindings = 2; - optional string ProgramText = 3; - optional bool IsPure = 4; -}; - -message TPreparedEffect { - optional string NodeAst = 1; - repeated TParameterBinding Bindings = 2; -} - -message TPreparedKql { - optional TKqlSettings Settings = 1; - repeated TPreparedMkql Mkqls = 2; - repeated TPreparedEffect Effects = 3; - repeated NKqpProto.TKqpTableOp Operations = 4; - repeated NKqpProto.TKqpTableInfo TableInfo = 5; - optional string Ast = 6; - optional string Plan = 7; -}; - message TPreparedResult { optional uint32 KqlIndex = 1; optional uint32 ResultIndex = 2; @@ -242,12 +219,12 @@ message TParameterDescription { message TPreparedQuery { enum EVersion { VERSION_UNSPECIFIED = 0; - VERSION_V1 = 1; + VERSION_V1_DEPRECATED = 1; VERSION_PHYSICAL_V1 = 11; }; optional uint32 Version = 1; - repeated TPreparedKql Kqls = 2; + reserved 2; // (deprecated) Kqls repeated TPreparedResult Results = 3; repeated TParameterDescription Parameters = 4; optional string Text = 5; |