diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-05-02 18:17:10 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-05-02 18:17:10 +0300 |
commit | 0d66cfaffce5fd15c6ead629d3a6ab2df6d8c1e7 (patch) | |
tree | 83f0491a982b43c8eef003d55e06c7725373ab33 | |
parent | 11aff5b3add429c636e48bc9cd4198448e95a5e4 (diff) | |
download | ydb-0d66cfaffce5fd15c6ead629d3a6ab2df6d8c1e7.tar.gz |
split files
35 files changed, 739 insertions, 307 deletions
diff --git a/ydb/core/kqp/common/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/common/CMakeLists.darwin-x86_64.txt index 407bd91dcb5..35587b33802 100644 --- a/ydb/core/kqp/common/CMakeLists.darwin-x86_64.txt +++ b/ydb/core/kqp/common/CMakeLists.darwin-x86_64.txt @@ -6,6 +6,9 @@ # original buildsystem will not be accepted. +add_subdirectory(compilation) +add_subdirectory(events) +add_subdirectory(simple) get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency @@ -29,6 +32,9 @@ target_link_libraries(core-kqp-common PUBLIC ydb-core-base ydb-core-engine core-kqp-expr_nodes + kqp-common-simple + kqp-common-compilation + kqp-common-events core-kqp-provider tx-long_tx_service-public core-tx-sharding diff --git a/ydb/core/kqp/common/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/common/CMakeLists.linux-aarch64.txt index 940c40b1689..a680d797473 100644 --- a/ydb/core/kqp/common/CMakeLists.linux-aarch64.txt +++ b/ydb/core/kqp/common/CMakeLists.linux-aarch64.txt @@ -6,6 +6,9 @@ # original buildsystem will not be accepted. +add_subdirectory(compilation) +add_subdirectory(events) +add_subdirectory(simple) get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency @@ -30,6 +33,9 @@ target_link_libraries(core-kqp-common PUBLIC ydb-core-base ydb-core-engine core-kqp-expr_nodes + kqp-common-simple + kqp-common-compilation + kqp-common-events core-kqp-provider tx-long_tx_service-public core-tx-sharding diff --git a/ydb/core/kqp/common/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/common/CMakeLists.linux-x86_64.txt index 940c40b1689..a680d797473 100644 --- a/ydb/core/kqp/common/CMakeLists.linux-x86_64.txt +++ b/ydb/core/kqp/common/CMakeLists.linux-x86_64.txt @@ -6,6 +6,9 @@ # original buildsystem will not be accepted. +add_subdirectory(compilation) +add_subdirectory(events) +add_subdirectory(simple) get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency @@ -30,6 +33,9 @@ target_link_libraries(core-kqp-common PUBLIC ydb-core-base ydb-core-engine core-kqp-expr_nodes + kqp-common-simple + kqp-common-compilation + kqp-common-events core-kqp-provider tx-long_tx_service-public core-tx-sharding diff --git a/ydb/core/kqp/common/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/common/CMakeLists.windows-x86_64.txt index 407bd91dcb5..35587b33802 100644 --- a/ydb/core/kqp/common/CMakeLists.windows-x86_64.txt +++ b/ydb/core/kqp/common/CMakeLists.windows-x86_64.txt @@ -6,6 +6,9 @@ # original buildsystem will not be accepted. +add_subdirectory(compilation) +add_subdirectory(events) +add_subdirectory(simple) get_built_tool_path( TOOL_enum_parser_bin TOOL_enum_parser_dependency @@ -29,6 +32,9 @@ target_link_libraries(core-kqp-common PUBLIC ydb-core-base ydb-core-engine core-kqp-expr_nodes + kqp-common-simple + kqp-common-compilation + kqp-common-events core-kqp-provider tx-long_tx_service-public core-tx-sharding diff --git a/ydb/core/kqp/common/compilation/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/common/compilation/CMakeLists.darwin-x86_64.txt new file mode 100644 index 00000000000..23acfee25cc --- /dev/null +++ b/ydb/core/kqp/common/compilation/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,23 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-compilation) +target_compile_options(kqp-common-compilation PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-compilation PUBLIC + contrib-libs-cxxsupp + yutil + core-kqp-query_data + kqp-common-simple + yql-public-issue +) +target_sources(kqp-common-compilation PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/compilation/result.cpp +) diff --git a/ydb/core/kqp/common/compilation/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/common/compilation/CMakeLists.linux-aarch64.txt new file mode 100644 index 00000000000..905a8b9a14c --- /dev/null +++ b/ydb/core/kqp/common/compilation/CMakeLists.linux-aarch64.txt @@ -0,0 +1,24 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-compilation) +target_compile_options(kqp-common-compilation PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-compilation PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + core-kqp-query_data + kqp-common-simple + yql-public-issue +) +target_sources(kqp-common-compilation PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/compilation/result.cpp +) diff --git a/ydb/core/kqp/common/compilation/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/common/compilation/CMakeLists.linux-x86_64.txt new file mode 100644 index 00000000000..905a8b9a14c --- /dev/null +++ b/ydb/core/kqp/common/compilation/CMakeLists.linux-x86_64.txt @@ -0,0 +1,24 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-compilation) +target_compile_options(kqp-common-compilation PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-compilation PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + core-kqp-query_data + kqp-common-simple + yql-public-issue +) +target_sources(kqp-common-compilation PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/compilation/result.cpp +) diff --git a/ydb/core/kqp/common/compilation/CMakeLists.txt b/ydb/core/kqp/common/compilation/CMakeLists.txt new file mode 100644 index 00000000000..f8b31df0c11 --- /dev/null +++ b/ydb/core/kqp/common/compilation/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/ydb/core/kqp/common/compilation/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/common/compilation/CMakeLists.windows-x86_64.txt new file mode 100644 index 00000000000..23acfee25cc --- /dev/null +++ b/ydb/core/kqp/common/compilation/CMakeLists.windows-x86_64.txt @@ -0,0 +1,23 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-compilation) +target_compile_options(kqp-common-compilation PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-compilation PUBLIC + contrib-libs-cxxsupp + yutil + core-kqp-query_data + kqp-common-simple + yql-public-issue +) +target_sources(kqp-common-compilation PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/compilation/result.cpp +) diff --git a/ydb/core/kqp/common/compilation/result.cpp b/ydb/core/kqp/common/compilation/result.cpp new file mode 100644 index 00000000000..138843cf36b --- /dev/null +++ b/ydb/core/kqp/common/compilation/result.cpp @@ -0,0 +1,6 @@ +#include "result.h" +#include <ydb/core/kqp/query_data/kqp_prepared_query.h> + +namespace NKikimr::NKqp { + +} // namespace NKikimr::NKqp diff --git a/ydb/core/kqp/common/compilation/result.h b/ydb/core/kqp/common/compilation/result.h new file mode 100644 index 00000000000..ea26f9ff23e --- /dev/null +++ b/ydb/core/kqp/common/compilation/result.h @@ -0,0 +1,51 @@ +#pragma once +#include <memory> +#include <ydb/core/kqp/common/simple/query_id.h> +#include <ydb/core/kqp/common/simple/helpers.h> +#include <ydb/library/yql/public/issue/yql_issue.h> + +namespace NKikimr::NKqp { + +class TPreparedQueryHolder; + +struct TKqpCompileResult { + using TConstPtr = std::shared_ptr<const TKqpCompileResult>; + + TKqpCompileResult(const TString& uid, TKqpQueryId&& query, const Ydb::StatusIds::StatusCode& status, + const NYql::TIssues& issues, ETableReadType maxReadType) + : Status(status) + , Issues(issues) + , Query(std::move(query)) + , Uid(uid) + , MaxReadType(maxReadType) {} + + TKqpCompileResult(const TString& uid, const Ydb::StatusIds::StatusCode& status, const NYql::TIssues& issues, + ETableReadType maxReadType) + : Status(status) + , Issues(issues) + , Uid(uid) + , MaxReadType(maxReadType) {} + + static std::shared_ptr<TKqpCompileResult> Make(const TString& uid, TKqpQueryId&& query, + const Ydb::StatusIds::StatusCode& status, const NYql::TIssues& issues, ETableReadType maxReadType) + { + return std::make_shared<TKqpCompileResult>(uid, std::move(query), status, issues, maxReadType); + } + + static std::shared_ptr<TKqpCompileResult> Make(const TString& uid, const Ydb::StatusIds::StatusCode& status, + const NYql::TIssues& issues, ETableReadType maxReadType) + { + return std::make_shared<TKqpCompileResult>(uid, status, issues, maxReadType); + } + + Ydb::StatusIds::StatusCode Status; + NYql::TIssues Issues; + + TMaybe<TKqpQueryId> Query; + TString Uid; + + ETableReadType MaxReadType; + + std::shared_ptr<const TPreparedQueryHolder> PreparedQuery; +}; +} // namespace NKikimr::NKqp diff --git a/ydb/core/kqp/common/events/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/common/events/CMakeLists.darwin-x86_64.txt new file mode 100644 index 00000000000..2e48fa7671d --- /dev/null +++ b/ydb/core/kqp/common/events/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,23 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-events) +target_compile_options(kqp-common-events PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-events PUBLIC + contrib-libs-cxxsupp + yutil + ydb-core-protos + ydb-core-base +) +target_sources(kqp-common-events PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/process_response.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/kqp_event_ids.cpp +) diff --git a/ydb/core/kqp/common/events/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/common/events/CMakeLists.linux-aarch64.txt new file mode 100644 index 00000000000..1013ee8365b --- /dev/null +++ b/ydb/core/kqp/common/events/CMakeLists.linux-aarch64.txt @@ -0,0 +1,24 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-events) +target_compile_options(kqp-common-events PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-events PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + ydb-core-protos + ydb-core-base +) +target_sources(kqp-common-events PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/process_response.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/kqp_event_ids.cpp +) diff --git a/ydb/core/kqp/common/events/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/common/events/CMakeLists.linux-x86_64.txt new file mode 100644 index 00000000000..1013ee8365b --- /dev/null +++ b/ydb/core/kqp/common/events/CMakeLists.linux-x86_64.txt @@ -0,0 +1,24 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-events) +target_compile_options(kqp-common-events PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-events PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + ydb-core-protos + ydb-core-base +) +target_sources(kqp-common-events PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/process_response.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/kqp_event_ids.cpp +) diff --git a/ydb/core/kqp/common/events/CMakeLists.txt b/ydb/core/kqp/common/events/CMakeLists.txt new file mode 100644 index 00000000000..f8b31df0c11 --- /dev/null +++ b/ydb/core/kqp/common/events/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/ydb/core/kqp/common/events/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/common/events/CMakeLists.windows-x86_64.txt new file mode 100644 index 00000000000..2e48fa7671d --- /dev/null +++ b/ydb/core/kqp/common/events/CMakeLists.windows-x86_64.txt @@ -0,0 +1,23 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-events) +target_compile_options(kqp-common-events PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(kqp-common-events PUBLIC + contrib-libs-cxxsupp + yutil + ydb-core-protos + ydb-core-base +) +target_sources(kqp-common-events PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/process_response.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/events/kqp_event_ids.cpp +) diff --git a/ydb/core/kqp/common/events/kqp_event_ids.cpp b/ydb/core/kqp/common/events/kqp_event_ids.cpp new file mode 100644 index 00000000000..593199fb384 --- /dev/null +++ b/ydb/core/kqp/common/events/kqp_event_ids.cpp @@ -0,0 +1,5 @@ +#include "kqp_event_ids.h" + +namespace NKikimr::NKqp { + +} diff --git a/ydb/core/kqp/common/events/kqp_event_ids.h b/ydb/core/kqp/common/events/kqp_event_ids.h new file mode 100644 index 00000000000..9723277a5cb --- /dev/null +++ b/ydb/core/kqp/common/events/kqp_event_ids.h @@ -0,0 +1,126 @@ +#pragma once + +#include <ydb/core/base/events.h> +#include <ydb/library/yql/dq/actors/dq_events_ids.h> + +namespace NKikimr { +namespace NKqp { + +struct TKqpEvents { + enum EKqpEvents { + EvQueryRequest = EventSpaceBegin(TKikimrEvents::ES_KQP), + EvQueryResponse, + EvContinueProcess, + EvQueryTimeout, + EvIdleTimeout, + EvCloseSessionRequest, + EvProcessResponse, + EvCreateSessionRequest, + EvCreateSessionResponse, + EvPingSessionRequest, + EvCloseSessionResponse, + EvPingSessionResponse, + EvCompileRequest, + EvCompileResponse, + EvCompileInvalidateRequest, + EvAbortExecution = NYql::NDq::TDqEvents::EDqEvents::EvAbortExecution, + EvInitiateShutdownRequest, + EvInitiateSessionShutdown, + EvContinueShutdown, + EvDataQueryStreamPart, + EvDataQueryStreamPartAck, + EvRecompileRequest, + EvScriptRequest, + EvScriptResponse, + EvFetchScriptResultsRequest, + EvFetchScriptResultsResponse, + EvKqpProxyPublishRequest, + }; + + static_assert (EvCompileInvalidateRequest + 1 == EvAbortExecution); +}; + + +struct TKqpExecuterEvents { + enum EKqpExecuterEvents { + EvTxRequest = EventSpaceBegin(TKikimrEvents::ES_KQP) + 100, + EvTxResponse, + EvStreamData, + EvStreamProfile, + EvProgress, + EvStreamDataAck, + EvTableResolveStatus, + EvShardsResolveStatus + }; +}; + +struct TKqpSnapshotEvents { + enum EKqpSnapshotEvents { + EvCreateSnapshotRequest = EventSpaceBegin(TKikimrEvents::ES_KQP) + 150, + EvCreateSnapshotResponse, + EvDiscardSnapshot + }; +}; + +struct TKqpComputeEvents { + enum EKqpComputeEvents { + Unused0 = NYql::NDq::TDqComputeEvents::EDqComputeEvents::Unused0, + EvState = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvState, + EvResumeExecution = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvResumeExecution, + EvChannelData = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvChannelData, + EvScanData, + EvScanDataAck, + EvChannelsInfo = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvChannelsInfo, + EvChannelDataAck = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvChannelDataAck, + EvScanError, + EvKillScanTablet = NYql::NDq::TDqComputeEvents::EDqComputeEvents::Unused1, + EvRetryChannelData = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvRetryChannelData, + EvRetryChannelDataAck = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvRetryChannelDataAck, + EvScanInitActor, + EvRemoteScanData, + EvRemoteScanDataAck, + }; + + static_assert(Unused0 == EventSpaceBegin(TKikimrEvents::ES_KQP) + 200); + static_assert(EvState == Unused0 + 1); + static_assert(EvResumeExecution == EvState + 1); + static_assert(EvChannelData == EvResumeExecution + 1); + static_assert(EvScanData == EvChannelData + 1); + static_assert(EvScanDataAck == EvScanData + 1); + static_assert(EvChannelsInfo == EvScanDataAck + 1); + static_assert(EvChannelDataAck == EvChannelsInfo + 1); + static_assert(EvScanError == EvChannelDataAck + 1); + static_assert(EvKillScanTablet == EvScanError + 1); + static_assert(EvRetryChannelData == EvKillScanTablet + 1); + static_assert(EvRetryChannelDataAck == EvRetryChannelData + 1); + static_assert(EvScanInitActor == EvRetryChannelDataAck + 1); +}; + +struct TKqpResourceManagerEvents { + enum EKqpResourceManagerEvents { + EvStartComputeTasks = EventSpaceBegin(TKikimrEvents::ES_KQP) + 300, + EvStartComputeTasksFailure, + EvStartedComputeTasks, + EvFinishComputeTask, + EvCancelComputeTasks, + Unused0, + EvStartDsComputeTasks, + Unused3, // EvEstimateResourcesRequest, + Unused4, // EvEstimateResourcesResponse, + Unused1, // EvAllocateTaskResourcesRequest, extra resources allocation + Unused2, // EvAllocateTaskResourcesResponse + }; +}; + +struct TKqpSpillingEvents { + enum EKqpSpillingEvents { + EvWrite = EventSpaceBegin(TKikimrEvents::ES_KQP) + 400, + EvWriteResult, + EvRead, + EvReadResult, + EvError, + }; +}; + +} // namespace NKqp +} // namespace NKikimr diff --git a/ydb/core/kqp/common/events/process_response.cpp b/ydb/core/kqp/common/events/process_response.cpp new file mode 100644 index 00000000000..fe71fdcfbb6 --- /dev/null +++ b/ydb/core/kqp/common/events/process_response.cpp @@ -0,0 +1,18 @@ +#include "process_response.h" + +namespace NKikimr::NKqp::NPrivateEvents { + +THolder<NKikimr::NKqp::NPrivateEvents::TEvProcessResponse> TEvProcessResponse::Error(Ydb::StatusIds::StatusCode ydbStatus, const TString& error) { + auto ev = MakeHolder<TEvProcessResponse>(); + ev->Record.SetYdbStatus(ydbStatus); + ev->Record.SetError(error); + return ev; +} + +THolder<NKikimr::NKqp::NPrivateEvents::TEvProcessResponse> TEvProcessResponse::Success() { + auto ev = MakeHolder<TEvProcessResponse>(); + ev->Record.SetYdbStatus(Ydb::StatusIds::SUCCESS); + return ev; +} + +} // namespace NKikimr::NKqp::NPrivateEvents diff --git a/ydb/core/kqp/common/events/process_response.h b/ydb/core/kqp/common/events/process_response.h new file mode 100644 index 00000000000..bdae89bb29d --- /dev/null +++ b/ydb/core/kqp/common/events/process_response.h @@ -0,0 +1,15 @@ +#pragma once +#include <ydb/core/protos/kqp.pb.h> +#include <library/cpp/actors/core/event_pb.h> +#include <util/generic/ptr.h> +#include "kqp_event_ids.h" + +namespace NKikimr::NKqp::NPrivateEvents { + +struct TEvProcessResponse: public TEventPB<TEvProcessResponse, NKikimrKqp::TEvProcessResponse, + TKqpEvents::EvProcessResponse> { + static THolder<TEvProcessResponse> Error(Ydb::StatusIds::StatusCode ydbStatus, const TString& error); + static THolder<TEvProcessResponse> Success(); +}; + +} // namespace NKikimr::NKqp::NPrivateEvents diff --git a/ydb/core/kqp/common/kqp.cpp b/ydb/core/kqp/common/kqp.cpp index f52e4f122ab..fe9f7d85663 100644 --- a/ydb/core/kqp/common/kqp.cpp +++ b/ydb/core/kqp/common/kqp.cpp @@ -6,24 +6,6 @@ namespace NKikimr::NKqp { -bool IsSqlQuery(const NKikimrKqp::EQueryType& queryType) { - switch (queryType) { - case NKikimrKqp::QUERY_TYPE_SQL_DML: - case NKikimrKqp::QUERY_TYPE_SQL_DDL: - case NKikimrKqp::QUERY_TYPE_SQL_SCRIPT: - case NKikimrKqp::QUERY_TYPE_SQL_SCRIPT_STREAMING: - case NKikimrKqp::QUERY_TYPE_SQL_SCAN: - case NKikimrKqp::QUERY_TYPE_SQL_QUERY: - case NKikimrKqp::QUERY_TYPE_FEDERATED_QUERY: - return true; - - default: - break; - } - - return false; -} - TKqpShutdownController::TKqpShutdownController(NActors::TActorId kqpProxyActorId, const NKikimrConfig::TTableServiceConfig& tableServiceConfig, bool enableGraceful) : KqpProxyActorId_(kqpProxyActorId) , EnableGraceful(enableGraceful) diff --git a/ydb/core/kqp/common/kqp.h b/ydb/core/kqp/common/kqp.h index 18602767937..3a8013ca654 100644 --- a/ydb/core/kqp/common/kqp.h +++ b/ydb/core/kqp/common/kqp.h @@ -1,6 +1,11 @@ #pragma once #include "kqp_event_ids.h" +#include "simple/helpers.h" +#include "simple/query_id.h" +#include "simple/settings.h" +#include "events/process_response.h" +#include "compilation/result.h" #include <library/cpp/lwtrace/shuttle.h> @@ -8,7 +13,6 @@ #include <ydb/core/grpc_services/cancelation/cancelation.h> #include <ydb/core/grpc_services/cancelation/cancelation_event.h> #include <ydb/core/kqp/counters/kqp_counters.h> -#include <ydb/core/kqp/query_data/kqp_prepared_query.h> #include <ydb/library/aclib/aclib.h> #include <ydb/library/yql/dq/actors/dq.h> #include <ydb/library/yql/public/issue/yql_issue.h> @@ -31,12 +35,6 @@ inline void ConvertKqpQueryResultsToDbResult(const TFrom& from, TTo* to) { } } -enum class ETableReadType { - Other = 0, - Scan = 1, - FullScan = 2, -}; - const TStringBuf DefaultKikimrPublicClusterName = "db"; inline NActors::TActorId MakeKqpProxyID(ui32 nodeId) { @@ -125,137 +123,12 @@ private: TIntrusivePtr<TKqpShutdownState> ShutdownState_; }; -struct TKqpQuerySettings { - bool DocumentApiRestricted = true; - bool IsInternalCall = false; - - bool operator==(const TKqpQuerySettings& other) const { - return - DocumentApiRestricted == other.DocumentApiRestricted && - IsInternalCall == other.IsInternalCall; - } - - bool operator!=(const TKqpQuerySettings& other) { - return !(*this == other); - } - - bool operator<(const TKqpQuerySettings&) = delete; - bool operator>(const TKqpQuerySettings&) = delete; - bool operator<=(const TKqpQuerySettings&) = delete; - bool operator>=(const TKqpQuerySettings&) = delete; - - size_t GetHash() const noexcept { - auto tuple = std::make_tuple(DocumentApiRestricted, IsInternalCall); - return THash<decltype(tuple)>()(tuple); - } -}; - -bool IsSqlQuery(const NKikimrKqp::EQueryType& queryType); - -struct TKqpQueryId { - TString Cluster; - TString Database; - TString UserSid; - TString Text; - TKqpQuerySettings Settings; - NKikimrKqp::EQueryType QueryType; - -public: - TKqpQueryId(const TString& cluster, const TString& database, const TString& text, NKikimrKqp::EQueryType type) - : Cluster(cluster) - , Database(database) - , Text(text) - , QueryType(type) - { - switch (QueryType) { - case NKikimrKqp::QUERY_TYPE_SQL_DML: - case NKikimrKqp::QUERY_TYPE_SQL_SCAN: - case NKikimrKqp::QUERY_TYPE_AST_DML: - case NKikimrKqp::QUERY_TYPE_AST_SCAN: - case NKikimrKqp::QUERY_TYPE_SQL_QUERY: - case NKikimrKqp::QUERY_TYPE_FEDERATED_QUERY: - break; - - default: - Y_ENSURE(false, "Unsupported request type"); - } - - } - - bool IsSql() const { - return IsSqlQuery(QueryType); - } - - bool operator==(const TKqpQueryId& other) const { - return - Cluster == other.Cluster && - Database == other.Database && - UserSid == other.UserSid && - Text == other.Text && - Settings == other.Settings && - QueryType == other.QueryType; - } - - bool operator!=(const TKqpQueryId& other) { - return !(*this == other); - } - - bool operator<(const TKqpQueryId&) = delete; - bool operator>(const TKqpQueryId&) = delete; - bool operator<=(const TKqpQueryId&) = delete; - bool operator>=(const TKqpQueryId&) = delete; - - size_t GetHash() const noexcept { - auto tuple = std::make_tuple(Cluster, Database, UserSid, Text, Settings, QueryType); - return THash<decltype(tuple)>()(tuple); - } -}; - -struct TKqpCompileResult { - using TConstPtr = std::shared_ptr<const TKqpCompileResult>; - - TKqpCompileResult(const TString& uid, TKqpQueryId&& query, const Ydb::StatusIds::StatusCode& status, - const NYql::TIssues& issues, ETableReadType maxReadType) - : Status(status) - , Issues(issues) - , Query(std::move(query)) - , Uid(uid) - , MaxReadType(maxReadType) {} - - TKqpCompileResult(const TString& uid, const Ydb::StatusIds::StatusCode& status, const NYql::TIssues& issues, - ETableReadType maxReadType) - : Status(status) - , Issues(issues) - , Uid(uid) - , MaxReadType(maxReadType) {} - - static std::shared_ptr<TKqpCompileResult> Make(const TString& uid, TKqpQueryId&& query, - const Ydb::StatusIds::StatusCode& status, const NYql::TIssues& issues, ETableReadType maxReadType) - { - return std::make_shared<TKqpCompileResult>(uid, std::move(query), status, issues, maxReadType); - } - - static std::shared_ptr<TKqpCompileResult> Make(const TString& uid, const Ydb::StatusIds::StatusCode& status, - const NYql::TIssues& issues, ETableReadType maxReadType) - { - return std::make_shared<TKqpCompileResult>(uid, status, issues, maxReadType); - } - - Ydb::StatusIds::StatusCode Status; - NYql::TIssues Issues; - - TMaybe<TKqpQueryId> Query; - TString Uid; - - ETableReadType MaxReadType; - - TPreparedQueryHolder::TConstPtr PreparedQuery; -}; - struct TEvKqp { struct TEvQueryRequestRemote : public TEventPB<TEvQueryRequestRemote, NKikimrKqp::TEvQueryRequest, TKqpEvents::EvQueryRequest> {}; + using TEvProcessResponse = NPrivateEvents::TEvProcessResponse; + struct TEvQueryRequest : public NActors::TEventLocal<TEvQueryRequest, TKqpEvents::EvQueryRequest> { public: TEvQueryRequest( @@ -544,23 +417,6 @@ struct TEvKqp { struct TEvContinueShutdown : public TEventLocal<TEvContinueShutdown, TKqpEvents::EvContinueShutdown> {}; - struct TEvProcessResponse : public TEventPB<TEvProcessResponse, NKikimrKqp::TEvProcessResponse, - TKqpEvents::EvProcessResponse> - { - static THolder<TEvProcessResponse> Error(Ydb::StatusIds::StatusCode ydbStatus, const TString& error) { - auto ev = MakeHolder<TEvProcessResponse>(); - ev->Record.SetYdbStatus(ydbStatus); - ev->Record.SetError(error); - return ev; - } - - static THolder<TEvProcessResponse> Success() { - auto ev = MakeHolder<TEvProcessResponse>(); - ev->Record.SetYdbStatus(Ydb::StatusIds::SUCCESS); - return ev; - } - }; - struct TEvDataQueryStreamPart : public TEventPB<TEvDataQueryStreamPart, NKikimrKqp::TEvDataQueryStreamPart, TKqpEvents::EvDataQueryStreamPart> {}; @@ -889,17 +745,3 @@ static inline IOutputStream& operator<<(IOutputStream& stream, const TKqpRequest } // namespace NKqp } // namespace NKikimr - -template<> -struct THash<NKikimr::NKqp::TKqpQuerySettings> { - inline size_t operator()(const NKikimr::NKqp::TKqpQuerySettings& settings) const { - return settings.GetHash(); - } -}; - -template<> -struct THash<NKikimr::NKqp::TKqpQueryId> { - inline size_t operator()(const NKikimr::NKqp::TKqpQueryId& query) const { - return query.GetHash(); - } -}; diff --git a/ydb/core/kqp/common/kqp_event_ids.h b/ydb/core/kqp/common/kqp_event_ids.h index 9723277a5cb..491443c69f8 100644 --- a/ydb/core/kqp/common/kqp_event_ids.h +++ b/ydb/core/kqp/common/kqp_event_ids.h @@ -1,126 +1,3 @@ #pragma once -#include <ydb/core/base/events.h> -#include <ydb/library/yql/dq/actors/dq_events_ids.h> - -namespace NKikimr { -namespace NKqp { - -struct TKqpEvents { - enum EKqpEvents { - EvQueryRequest = EventSpaceBegin(TKikimrEvents::ES_KQP), - EvQueryResponse, - EvContinueProcess, - EvQueryTimeout, - EvIdleTimeout, - EvCloseSessionRequest, - EvProcessResponse, - EvCreateSessionRequest, - EvCreateSessionResponse, - EvPingSessionRequest, - EvCloseSessionResponse, - EvPingSessionResponse, - EvCompileRequest, - EvCompileResponse, - EvCompileInvalidateRequest, - EvAbortExecution = NYql::NDq::TDqEvents::EDqEvents::EvAbortExecution, - EvInitiateShutdownRequest, - EvInitiateSessionShutdown, - EvContinueShutdown, - EvDataQueryStreamPart, - EvDataQueryStreamPartAck, - EvRecompileRequest, - EvScriptRequest, - EvScriptResponse, - EvFetchScriptResultsRequest, - EvFetchScriptResultsResponse, - EvKqpProxyPublishRequest, - }; - - static_assert (EvCompileInvalidateRequest + 1 == EvAbortExecution); -}; - - -struct TKqpExecuterEvents { - enum EKqpExecuterEvents { - EvTxRequest = EventSpaceBegin(TKikimrEvents::ES_KQP) + 100, - EvTxResponse, - EvStreamData, - EvStreamProfile, - EvProgress, - EvStreamDataAck, - EvTableResolveStatus, - EvShardsResolveStatus - }; -}; - -struct TKqpSnapshotEvents { - enum EKqpSnapshotEvents { - EvCreateSnapshotRequest = EventSpaceBegin(TKikimrEvents::ES_KQP) + 150, - EvCreateSnapshotResponse, - EvDiscardSnapshot - }; -}; - -struct TKqpComputeEvents { - enum EKqpComputeEvents { - Unused0 = NYql::NDq::TDqComputeEvents::EDqComputeEvents::Unused0, - EvState = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvState, - EvResumeExecution = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvResumeExecution, - EvChannelData = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvChannelData, - EvScanData, - EvScanDataAck, - EvChannelsInfo = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvChannelsInfo, - EvChannelDataAck = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvChannelDataAck, - EvScanError, - EvKillScanTablet = NYql::NDq::TDqComputeEvents::EDqComputeEvents::Unused1, - EvRetryChannelData = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvRetryChannelData, - EvRetryChannelDataAck = NYql::NDq::TDqComputeEvents::EDqComputeEvents::EvRetryChannelDataAck, - EvScanInitActor, - EvRemoteScanData, - EvRemoteScanDataAck, - }; - - static_assert(Unused0 == EventSpaceBegin(TKikimrEvents::ES_KQP) + 200); - static_assert(EvState == Unused0 + 1); - static_assert(EvResumeExecution == EvState + 1); - static_assert(EvChannelData == EvResumeExecution + 1); - static_assert(EvScanData == EvChannelData + 1); - static_assert(EvScanDataAck == EvScanData + 1); - static_assert(EvChannelsInfo == EvScanDataAck + 1); - static_assert(EvChannelDataAck == EvChannelsInfo + 1); - static_assert(EvScanError == EvChannelDataAck + 1); - static_assert(EvKillScanTablet == EvScanError + 1); - static_assert(EvRetryChannelData == EvKillScanTablet + 1); - static_assert(EvRetryChannelDataAck == EvRetryChannelData + 1); - static_assert(EvScanInitActor == EvRetryChannelDataAck + 1); -}; - -struct TKqpResourceManagerEvents { - enum EKqpResourceManagerEvents { - EvStartComputeTasks = EventSpaceBegin(TKikimrEvents::ES_KQP) + 300, - EvStartComputeTasksFailure, - EvStartedComputeTasks, - EvFinishComputeTask, - EvCancelComputeTasks, - Unused0, - EvStartDsComputeTasks, - Unused3, // EvEstimateResourcesRequest, - Unused4, // EvEstimateResourcesResponse, - Unused1, // EvAllocateTaskResourcesRequest, extra resources allocation - Unused2, // EvAllocateTaskResourcesResponse - }; -}; - -struct TKqpSpillingEvents { - enum EKqpSpillingEvents { - EvWrite = EventSpaceBegin(TKikimrEvents::ES_KQP) + 400, - EvWriteResult, - EvRead, - EvReadResult, - EvError, - }; -}; - -} // namespace NKqp -} // namespace NKikimr +#include "events/kqp_event_ids.h" diff --git a/ydb/core/kqp/common/simple/CMakeLists.darwin-x86_64.txt b/ydb/core/kqp/common/simple/CMakeLists.darwin-x86_64.txt new file mode 100644 index 00000000000..28c9e36787d --- /dev/null +++ b/ydb/core/kqp/common/simple/CMakeLists.darwin-x86_64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-simple) +target_link_libraries(kqp-common-simple PUBLIC + contrib-libs-cxxsupp + yutil + ydb-core-protos +) +target_sources(kqp-common-simple PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/helpers.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/query_id.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/settings.cpp +) diff --git a/ydb/core/kqp/common/simple/CMakeLists.linux-aarch64.txt b/ydb/core/kqp/common/simple/CMakeLists.linux-aarch64.txt new file mode 100644 index 00000000000..0c8ad81844e --- /dev/null +++ b/ydb/core/kqp/common/simple/CMakeLists.linux-aarch64.txt @@ -0,0 +1,21 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-simple) +target_link_libraries(kqp-common-simple PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + ydb-core-protos +) +target_sources(kqp-common-simple PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/helpers.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/query_id.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/settings.cpp +) diff --git a/ydb/core/kqp/common/simple/CMakeLists.linux-x86_64.txt b/ydb/core/kqp/common/simple/CMakeLists.linux-x86_64.txt new file mode 100644 index 00000000000..0c8ad81844e --- /dev/null +++ b/ydb/core/kqp/common/simple/CMakeLists.linux-x86_64.txt @@ -0,0 +1,21 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-simple) +target_link_libraries(kqp-common-simple PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + ydb-core-protos +) +target_sources(kqp-common-simple PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/helpers.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/query_id.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/settings.cpp +) diff --git a/ydb/core/kqp/common/simple/CMakeLists.txt b/ydb/core/kqp/common/simple/CMakeLists.txt new file mode 100644 index 00000000000..f8b31df0c11 --- /dev/null +++ b/ydb/core/kqp/common/simple/CMakeLists.txt @@ -0,0 +1,17 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-aarch64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin-x86_64.txt) +elseif (WIN32 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" AND NOT HAVE_CUDA) + include(CMakeLists.windows-x86_64.txt) +elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT HAVE_CUDA) + include(CMakeLists.linux-x86_64.txt) +endif() diff --git a/ydb/core/kqp/common/simple/CMakeLists.windows-x86_64.txt b/ydb/core/kqp/common/simple/CMakeLists.windows-x86_64.txt new file mode 100644 index 00000000000..28c9e36787d --- /dev/null +++ b/ydb/core/kqp/common/simple/CMakeLists.windows-x86_64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(kqp-common-simple) +target_link_libraries(kqp-common-simple PUBLIC + contrib-libs-cxxsupp + yutil + ydb-core-protos +) +target_sources(kqp-common-simple PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/helpers.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/query_id.cpp + ${CMAKE_SOURCE_DIR}/ydb/core/kqp/common/simple/settings.cpp +) diff --git a/ydb/core/kqp/common/simple/helpers.cpp b/ydb/core/kqp/common/simple/helpers.cpp new file mode 100644 index 00000000000..e9694c52de3 --- /dev/null +++ b/ydb/core/kqp/common/simple/helpers.cpp @@ -0,0 +1,23 @@ +#include "helpers.h" + +namespace NKikimr::NKqp { + +bool IsSqlQuery(const NKikimrKqp::EQueryType& queryType) { + switch (queryType) { + case NKikimrKqp::QUERY_TYPE_SQL_DML: + case NKikimrKqp::QUERY_TYPE_SQL_DDL: + case NKikimrKqp::QUERY_TYPE_SQL_SCRIPT: + case NKikimrKqp::QUERY_TYPE_SQL_SCRIPT_STREAMING: + case NKikimrKqp::QUERY_TYPE_SQL_SCAN: + case NKikimrKqp::QUERY_TYPE_SQL_QUERY: + case NKikimrKqp::QUERY_TYPE_FEDERATED_QUERY: + return true; + + default: + break; + } + + return false; +} + +} // namespace NKikimr::NKqp diff --git a/ydb/core/kqp/common/simple/helpers.h b/ydb/core/kqp/common/simple/helpers.h new file mode 100644 index 00000000000..c3e1cbcbce8 --- /dev/null +++ b/ydb/core/kqp/common/simple/helpers.h @@ -0,0 +1,14 @@ +#pragma once +#include <ydb/core/protos/kqp.pb.h> + +namespace NKikimr::NKqp { + +enum class ETableReadType { + Other = 0, + Scan = 1, + FullScan = 2, +}; + +bool IsSqlQuery(const NKikimrKqp::EQueryType& queryType); + +} // namespace NKikimr::NKqp diff --git a/ydb/core/kqp/common/simple/query_id.cpp b/ydb/core/kqp/common/simple/query_id.cpp new file mode 100644 index 00000000000..af7b3e139af --- /dev/null +++ b/ydb/core/kqp/common/simple/query_id.cpp @@ -0,0 +1,31 @@ +#include "query_id.h" +#include "helpers.h" +#include <util/generic/yexception.h> + +namespace NKikimr::NKqp { + +TKqpQueryId::TKqpQueryId(const TString& cluster, const TString& database, const TString& text, NKikimrKqp::EQueryType type) + : Cluster(cluster) + , Database(database) + , Text(text) + , QueryType(type) +{ + switch (QueryType) { + case NKikimrKqp::QUERY_TYPE_SQL_DML: + case NKikimrKqp::QUERY_TYPE_SQL_SCAN: + case NKikimrKqp::QUERY_TYPE_AST_DML: + case NKikimrKqp::QUERY_TYPE_AST_SCAN: + case NKikimrKqp::QUERY_TYPE_SQL_QUERY: + case NKikimrKqp::QUERY_TYPE_FEDERATED_QUERY: + break; + + default: + Y_ENSURE(false, "Unsupported request type"); + } +} + +bool TKqpQueryId::IsSql() const { + return IsSqlQuery(QueryType); +} + +} // namespace NKikimr::NKqp diff --git a/ydb/core/kqp/common/simple/query_id.h b/ydb/core/kqp/common/simple/query_id.h new file mode 100644 index 00000000000..d73e36d0000 --- /dev/null +++ b/ydb/core/kqp/common/simple/query_id.h @@ -0,0 +1,52 @@ +#pragma once +#include "settings.h" +#include <util/generic/string.h> +#include <ydb/core/protos/kqp.pb.h> + +namespace NKikimr::NKqp { + +struct TKqpQueryId { + TString Cluster; + TString Database; + TString UserSid; + TString Text; + TKqpQuerySettings Settings; + NKikimrKqp::EQueryType QueryType; + +public: + TKqpQueryId(const TString& cluster, const TString& database, const TString& text, NKikimrKqp::EQueryType type); + + bool IsSql() const; + + bool operator==(const TKqpQueryId& other) const { + return + Cluster == other.Cluster && + Database == other.Database && + UserSid == other.UserSid && + Text == other.Text && + Settings == other.Settings && + QueryType == other.QueryType; + } + + bool operator!=(const TKqpQueryId& other) { + return !(*this == other); + } + + bool operator<(const TKqpQueryId&) = delete; + bool operator>(const TKqpQueryId&) = delete; + bool operator<=(const TKqpQueryId&) = delete; + bool operator>=(const TKqpQueryId&) = delete; + + size_t GetHash() const noexcept { + auto tuple = std::make_tuple(Cluster, Database, UserSid, Text, Settings, QueryType); + return THash<decltype(tuple)>()(tuple); + } +}; +} // namespace NKikimr::NKqp + +template<> +struct THash<NKikimr::NKqp::TKqpQueryId> { + inline size_t operator()(const NKikimr::NKqp::TKqpQueryId& query) const { + return query.GetHash(); + } +}; diff --git a/ydb/core/kqp/common/simple/settings.cpp b/ydb/core/kqp/common/simple/settings.cpp new file mode 100644 index 00000000000..d4c971ed97d --- /dev/null +++ b/ydb/core/kqp/common/simple/settings.cpp @@ -0,0 +1,5 @@ +#include "settings.h" + +namespace NKikimr::NKqp { + +} // namespace NKikimr::NKqp diff --git a/ydb/core/kqp/common/simple/settings.h b/ydb/core/kqp/common/simple/settings.h new file mode 100644 index 00000000000..2882c736dc1 --- /dev/null +++ b/ydb/core/kqp/common/simple/settings.h @@ -0,0 +1,39 @@ +#pragma once +#include <tuple> +#include <util/str_stl.h> + +namespace NKikimr::NKqp { + +struct TKqpQuerySettings { + bool DocumentApiRestricted = true; + bool IsInternalCall = false; + + bool operator==(const TKqpQuerySettings& other) const { + return + DocumentApiRestricted == other.DocumentApiRestricted && + IsInternalCall == other.IsInternalCall; + } + + bool operator!=(const TKqpQuerySettings& other) { + return !(*this == other); + } + + bool operator<(const TKqpQuerySettings&) = delete; + bool operator>(const TKqpQuerySettings&) = delete; + bool operator<=(const TKqpQuerySettings&) = delete; + bool operator>=(const TKqpQuerySettings&) = delete; + + size_t GetHash() const noexcept { + auto tuple = std::make_tuple(DocumentApiRestricted, IsInternalCall); + return THash<decltype(tuple)>()(tuple); + } +}; + +} // namespace NKikimr::NKqp + +template<> +struct THash<NKikimr::NKqp::TKqpQuerySettings> { + inline size_t operator()(const NKikimr::NKqp::TKqpQuerySettings& settings) const { + return settings.GetHash(); + } +}; diff --git a/ydb/core/kqp/compute_actor/kqp_scan_events.h b/ydb/core/kqp/compute_actor/kqp_scan_events.h index aaa8777b125..ab0e4bc6c59 100644 --- a/ydb/core/kqp/compute_actor/kqp_scan_events.h +++ b/ydb/core/kqp/compute_actor/kqp_scan_events.h @@ -1,6 +1,7 @@ #pragma once #include "kqp_compute_events.h" #include <ydb/core/base/events.h> +#include <ydb/core/base/kikimr_issue.h> #include <ydb/core/scheme/scheme_tablecell.h> #include <ydb/library/accessor/accessor.h> #include <ydb/library/yql/public/issue/yql_issue.h> |