diff options
author | monster <[email protected]> | 2022-10-05 20:03:36 +0300 |
---|---|---|
committer | monster <[email protected]> | 2022-10-05 20:03:36 +0300 |
commit | 83a7f133568d1a836270d3452cbab8b4b890e291 (patch) | |
tree | ee9c27bd5cc371ea1f1450a427e6187b6aefaa04 | |
parent | f457f9080996d19700b93517baba2076092638c1 (diff) |
make interface headers for pg_wrapper
48 files changed, 176 insertions, 86 deletions
diff --git a/ydb/apps/ydbd/main.cpp b/ydb/apps/ydbd/main.cpp index 000130e9302..a280b024b08 100644 --- a/ydb/apps/ydbd/main.cpp +++ b/ydb/apps/ydbd/main.cpp @@ -7,7 +7,7 @@ #include <ydb/library/folder_service/mock/mock_folder_service.h> #include <ydb/library/pdisk_io/aio.h> #include <ydb/library/security/ydb_credentials_provider_factory.h> -#include <ydb/library/yql/parser/pg_wrapper/comp_factory.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h> #include <ydb/core/http_proxy/auth_factory.h> diff --git a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp index e3ed46980b0..f50af449f6b 100644 --- a/ydb/core/driver_lib/run/kikimr_services_initializers.cpp +++ b/ydb/core/driver_lib/run/kikimr_services_initializers.cpp @@ -146,7 +146,7 @@ #include <ydb/library/folder_service/proto/config.pb.h> #include <ydb/library/yql/minikql/comp_nodes/mkql_factories.h> -#include <ydb/library/yql/parser/pg_wrapper/comp_factory.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h> #include <library/cpp/actors/protos/services_common.pb.h> diff --git a/ydb/core/kqp/common/CMakeLists.txt b/ydb/core/kqp/common/CMakeLists.txt index c4926bd4b0f..5833136a2a4 100644 --- a/ydb/core/kqp/common/CMakeLists.txt +++ b/ydb/core/kqp/common/CMakeLists.txt @@ -23,6 +23,7 @@ target_link_libraries(core-kqp-common PUBLIC yql-core-issue yql-dq-actors yql-dq-common + parser-pg_wrapper-interface library-cpp-lwtrace tools-enum_parser-enum_serialization_runtime ) diff --git a/ydb/core/kqp/common/kqp_types.cpp b/ydb/core/kqp/common/kqp_types.cpp index 22aed7aa5ef..2288ca2d09b 100644 --- a/ydb/core/kqp/common/kqp_types.cpp +++ b/ydb/core/kqp/common/kqp_types.cpp @@ -1,7 +1,7 @@ #include "kqp_types.h" #include <ydb/library/yql/minikql/mkql_node_cast.h> -#include <ydb/library/yql/utils/pg_types.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/type_desc.h> namespace NKikimr::NScheme { diff --git a/ydb/core/kqp/provider/CMakeLists.txt b/ydb/core/kqp/provider/CMakeLists.txt index c4c32c34a21..fccd83767a0 100644 --- a/ydb/core/kqp/provider/CMakeLists.txt +++ b/ydb/core/kqp/provider/CMakeLists.txt @@ -29,6 +29,7 @@ target_link_libraries(core-kqp-provider PUBLIC yql-public-decimal public-lib-scheme_types yql-core-expr_nodes + parser-pg_wrapper-interface providers-common-codec providers-common-config providers-common-gateway diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp index 24e9df6fbec..d60744455b5 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway.cpp @@ -2,7 +2,7 @@ #include <ydb/library/yql/public/issue/yql_issue_message.h> #include <ydb/library/yql/providers/common/proto/gateways_config.pb.h> -#include <ydb/library/yql/utils/pg_types.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/type_desc.h> #include <ydb/library/yql/utils/yql_panic.h> #include <ydb/core/base/table_index.h> diff --git a/ydb/core/scheme/CMakeLists.txt b/ydb/core/scheme/CMakeLists.txt index 1b70a91472d..cdb6a472f67 100644 --- a/ydb/core/scheme/CMakeLists.txt +++ b/ydb/core/scheme/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(ydb-core-scheme PUBLIC ydb-core-scheme_types ydb-core-util ydb-library-aclib + parser-pg_wrapper-interface public-lib-scheme_types ) target_sources(ydb-core-scheme PRIVATE diff --git a/ydb/core/scheme/scheme_tablecell.h b/ydb/core/scheme/scheme_tablecell.h index fffd827cf77..6d91a9e251d 100644 --- a/ydb/core/scheme/scheme_tablecell.h +++ b/ydb/core/scheme/scheme_tablecell.h @@ -5,8 +5,6 @@ #include "scheme_type_order.h" #include "scheme_types_defs.h" -#include <ydb/library/yql/utils/pg_types.h> - #include <util/generic/hash.h> #include <util/system/unaligned_mem.h> diff --git a/ydb/core/scheme/scheme_type_info.cpp b/ydb/core/scheme/scheme_type_info.cpp index 4d560fdbad1..f655cd5f192 100644 --- a/ydb/core/scheme/scheme_type_info.cpp +++ b/ydb/core/scheme/scheme_type_info.cpp @@ -1,7 +1,7 @@ #include "scheme_type_info.h" #include <ydb/public/lib/scheme_types/scheme_type_id.h> -#include <ydb/library/yql/utils/pg_types.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/type_desc.h> namespace NKikimr::NScheme { diff --git a/ydb/core/scheme/scheme_types_defs.h b/ydb/core/scheme/scheme_types_defs.h index 61373b59f77..9e51f936fd9 100644 --- a/ydb/core/scheme/scheme_types_defs.h +++ b/ydb/core/scheme/scheme_types_defs.h @@ -4,7 +4,7 @@ #include <library/cpp/actors/core/actorid.h> #include <ydb/core/scheme_types/scheme_types_defs.h> -#include <ydb/library/yql/utils/pg_types.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/type_desc.h> #include <util/stream/output.h> diff --git a/ydb/library/mkql_proto/mkql_proto.cpp b/ydb/library/mkql_proto/mkql_proto.cpp index 6b9bb4b7d82..96f38a9c9a3 100644 --- a/ydb/library/mkql_proto/mkql_proto.cpp +++ b/ydb/library/mkql_proto/mkql_proto.cpp @@ -6,8 +6,8 @@ #include <ydb/library/yql/minikql/computation/mkql_computation_node_holders.h> #include <ydb/library/yql/minikql/mkql_type_ops.h> #include <ydb/library/yql/parser/pg_catalog/catalog.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/codec.h> #include <ydb/library/yql/public/decimal/yql_decimal.h> -#include <ydb/library/yql/providers/common/codec/yql_pg_codec.h> #include <library/cpp/containers/stack_vector/stack_vec.h> diff --git a/ydb/library/yql/core/type_ann/CMakeLists.txt b/ydb/library/yql/core/type_ann/CMakeLists.txt index 8decb4897b6..425c75d8407 100644 --- a/ydb/library/yql/core/type_ann/CMakeLists.txt +++ b/ydb/library/yql/core/type_ann/CMakeLists.txt @@ -24,6 +24,7 @@ target_link_libraries(yql-core-type_ann PUBLIC core-issue-protos common-schema-expr yql-parser-pg_catalog + parser-pg_wrapper-interface ) target_sources(yql-core-type_ann PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/yql/core/type_ann/type_ann_blocks.cpp diff --git a/ydb/library/yql/core/type_ann/type_ann_pg.cpp b/ydb/library/yql/core/type_ann/type_ann_pg.cpp index 7d2afa7a9e9..7772b475897 100644 --- a/ydb/library/yql/core/type_ann/type_ann_pg.cpp +++ b/ydb/library/yql/core/type_ann/type_ann_pg.cpp @@ -6,17 +6,15 @@ #include <ydb/library/yql/core/yql_expr_type_annotation.h> #include <ydb/library/yql/core/yql_expr_optimize.h> #include <ydb/library/yql/core/yql_opt_utils.h> -#include <ydb/library/yql/core/yql_pg_utils.h> #include <ydb/library/yql/core/yql_expr_csee.h> #include <ydb/library/yql/parser/pg_catalog/catalog.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/utils.h> #include <util/generic/set.h> namespace NYql { -bool ParsePgIntervalModifier(const TString& str, i32& ret); - namespace NTypeAnnImpl { bool ValidateInputTypes(const TExprNode& node, TExprContext& ctx) { diff --git a/ydb/library/yql/core/yql_expr_type_annotation.cpp b/ydb/library/yql/core/yql_expr_type_annotation.cpp index fe17854c998..2f97607cf1d 100644 --- a/ydb/library/yql/core/yql_expr_type_annotation.cpp +++ b/ydb/library/yql/core/yql_expr_type_annotation.cpp @@ -3,12 +3,12 @@ #include "yql_opt_rewrite_io.h" #include "yql_opt_utils.h" #include "yql_expr_optimize.h" -#include "yql_pg_utils.h" #include <ydb/library/yql/public/udf/udf_data_type.h> #include <ydb/library/yql/minikql/dom/json.h> #include <ydb/library/yql/minikql/dom/yson.h> #include <ydb/library/yql/core/sql_types/simple_types.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/utils.h> #include <ydb/library/yql/public/decimal/yql_decimal.h> #include <ydb/library/yql/utils/yql_panic.h> #include <ydb/library/yql/utils/utf8.h> diff --git a/ydb/library/yql/minikql/CMakeLists.txt b/ydb/library/yql/minikql/CMakeLists.txt index 3bcf235e56a..d3aab5921b0 100644 --- a/ydb/library/yql/minikql/CMakeLists.txt +++ b/ydb/library/yql/minikql/CMakeLists.txt @@ -37,6 +37,7 @@ target_link_libraries(library-yql-minikql PUBLIC ydb-library-dynumber yql-minikql-dom yql-parser-pg_catalog + parser-pg_wrapper-interface yql-public-udf public-udf-tz library-yql-utils diff --git a/ydb/library/yql/minikql/comp_nodes/CMakeLists.txt b/ydb/library/yql/minikql/comp_nodes/CMakeLists.txt index 9a8ecbcd28f..45965024fa3 100644 --- a/ydb/library/yql/minikql/comp_nodes/CMakeLists.txt +++ b/ydb/library/yql/minikql/comp_nodes/CMakeLists.txt @@ -20,6 +20,7 @@ target_link_libraries(yql-minikql-comp_nodes PUBLIC library-yql-minikql yql-minikql-arrow yql-minikql-invoke_builtins + parser-pg_wrapper-interface library-yql-utils yql-minikql-codegen llvm12-lib-IR diff --git a/ydb/library/yql/minikql/comp_nodes/mkql_withcontext.cpp b/ydb/library/yql/minikql/comp_nodes/mkql_withcontext.cpp index c70132c1e51..95067dc099c 100644 --- a/ydb/library/yql/minikql/comp_nodes/mkql_withcontext.cpp +++ b/ydb/library/yql/minikql/comp_nodes/mkql_withcontext.cpp @@ -2,8 +2,8 @@ #include <ydb/library/yql/minikql/mkql_node_cast.h> #include <ydb/library/yql/minikql/computation/mkql_computation_node_codegen.h> -#include <ydb/library/yql/minikql/computation/mkql_computation_pg.h> #include <ydb/library/yql/minikql/computation/mkql_computation_node_holders.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/context.h> #include <util/generic/scope.h> diff --git a/ydb/library/yql/minikql/computation/CMakeLists.txt b/ydb/library/yql/minikql/computation/CMakeLists.txt index bcfbf8618e0..a1a1ffe3398 100644 --- a/ydb/library/yql/minikql/computation/CMakeLists.txt +++ b/ydb/library/yql/minikql/computation/CMakeLists.txt @@ -22,6 +22,7 @@ target_link_libraries(yql-minikql-computation PUBLIC library-cpp-time_provider library-yql-minikql yql-minikql-arrow + parser-pg_wrapper-interface yql-public-udf library-yql-utils yql-minikql-codegen @@ -63,6 +64,7 @@ target_link_libraries(yql-minikql-computation.global PUBLIC library-cpp-time_provider library-yql-minikql yql-minikql-arrow + parser-pg_wrapper-interface yql-public-udf library-yql-utils yql-minikql-codegen diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp b/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp index a40427ac049..154dd225dfe 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_pack.cpp @@ -3,6 +3,7 @@ #include "mkql_computation_node_holders.h" #include "presort.h" +#include <ydb/library/yql/parser/pg_wrapper/interface/pack.h> #include <ydb/library/yql/public/decimal/yql_decimal.h> #include <ydb/library/yql/public/decimal/yql_decimal_serialize.h> #include <ydb/library/yql/minikql/defs.h> diff --git a/ydb/library/yql/minikql/computation/mkql_computation_node_pack_impl.h b/ydb/library/yql/minikql/computation/mkql_computation_node_pack_impl.h index de6311e5f9f..c47e4b574f2 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_node_pack_impl.h +++ b/ydb/library/yql/minikql/computation/mkql_computation_node_pack_impl.h @@ -97,8 +97,5 @@ T GetRawData(TStringBuf& buf) { } // NDetails -void PGPackImpl(bool stable, const TPgType* type, const NUdf::TUnboxedValuePod& value, TBuffer& buf); -NUdf::TUnboxedValue PGUnpackImpl(const TPgType* type, TStringBuf& buf); - } } diff --git a/ydb/library/yql/minikql/computation/mkql_value_builder.cpp b/ydb/library/yql/minikql/computation/mkql_value_builder.cpp index ad83f23b661..e979b4a05e7 100644 --- a/ydb/library/yql/minikql/computation/mkql_value_builder.cpp +++ b/ydb/library/yql/minikql/computation/mkql_value_builder.cpp @@ -4,6 +4,7 @@ #include <ydb/library/yql/minikql/mkql_node_cast.h> #include <ydb/library/yql/minikql/mkql_string_util.h> #include <ydb/library/yql/minikql/mkql_type_builder.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/utils.h> #include <library/cpp/yson/node/node_io.h> #include <arrow/array/array_base.h> @@ -12,10 +13,6 @@ #include <util/system/env.h> -namespace NYql { - std::unique_ptr<NUdf::IPgBuilder> CreatePgBuilder(); -} - namespace NKikimr { namespace NMiniKQL { diff --git a/ydb/library/yql/minikql/computation/presort.cpp b/ydb/library/yql/minikql/computation/presort.cpp index b5f93d1fead..9f18fe8c7fd 100644 --- a/ydb/library/yql/minikql/computation/presort.cpp +++ b/ydb/library/yql/minikql/computation/presort.cpp @@ -5,6 +5,7 @@ #include <ydb/library/yql/minikql/mkql_string_util.h> #include <ydb/library/yql/utils/swap_bytes.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/pack.h> #include <ydb/library/yql/public/decimal/yql_decimal_serialize.h> #include <util/system/unaligned_mem.h> diff --git a/ydb/library/yql/minikql/computation/presort_impl.h b/ydb/library/yql/minikql/computation/presort_impl.h index 5729cf3d246..7715e7a2f97 100644 --- a/ydb/library/yql/minikql/computation/presort_impl.h +++ b/ydb/library/yql/minikql/computation/presort_impl.h @@ -258,8 +258,5 @@ namespace NDetail { } } -void EncodePresortPGValue(TPgType* type, const NUdf::TUnboxedValue& value, TVector<ui8>& output); -NUdf::TUnboxedValue DecodePresortPGValue(TPgType* type, TStringBuf& input, TVector<ui8>& buffer); - } // NMiniKQL } // NKikimr diff --git a/ydb/library/yql/minikql/mkql_alloc.h b/ydb/library/yql/minikql/mkql_alloc.h index 7df4adc3e95..e71da4e7889 100644 --- a/ydb/library/yql/minikql/mkql_alloc.h +++ b/ydb/library/yql/minikql/mkql_alloc.h @@ -1,6 +1,7 @@ #pragma once #include "aligned_page_pool.h" #include "mkql_mem_info.h" +#include <ydb/library/yql/parser/pg_wrapper/interface/context.h> #include <ydb/library/yql/public/udf/udf_allocator.h> #include <ydb/library/yql/public/udf/udf_value.h> #include <util/system/defaults.h> @@ -75,11 +76,6 @@ struct TAllocState : public TAlignedPagePool extern Y_POD_THREAD(TAllocState*) TlsAllocState; -void* PgInitializeMainContext(); -void PgDestroyMainContext(void* ctx); -void PgAcquireThreadContext(void* ctx); -void PgReleaseThreadContext(void* ctx); - class TPAllocScope { public: TPAllocScope() { diff --git a/ydb/library/yql/minikql/mkql_type_builder.h b/ydb/library/yql/minikql/mkql_type_builder.h index 54aabcb5071..9cc4ea126ef 100644 --- a/ydb/library/yql/minikql/mkql_type_builder.h +++ b/ydb/library/yql/minikql/mkql_type_builder.h @@ -3,6 +3,7 @@ #include "mkql_node.h" #include <ydb/library/yql/public/udf/udf_type_builder.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/compare.h> #include <arrow/datum.h> @@ -195,9 +196,5 @@ NUdf::IHash::TPtr MakeHashImpl(const NMiniKQL::TType* type); NUdf::ICompare::TPtr MakeCompareImpl(const NMiniKQL::TType* type); NUdf::IEquate::TPtr MakeEquateImpl(const NMiniKQL::TType* type); -NUdf::IHash::TPtr MakePgHash(const NMiniKQL::TPgType* type); -NUdf::ICompare::TPtr MakePgCompare(const NMiniKQL::TPgType* type); -NUdf::IEquate::TPtr MakePgEquate(const NMiniKQL::TPgType* type); - } // namespace NMiniKQL } // namespace Nkikimr diff --git a/ydb/library/yql/parser/pg_wrapper/CMakeLists.txt b/ydb/library/yql/parser/pg_wrapper/CMakeLists.txt index d451e5cdbb8..20acb5e33be 100644 --- a/ydb/library/yql/parser/pg_wrapper/CMakeLists.txt +++ b/ydb/library/yql/parser/pg_wrapper/CMakeLists.txt @@ -8,6 +8,7 @@ find_package(Iconv REQUIRED) find_package(OpenSSL REQUIRED) +add_subdirectory(interface) add_subdirectory(ut) add_library(yql-parser-pg_wrapper) diff --git a/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp b/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp index 9376ec2ac70..51dd709da7d 100644 --- a/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp +++ b/ydb/library/yql/parser/pg_wrapper/comp_factory.cpp @@ -1,4 +1,4 @@ -#include "comp_factory.h" +#include <ydb/library/yql/parser/pg_wrapper/interface/interface.h> #include <ydb/library/yql/minikql/computation/mkql_computation_node_impl.h> #include <ydb/library/yql/minikql/computation/mkql_computation_node_holders.h> #include <ydb/library/yql/minikql/computation/mkql_computation_node_pack_impl.h> @@ -9,10 +9,10 @@ #include <ydb/library/yql/minikql/mkql_node_builder.h> #include <ydb/library/yql/minikql/mkql_string_util.h> #include <ydb/library/yql/minikql/mkql_type_builder.h> -#include <ydb/library/yql/providers/common/codec/yql_pg_codec.h> #include <ydb/library/yql/parser/pg_catalog/catalog.h> +#include <ydb/library/yql/providers/common/codec/yql_codec_buf.h> +#include <ydb/library/yql/providers/common/codec/yql_codec_results.h> #include <ydb/library/yql/public/udf/udf_value_builder.h> -#include <ydb/library/yql/core/yql_pg_utils.h> #include <ydb/library/yql/utils/fp_bits.h> #include <library/cpp/yson/detail.h> @@ -2586,7 +2586,7 @@ class TPgHash : public NUdf::IHash { public: TPgHash(const NMiniKQL::TPgType* type) : Type(type) - , TypeDesc(NPg::LookupType(type->GetTypeId())) + , TypeDesc(NYql::NPg::LookupType(type->GetTypeId())) { Y_ENSURE(TypeDesc.HashProcId); @@ -2619,7 +2619,7 @@ public: private: const NMiniKQL::TPgType* Type; - const NPg::TTypeDesc TypeDesc; + const NYql::NPg::TTypeDesc TypeDesc; FmgrInfo FInfoHash; }; @@ -2632,7 +2632,7 @@ class TPgCompare : public NUdf::ICompare { public: TPgCompare(const NMiniKQL::TPgType* type) : Type(type) - , TypeDesc(NPg::LookupType(type->GetTypeId())) + , TypeDesc(NYql::NPg::LookupType(type->GetTypeId())) { Y_ENSURE(TypeDesc.LessProcId); Y_ENSURE(TypeDesc.CompareProcId); @@ -2714,7 +2714,7 @@ public: private: const NMiniKQL::TPgType* Type; - const NPg::TTypeDesc TypeDesc; + const NYql::NPg::TTypeDesc TypeDesc; FmgrInfo FInfoLess, FInfoCompare; }; @@ -2727,7 +2727,7 @@ class TPgEquate: public NUdf::IEquate { public: TPgEquate(const NMiniKQL::TPgType* type) : Type(type) - , TypeDesc(NPg::LookupType(type->GetTypeId())) + , TypeDesc(NYql::NPg::LookupType(type->GetTypeId())) { Y_ENSURE(TypeDesc.EqualProcId); @@ -2771,7 +2771,7 @@ public: private: const NMiniKQL::TPgType* Type; - const NPg::TTypeDesc TypeDesc; + const NYql::NPg::TTypeDesc TypeDesc; FmgrInfo FInfoEquate; }; diff --git a/ydb/library/yql/parser/pg_wrapper/comp_factory.h b/ydb/library/yql/parser/pg_wrapper/comp_factory.h deleted file mode 100644 index 8e17a3134b0..00000000000 --- a/ydb/library/yql/parser/pg_wrapper/comp_factory.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include <ydb/library/yql/minikql/computation/mkql_computation_node.h> - -namespace NYql { - -NKikimr::NMiniKQL::TComputationNodeFactory GetPgFactory(); - -} diff --git a/ydb/library/yql/parser/pg_wrapper/interface/CMakeLists.txt b/ydb/library/yql/parser/pg_wrapper/interface/CMakeLists.txt new file mode 100644 index 00000000000..f4a9b258c09 --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/CMakeLists.txt @@ -0,0 +1,22 @@ + +# This file was gererated 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(parser-pg_wrapper-interface) +target_compile_options(parser-pg_wrapper-interface PRIVATE + -DUSE_CURRENT_UDF_ABI_VERSION +) +target_link_libraries(parser-pg_wrapper-interface PUBLIC + contrib-libs-cxxsupp + yutil + library-yql-ast + yql-public-udf +) +target_sources(parser-pg_wrapper-interface PRIVATE + ${CMAKE_SOURCE_DIR}/ydb/library/yql/parser/pg_wrapper/interface/interface.cpp +) diff --git a/ydb/library/yql/providers/common/codec/yql_pg_codec.h b/ydb/library/yql/parser/pg_wrapper/interface/codec.h index a943fbe0b61..8b8e1509427 100644 --- a/ydb/library/yql/providers/common/codec/yql_pg_codec.h +++ b/ydb/library/yql/parser/pg_wrapper/interface/codec.h @@ -1,17 +1,25 @@ #pragma once -#include <library/cpp/yson/public.h> #include <ydb/library/yql/public/udf/udf_value.h> -#include <ydb/library/yql/minikql/mkql_node.h> -#include <util/generic/vector.h> +#include <util/generic/strbuf.h> +#include <util/generic/string.h> -#include "yql_codec_results.h" -#include "yql_codec_buf.h" +namespace NKikimr { +namespace NMiniKQL { + +class TPgType; + +} // NMiniKQL +} // NKikimr namespace NYql { namespace NCommon { +class TInputBuf; +class TOutputBuf; +class TYsonResultWriter; + TString PgValueToString(const NUdf::TUnboxedValuePod& value, ui32 pgTypeId); NUdf::TUnboxedValue PgValueFromString(const TStringBuf text, ui32 pgTypeId); @@ -29,8 +37,11 @@ void WriteYsonValueInTableFormatPg(TOutputBuf& buf, NKikimr::NMiniKQL::TPgType* NUdf::TUnboxedValue ReadYsonValueInTableFormatPg(NKikimr::NMiniKQL::TPgType* type, char cmd, TInputBuf& buf); NUdf::TUnboxedValue ReadYsonValuePg(NKikimr::NMiniKQL::TPgType* type, char cmd, TInputBuf& buf); -extern "C" void ReadSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, NKikimr::NUdf::TUnboxedValue& value, NCommon::TInputBuf& buf); -extern "C" void WriteSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf); +NKikimr::NUdf::TUnboxedValue ReadSkiffPg(NKikimr::NMiniKQL::TPgType* type, TInputBuf& buf); +void WriteSkiffPg(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, TOutputBuf& buf); + +extern "C" void ReadSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, NKikimr::NUdf::TUnboxedValue& value, TInputBuf& buf); +extern "C" void WriteSkiffPgValue(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, TOutputBuf& buf); } // namespace NCommon } // namespace NYql diff --git a/ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h b/ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h new file mode 100644 index 00000000000..e969c6e1c69 --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h @@ -0,0 +1,20 @@ +#pragma once + +#include <functional> + +namespace NKikimr { +namespace NMiniKQL { + +class IComputationNode; +class TCallable; +struct TComputationNodeFactoryContext; + +} // NMiniKQL +} // NKikimr + +namespace NYql { + +std::function<NKikimr::NMiniKQL::IComputationNode* (NKikimr::NMiniKQL::TCallable&, + const NKikimr::NMiniKQL::TComputationNodeFactoryContext&)> GetPgFactory(); + +} // NYql diff --git a/ydb/library/yql/parser/pg_wrapper/interface/compare.h b/ydb/library/yql/parser/pg_wrapper/interface/compare.h new file mode 100644 index 00000000000..4b7eb15ef1a --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/compare.h @@ -0,0 +1,15 @@ +#pragma once + +#include <ydb/library/yql/public/udf/udf_type_builder.h> + +namespace NKikimr { +namespace NMiniKQL { + +class TPgType; + +NUdf::IHash::TPtr MakePgHash(const TPgType* type); +NUdf::ICompare::TPtr MakePgCompare(const TPgType* type); +NUdf::IEquate::TPtr MakePgEquate(const TPgType* type); + +} // namespace NMiniKQL +} // namespace NKikimr diff --git a/ydb/library/yql/minikql/computation/mkql_computation_pg.h b/ydb/library/yql/parser/pg_wrapper/interface/context.h index fbb4ae7302a..7cde36b3baa 100644 --- a/ydb/library/yql/minikql/computation/mkql_computation_pg.h +++ b/ydb/library/yql/parser/pg_wrapper/interface/context.h @@ -1,11 +1,18 @@ #pragma once + #include <string_view> namespace NKikimr { namespace NMiniKQL { +void* PgInitializeMainContext(); +void PgDestroyMainContext(void* ctx); + +void PgAcquireThreadContext(void* ctx); +void PgReleaseThreadContext(void* ctx); + void* PgInitializeContext(const std::string_view& contextType); void PgDestroyContext(const std::string_view& contextType, void* ctx); -} // namespace MiniKQL +} // namespace NMiniKQL } // namespace NKikimr diff --git a/ydb/library/yql/parser/pg_wrapper/interface/interface.cpp b/ydb/library/yql/parser/pg_wrapper/interface/interface.cpp new file mode 100644 index 00000000000..f9c711d00c3 --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/interface.cpp @@ -0,0 +1 @@ +#include "interface.h" diff --git a/ydb/library/yql/parser/pg_wrapper/interface/interface.h b/ydb/library/yql/parser/pg_wrapper/interface/interface.h new file mode 100644 index 00000000000..7f5ed658eec --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/interface.h @@ -0,0 +1,10 @@ +#pragma once + +#include "codec.h" +#include "compare.h" +#include "comp_factory.h" +#include "context.h" +#include "pack.h" +#include "parser.h" +#include "type_desc.h" +#include "utils.h" diff --git a/ydb/library/yql/parser/pg_wrapper/interface/pack.h b/ydb/library/yql/parser/pg_wrapper/interface/pack.h new file mode 100644 index 00000000000..0a66c7fbb29 --- /dev/null +++ b/ydb/library/yql/parser/pg_wrapper/interface/pack.h @@ -0,0 +1,21 @@ +#pragma once + +#include <ydb/library/yql/public/udf/udf_value.h> + +#include <util/generic/buffer.h> +#include <util/generic/strbuf.h> +#include <util/generic/vector.h> + +namespace NKikimr { +namespace NMiniKQL { + +class TPgType; + +void PGPackImpl(bool stable, const TPgType* type, const NUdf::TUnboxedValuePod& value, TBuffer& buf); +NUdf::TUnboxedValue PGUnpackImpl(const TPgType* type, TStringBuf& buf); + +void EncodePresortPGValue(TPgType* type, const NUdf::TUnboxedValue& value, TVector<ui8>& output); +NUdf::TUnboxedValue DecodePresortPGValue(TPgType* type, TStringBuf& input, TVector<ui8>& buffer); + +} // namespace NMiniKQL +} // namespace NKikimr diff --git a/ydb/library/yql/sql/pg_sql.h b/ydb/library/yql/parser/pg_wrapper/interface/parser.h index c27ff312482..d481820e7ef 100644 --- a/ydb/library/yql/sql/pg_sql.h +++ b/ydb/library/yql/parser/pg_wrapper/interface/parser.h @@ -1,9 +1,15 @@ #pragma once + #include <ydb/library/yql/ast/yql_ast.h> -#include <ydb/library/yql/sql/settings/translation_settings.h> + +namespace NSQLTranslation { + +struct TTranslationSettings; + +} // NSQLTranslation namespace NSQLTranslationPG { NYql::TAstParseResult PGToYql(const TString& query, const NSQLTranslation::TTranslationSettings& settings); -} // NSQLTranslationPG +} // NSQLTranslationPG diff --git a/ydb/library/yql/utils/pg_types.h b/ydb/library/yql/parser/pg_wrapper/interface/type_desc.h index a043aca4ec9..533db3b90b2 100644 --- a/ydb/library/yql/utils/pg_types.h +++ b/ydb/library/yql/parser/pg_wrapper/interface/type_desc.h @@ -13,8 +13,7 @@ void* TypeDescFromPgTypeName(const TStringBuf name); bool TypeDescIsComparable(void* typeDesc); ui32 TypeDescGetTypeLen(void* typeDesc); -int PgNativeBinaryCompare(const char* dataL, size_t sizeL, - const char* dataR, size_t sizeR, void* typeDesc); +int PgNativeBinaryCompare(const char* dataL, size_t sizeL, const char* dataR, size_t sizeR, void* typeDesc); ui64 PgNativeBinaryHash(const char* data, size_t size, void* typeDesc); diff --git a/ydb/library/yql/core/yql_pg_utils.h b/ydb/library/yql/parser/pg_wrapper/interface/utils.h index 5df3aeba510..e0e98542f29 100644 --- a/ydb/library/yql/core/yql_pg_utils.h +++ b/ydb/library/yql/parser/pg_wrapper/interface/utils.h @@ -1,5 +1,8 @@ #pragma once + #include <ydb/library/yql/public/udf/udf_data_type.h> +#include <ydb/library/yql/public/udf/udf_value_builder.h> + #include <util/generic/maybe.h> namespace NYql { @@ -7,4 +10,8 @@ namespace NYql { TMaybe<ui32> ConvertToPgType(NKikimr::NUdf::EDataSlot slot); TMaybe<NKikimr::NUdf::EDataSlot> ConvertFromPgType(ui32 typeId); -} +bool ParsePgIntervalModifier(const TString& str, i32& ret); + +std::unique_ptr<NUdf::IPgBuilder> CreatePgBuilder(); + +} // NYql diff --git a/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp b/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp index da6e2ab9bca..04f812ef166 100644 --- a/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp +++ b/ydb/library/yql/parser/pg_wrapper/ut/sort_ut.cpp @@ -6,7 +6,7 @@ #include <ydb/library/yql/minikql/mkql_program_builder.h> #include <ydb/library/yql/minikql/mkql_string_util.h> #include <ydb/library/yql/parser/pg_catalog/catalog.h> -#include <ydb/library/yql/parser/pg_wrapper/comp_factory.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/comp_factory.h> #include <ydb/library/yql/minikql/comp_nodes/ut/mkql_computation_node_ut.h> diff --git a/ydb/library/yql/providers/common/codec/CMakeLists.txt b/ydb/library/yql/providers/common/codec/CMakeLists.txt index 8c90e40f97e..23a543d2146 100644 --- a/ydb/library/yql/providers/common/codec/CMakeLists.txt +++ b/ydb/library/yql/providers/common/codec/CMakeLists.txt @@ -17,6 +17,7 @@ target_link_libraries(providers-common-codec PUBLIC yutil library-yql-minikql yql-minikql-computation + parser-pg_wrapper-interface providers-common-mkql cpp-yson-node library-cpp-yson diff --git a/ydb/library/yql/providers/common/codec/yql_codec.cpp b/ydb/library/yql/providers/common/codec/yql_codec.cpp index 3dd18b34012..8523974efb2 100644 --- a/ydb/library/yql/providers/common/codec/yql_codec.cpp +++ b/ydb/library/yql/providers/common/codec/yql_codec.cpp @@ -1,4 +1,3 @@ -#include "yql_pg_codec.h" #include "yql_codec.h" #include "yql_restricted_yson.h" #include "yql_codec_type_flags.h" diff --git a/ydb/library/yql/providers/common/codec/yql_codec.h b/ydb/library/yql/providers/common/codec/yql_codec.h index 59718c14153..39a95196c3c 100644 --- a/ydb/library/yql/providers/common/codec/yql_codec.h +++ b/ydb/library/yql/providers/common/codec/yql_codec.h @@ -6,6 +6,7 @@ #include <ydb/library/yql/minikql/mkql_function_registry.h> #include <ydb/library/yql/minikql/mkql_program_builder.h> #include <ydb/library/yql/minikql/computation/mkql_computation_node_holders.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/codec.h> #include <ydb/library/yql/ast/yql_expr.h> #include <util/generic/strbuf.h> @@ -80,7 +81,6 @@ NKikimr::NUdf::TUnboxedValue ReadSkiffNativeYtValue(NKikimr::NMiniKQL::TType* ty const NKikimr::NMiniKQL::THolderFactory& holderFactory, TInputBuf& buf); NKikimr::NUdf::TUnboxedValue ReadSkiffData(NKikimr::NMiniKQL::TType* type, ui64 nativeYtTypeFlags, NCommon::TInputBuf& buf); -NKikimr::NUdf::TUnboxedValue ReadSkiffPg(NKikimr::NMiniKQL::TPgType* type, NCommon::TInputBuf& buf); extern "C" void ReadContainerNativeYtValue(NKikimr::NMiniKQL::TType* type, ui64 nativeYtTypeFlags, const NKikimr::NMiniKQL::THolderFactory& holderFactory, NKikimr::NUdf::TUnboxedValue& value, NCommon::TInputBuf& buf, bool wrapOptional); @@ -89,7 +89,6 @@ extern "C" void WriteYsonContainerValue(NKikimr::NMiniKQL::TType* type, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf); void WriteSkiffData(NKikimr::NMiniKQL::TType* type, ui64 nativeYtTypeFlags, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf); -void WriteSkiffPg(NKikimr::NMiniKQL::TPgType* type, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf); void WriteSkiffNativeYtValue(NKikimr::NMiniKQL::TType* type, ui64 nativeYtTypeFlags, const NKikimr::NUdf::TUnboxedValuePod& value, NCommon::TOutputBuf& buf); diff --git a/ydb/library/yql/sql/CMakeLists.txt b/ydb/library/yql/sql/CMakeLists.txt index 56188ec324d..60c0205ab89 100644 --- a/ydb/library/yql/sql/CMakeLists.txt +++ b/ydb/library/yql/sql/CMakeLists.txt @@ -17,6 +17,7 @@ target_link_libraries(library-yql-sql PUBLIC contrib-libs-cxxsupp yutil cpp-deprecated-split + parser-pg_wrapper-interface yql-sql-settings yql-sql-v0 sql-v0-lexer diff --git a/ydb/library/yql/sql/pg/pg_sql.cpp b/ydb/library/yql/sql/pg/pg_sql.cpp index 1766600b424..e8b3d29ae99 100644 --- a/ydb/library/yql/sql/pg/pg_sql.cpp +++ b/ydb/library/yql/sql/pg/pg_sql.cpp @@ -1,5 +1,5 @@ -#include <ydb/library/yql/sql/pg_sql.h> #include <ydb/library/yql/sql/settings/partitioning.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/parser.h> #include <ydb/library/yql/parser/pg_wrapper/parser.h> #include <ydb/library/yql/providers/common/provider/yql_provider_names.h> #include <ydb/library/yql/core/yql_callable_names.h> diff --git a/ydb/library/yql/sql/pg_dummy/CMakeLists.txt b/ydb/library/yql/sql/pg_dummy/CMakeLists.txt index e8f7d109a06..a54584f18bb 100644 --- a/ydb/library/yql/sql/pg_dummy/CMakeLists.txt +++ b/ydb/library/yql/sql/pg_dummy/CMakeLists.txt @@ -14,13 +14,7 @@ target_compile_options(yql-sql-pg_dummy PRIVATE target_link_libraries(yql-sql-pg_dummy PUBLIC contrib-libs-cxxsupp yutil - library-yql-ast - library-yql-core - library-yql-minikql - yql-minikql-computation - providers-common-codec - yql-public-udf - yql-sql-settings + parser-pg_wrapper-interface ) target_sources(yql-sql-pg_dummy PRIVATE ${CMAKE_SOURCE_DIR}/ydb/library/yql/sql/pg_dummy/pg_sql_dummy.cpp diff --git a/ydb/library/yql/sql/pg_dummy/pg_sql_dummy.cpp b/ydb/library/yql/sql/pg_dummy/pg_sql_dummy.cpp index 999902d3269..2bf416fbc5f 100644 --- a/ydb/library/yql/sql/pg_dummy/pg_sql_dummy.cpp +++ b/ydb/library/yql/sql/pg_dummy/pg_sql_dummy.cpp @@ -1,11 +1,4 @@ -#include <ydb/library/yql/sql/pg_sql.h> -#include <ydb/library/yql/providers/common/codec/yql_pg_codec.h> -#include <ydb/library/yql/minikql/computation/mkql_computation_node.h> -#include <ydb/library/yql/minikql/computation/mkql_computation_node_pack_impl.h> -#include <ydb/library/yql/minikql/computation/presort_impl.h> -#include <ydb/library/yql/core/yql_pg_utils.h> -#include <ydb/library/yql/minikql/mkql_type_builder.h> -#include <ydb/library/yql/public/udf/udf_value_builder.h> +#include <ydb/library/yql/parser/pg_wrapper/interface/interface.h> namespace NSQLTranslationPG { @@ -253,7 +246,9 @@ std::unique_ptr<NUdf::IPgBuilder> CreatePgBuilder() { return std::make_unique<TPgDummyBuilder>(); } -NKikimr::NMiniKQL::TComputationNodeFactory GetPgFactory() { +std::function<NKikimr::NMiniKQL::IComputationNode* (NKikimr::NMiniKQL::TCallable&, + const NKikimr::NMiniKQL::TComputationNodeFactoryContext&)> GetPgFactory() +{ return {}; } diff --git a/ydb/library/yql/sql/sql.cpp b/ydb/library/yql/sql/sql.cpp index 79b62215b34..620436cabcc 100644 --- a/ydb/library/yql/sql/sql.cpp +++ b/ydb/library/yql/sql/sql.cpp @@ -6,7 +6,7 @@ #include <ydb/library/yql/sql/v1/sql.h> #include <ydb/library/yql/sql/v1/lexer/lexer.h> #include <ydb/library/yql/sql/v1/proto_parser/proto_parser.h> -#include "pg_sql.h" +#include <ydb/library/yql/parser/pg_wrapper/interface/parser.h> #include <google/protobuf/arena.h> |