diff options
author | Vitalii Gridnev <gridnevvvit@gmail.com> | 2024-10-20 00:43:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-20 00:43:29 +0300 |
commit | 0e3eafc633fdd3f1386f1586faa81195df48b340 (patch) | |
tree | 5b3eaaf146952e58ae3987987a29c0d28ff76e33 | |
parent | e0b481c6710337ae655271bbb80afe6ac81a5614 (diff) | |
download | ydb-0e3eafc633fdd3f1386f1586faa81195df48b340.tar.gz |
remove deprecated & unused result lib (#10641)
-rw-r--r-- | ydb/core/client/minikql_result_lib/converter.cpp | 14 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/converter.h | 29 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/converter_ut.cpp | 70 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/data_funcs.inl | 120 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/list_funcs.inl | 81 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/objects.cpp | 6 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/objects.h | 318 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/objects_ut.cpp | 158 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/optional_funcs.inl | 49 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/struct_funcs.inl | 48 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/tuple_funcs.inl | 48 | ||||
-rw-r--r-- | ydb/core/client/minikql_result_lib/ya.make | 22 | ||||
-rw-r--r-- | ydb/core/client/ya.make | 5 | ||||
-rw-r--r-- | ydb/core/kqp/provider/ut/ya.make | 1 | ||||
-rw-r--r-- | ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp | 2 |
15 files changed, 0 insertions, 971 deletions
diff --git a/ydb/core/client/minikql_result_lib/converter.cpp b/ydb/core/client/minikql_result_lib/converter.cpp deleted file mode 100644 index bfb1ea6db3..0000000000 --- a/ydb/core/client/minikql_result_lib/converter.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "converter.h" - -#include <ydb/library/mkql_proto/protos/minikql.pb.h> - - -namespace NKikimr { -namespace NResultLib { - -TStruct ConvertResult(const NKikimrMiniKQL::TValue& value, const NKikimrMiniKQL::TType& type) { - return TStruct(value, type); -} - -} // namespace NResultLib -} // namespace NKikimr diff --git a/ydb/core/client/minikql_result_lib/converter.h b/ydb/core/client/minikql_result_lib/converter.h deleted file mode 100644 index d1b2b70a10..0000000000 --- a/ydb/core/client/minikql_result_lib/converter.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include "objects.h" - -#include <ydb/public/lib/deprecated/kicli/kicli.h> - - -namespace NKikimrMiniKQL { -class TValue; -class TType; -} // namespace NKikimrMiniKQL - - -namespace NKikimr { -namespace NResultLib { - -TStruct ConvertResult(const NKikimrMiniKQL::TValue& value, const NKikimrMiniKQL::TType& type); - -// convert C++ API result -inline TStruct ConvertResult(const NKikimr::NClient::TQueryResult& apiResult) { - const NKikimrClient::TResponse& response = apiResult.GetResult<NKikimrClient::TResponse>(); - Y_ABORT_UNLESS(response.HasExecutionEngineEvaluatedResponse()); - const auto& result = response.GetExecutionEngineEvaluatedResponse(); - // TODO: type caching - return ConvertResult(result.GetValue(), result.GetType()); -} - -} // namespace NResultLib -} // namespace NKikimr diff --git a/ydb/core/client/minikql_result_lib/converter_ut.cpp b/ydb/core/client/minikql_result_lib/converter_ut.cpp deleted file mode 100644 index 0fb5eff621..0000000000 --- a/ydb/core/client/minikql_result_lib/converter_ut.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "converter.h" - -#include <ydb/core/testlib/test_client.h> - -#include <library/cpp/testing/unittest/tests_data.h> -#include <library/cpp/testing/unittest/registar.h> - - -namespace NKikimr { - -using namespace NResultLib; - -Y_UNIT_TEST_SUITE(TMiniKQLResultConverterTest) { - -Y_UNIT_TEST(TTestWithSimpleProgram) { - TPortManager pm; - ui16 port = pm.GetPort(2134); - auto settings = Tests::TServerSettings(port); - Tests::TServer server = Tests::TServer(settings); - Tests::TClient client(settings); - client.InitRootScheme(); - - const TString pgmText = R"___( -( -(let list (AsList (Uint32 '20) (Uint32 '10) (Uint32 '0))) -(let opt (Just (String 'i_am_opt))) -(let tuple '((Double '12) (Float '22))) -(return (AsList - (SetResult 'list list) - (SetResult 'opt opt) - (SetResult 'emptyOpt (Nothing (OptionalType (DataType 'Int32)))) - (SetResult 'tuple tuple) -)) -) -)___"; - - NKikimrMiniKQL::TResult result; - UNIT_ASSERT(client.FlatQuery(pgmText, result)); - - TStruct s = ConvertResult(result.GetValue(), result.GetType()); - { - TListType l = s.GetMember<TOptional>("list").GetItem<TListType>(); - TVector<ui32> v; - for (ui32 item : l.MakeIterable<ui32>()) { - v.push_back(item); - } - UNIT_ASSERT_EQUAL(v.size(), 3); - UNIT_ASSERT_EQUAL(v[0], 20); - UNIT_ASSERT_EQUAL(v[1], 10); - UNIT_ASSERT_EQUAL(v[2], 0); - } - { - TOptional opt = s.GetMember<TOptional>("opt").GetItem<TOptional>(); - UNIT_ASSERT_EQUAL(opt.GetItem<TStringBuf>(), "i_am_opt"); - } - { - TOptional opt = s.GetMember<TOptional>("emptyOpt").GetItem<TOptional>(); - UNIT_ASSERT(!opt.HasItem()); - } - { - TTuple tuple = s.GetMember<TOptional>("tuple").GetItem<TTuple>(); - UNIT_ASSERT_DOUBLES_EQUAL(tuple.GetElement<double>(0), 12.0, 1e-3); - UNIT_ASSERT_DOUBLES_EQUAL(tuple.GetElement<float>(1), 22.0, 1e-3); - } -} - -} - - -} // namespace NKikimr diff --git a/ydb/core/client/minikql_result_lib/data_funcs.inl b/ydb/core/client/minikql_result_lib/data_funcs.inl deleted file mode 100644 index a152c054a1..0000000000 --- a/ydb/core/client/minikql_result_lib/data_funcs.inl +++ /dev/null @@ -1,120 +0,0 @@ -#pragma once - - -#define ENSURE_SCHEME_TYPE(expected, gotName) \ - do { \ - Y_ENSURE(expected == NScheme::NTypeIds::gotName, "Data scheme type mismatch: expected " << expected << ", but got " #gotName << "."); \ - } while (0); - - -template <> -inline bool HasData<bool>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Bool); - return value.HasBool(); -} - -template <> -inline bool HasData<i32>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Int32); - return value.HasInt32(); -} - -template <> -inline bool HasData<ui32>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Uint32); - return value.HasUint32(); -} - -template <> -inline bool HasData<i64>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Int64); - return value.HasInt64(); -} - -template <> -inline bool HasData<ui64>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Uint64); - return value.HasUint64(); -} - -template <> -inline bool HasData<float>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Float); - return value.HasFloat(); -} - -template <> -inline bool HasData<double>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_SCHEME_TYPE(schemeType, Double); - return value.HasDouble(); -} - -template <> -inline bool HasData<TStringBuf>(const TProtoValue& value, NScheme::TTypeId schemeType) { - if (schemeType == NScheme::NTypeIds::Utf8) { - return value.HasText(); - } else { - return value.HasBytes(); - } -} - -#undef ENSURE_SCHEME_TYPE - -#define ENSURE_HAS_DATA(type, value, schemeType) \ - do { \ - Y_ENSURE(HasData<type>(value, schemeType), "No data of type " #type "."); \ - } while (0); - -template <> -inline bool GetData<bool>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(bool, value, schemeType); - return value.GetBool(); -} - -template <> -inline i32 GetData<i32>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(i32, value, schemeType); - return value.GetInt32(); -} - -template <> -inline ui32 GetData<ui32>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(ui32, value, schemeType); - return value.GetUint32(); -} - -template <> -inline i64 GetData<i64>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(i64, value, schemeType); - return value.GetInt64(); -} - -template <> -inline ui64 GetData<ui64>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(ui64, value, schemeType); - return value.GetUint64(); -} - -template <> -inline float GetData<float>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(float, value, schemeType); - return value.GetFloat(); -} - -template <> -inline double GetData<double>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(double, value, schemeType); - return value.GetDouble(); -} - -template <> -inline TStringBuf GetData<TStringBuf>(const TProtoValue& value, NScheme::TTypeId schemeType) { - ENSURE_HAS_DATA(TStringBuf, value, schemeType); - if (schemeType == NScheme::NTypeIds::Utf8) { - return value.GetText(); - } else { - return value.GetBytes(); - } -} - -#undef ENSURE_HAS_DATA diff --git a/ydb/core/client/minikql_result_lib/list_funcs.inl b/ydb/core/client/minikql_result_lib/list_funcs.inl deleted file mode 100644 index 6fb2d46ab8..0000000000 --- a/ydb/core/client/minikql_result_lib/list_funcs.inl +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - - -template <typename T> -inline TListType::iterator<T>::iterator(google::protobuf::RepeatedPtrField<TProtoValue>::const_iterator item, const TProtoType& itemType) - : Item(item) - , ItemType(itemType) -{ -} - -template <typename T> -inline TListType::iterator<T>::iterator(const iterator& it) - : Item(it.Item) - , ItemType(it.ItemType) -{ -} - -template <typename T> -inline TListType::iterator<T>& TListType::iterator<T>::operator++() { - ++Item; - return *this; -} - -template <typename T> -inline TListType::iterator<T> TListType::iterator<T>::operator++(int) { - iterator it(*this); - ++(*this); - return it; -} - -template <typename T> -inline bool TListType::iterator<T>::operator!=(const iterator& it) const { - return Item != it.Item; -} - -template <typename T> -inline bool TListType::iterator<T>::operator==(const iterator& it) const { - return Item == it.Item; -} - -template <typename T> -inline T TListType::iterator<T>::operator*() const { - return Get(); -} - -template <typename T> -inline T TListType::iterator<T>::Get() const { - ENSURE_KIND(ItemType, Data); - auto schemeType = ItemType.GetData().GetScheme(); - return NPrivate::GetData<T>(*Item, schemeType); -} - -template <> -inline void TListType::iterator<void>::Get() const { - return; -} - -template <> -inline TOptional TListType::iterator<TOptional>::Get() const { - return TOptional(*Item, ItemType); -} - -template <> -inline TListType TListType::iterator<TListType>::Get() const { - return TListType(*Item, ItemType); -} - -template <> -inline TTuple TListType::iterator<TTuple>::Get() const { - return TTuple(*Item, ItemType); -} - -template <> -inline TStruct TListType::iterator<TStruct>::Get() const { - return TStruct(*Item, ItemType); -} - -template <> -inline TDict TListType::iterator<TDict>::Get() const { - return TDict(*Item, ItemType); -} diff --git a/ydb/core/client/minikql_result_lib/objects.cpp b/ydb/core/client/minikql_result_lib/objects.cpp deleted file mode 100644 index eaaa2e4551..0000000000 --- a/ydb/core/client/minikql_result_lib/objects.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "objects.h" - - -namespace NKikimr { - -} // namespace NKikimr diff --git a/ydb/core/client/minikql_result_lib/objects.h b/ydb/core/client/minikql_result_lib/objects.h deleted file mode 100644 index 23eab54d76..0000000000 --- a/ydb/core/client/minikql_result_lib/objects.h +++ /dev/null @@ -1,318 +0,0 @@ -#pragma once - -#include <ydb/library/mkql_proto/protos/minikql.pb.h> -#include <ydb/core/scheme/scheme_type_id.h> - -#include <google/protobuf/repeated_field.h> - -#include <util/generic/hash.h> -#include <util/generic/yexception.h> - - -namespace NKikimr { -namespace NResultLib { - -using TProtoValue = NKikimrMiniKQL::TValue; -using TProtoType = NKikimrMiniKQL::TType; -using EProtoTypeKind = NKikimrMiniKQL::ETypeKind; - -class TOptional; -class TListType; -class TTuple; -class TStruct; -class TDict; - - -namespace NPrivate { - -template <typename T> -inline bool HasData(const TProtoValue& value, NScheme::TTypeId schemeType) { - Y_UNUSED(value); - Y_UNUSED(schemeType); - Y_ABORT("Not scpecified type."); -} - -template <typename T> -inline T GetData(const TProtoValue& value, NScheme::TTypeId schemeType) { - Y_UNUSED(value); - Y_UNUSED(schemeType); - Y_ABORT("Not scpecified type."); -} - -#include "data_funcs.inl" - -} // namespace NPrivate - - -#define ENSURE_KIND(type, expectedKind) \ - do { \ - auto kind = (EProtoTypeKind) type.GetKind(); \ - Y_ENSURE(kind == EProtoTypeKind::expectedKind, \ - "Expected " #expectedKind " instead of " << NKikimrMiniKQL::ETypeKind_Name(kind)); \ - Y_ENSURE(type.Has ## expectedKind(), "No " #expectedKind " in type, seems like an error."); \ - } while (false); - - -class TOptional { -public: - explicit TOptional(const TProtoValue& value, const TProtoType& type) - : RootValue(value) - , RootType(type) - { - ENSURE_KIND(RootType, Optional); - } - - template <typename T> - T GetItem() const; - - bool HasItem() const { - return RootValue.HasOptional(); - } - -private: - const TProtoValue& RootValue; - const TProtoType& RootType; -}; - - -class TListType { -public: - template <typename T> - class iterator { - public: - iterator(google::protobuf::RepeatedPtrField<TProtoValue>::const_iterator item, const TProtoType& itemType); - iterator(const iterator& it); - - iterator& operator++(); - iterator operator++(int); - bool operator!=(const iterator& it) const; - bool operator==(const iterator& it) const; - T operator*() const; - T Get() const; - - private: - google::protobuf::RepeatedPtrField<TProtoValue>::const_iterator Item; - const TProtoType& ItemType; - }; - - - template <typename T> - class TIterableList { - public: - TIterableList(const TListType& l) - : List(l) - { - } - - iterator<T> begin() { - return iterator<T>(List.RootValue.GetList().begin(), List.RootType.GetList().GetItem()); - } - - iterator<T> end() { - return iterator<T>(List.RootValue.GetList().end(), List.RootType.GetList().GetItem()); - } - - private: - const TListType& List; - }; - - - explicit TListType(const TProtoValue& value, const TProtoType& type) - : RootValue(value) - , RootType(type) - , Size(RootValue.ListSize()) - { - ENSURE_KIND(RootType, List); - } - - template <typename T> - TIterableList<T> MakeIterable() { - return TIterableList<T>(*this); - } - - template <typename T> - T GetItem(size_t index) { - Y_ENSURE(CheckIndex(index), "List item index" << index << " is out of bounds."); - iterator<T> it(RootValue.GetList().begin() + index, RootType.GetList().GetItem()); - return it.Get(); - } - - size_t GetSize() const { - return Size; - } - -private: - bool CheckIndex(size_t index) { - return index < Size; - } - -private: - const TProtoValue& RootValue; - const TProtoType& RootType; - const size_t Size; -}; - - -class TTuple { -public: - explicit TTuple(const TProtoValue& value, const TProtoType& type) - : RootValue(value) - , RootType(type) - , Size(RootValue.TupleSize()) - { - ENSURE_KIND(RootType, Tuple); - Y_ENSURE(RootType.GetTuple().ElementSize() == RootValue.TupleSize(), "Size mismatch."); - } - - template <typename T> - T GetElement(size_t index) const; - - size_t GetSize() const { - return Size; - } - -private: - bool CheckIndex(size_t index) const { - return index < Size; - } - -private: - const TProtoValue& RootValue; - const TProtoType& RootType; - const size_t Size; -}; - - -class TStruct { -public: - explicit TStruct(const TProtoValue& value, const TProtoType& type) - : RootValue(value) - , RootType(type) - , Size(RootValue.StructSize()) - { - ENSURE_KIND(RootType, Struct); - Y_ENSURE(RootType.GetStruct().MemberSize() == RootValue.StructSize(), "Size mismatch."); - } - - template <typename T> - T GetMember(const TStringBuf& memberName); - - template <typename T> - T GetMember(size_t memberIndex); - - size_t GetMemberIndex(const TStringBuf& memberName) const { - for (size_t i = 0, end = RootType.GetStruct().MemberSize(); i < end; ++i) { - const TStringBuf& name = RootType.GetStruct().GetMember(i).GetName(); - if (name == memberName) { - return i; - } - } - ythrow yexception() << "Unknown Struct member name: " << memberName << "."; - } - - size_t GetSize() const { - return Size; - } - -private: - bool CheckIndex(size_t index) const { - return index < Size; - } - -private: - const TProtoValue& RootValue; - const TProtoType& RootType; - const size_t Size; -}; - - -class TDict { -public: - explicit TDict(const TProtoValue& value, const TProtoType& type) - : RootValue(value) - , RootType(type) - { - ENSURE_KIND(RootType, Dict); - ENSURE_KIND(RootType.GetDict().GetKey(), Data); - - } - - template <typename K, typename V> - THashMap<K, V> GetHashMap() const; - -private: - const TProtoValue& RootValue; - const TProtoType& RootType; -}; - - -// TOptional. -template <typename T> -T TOptional::GetItem() const { - Y_ENSURE(HasItem(), "Optional is empty!"); - const auto& itemType = RootType.GetOptional().GetItem(); - ENSURE_KIND(itemType, Data); - auto schemeType = itemType.GetData().GetScheme(); - return NPrivate::GetData<T>(RootValue.GetOptional(), schemeType); -} - -#include "optional_funcs.inl" - - -// TListType. -#include "list_funcs.inl" - - -// TTuple. -template <typename T> -T TTuple::GetElement(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - const auto& elementType = RootType.GetTuple().GetElement(index); - const auto& element = RootValue.GetTuple(index); - ENSURE_KIND(elementType, Data); - auto schemeType = elementType.GetData().GetScheme(); - return NPrivate::GetData<T>(element, schemeType); -} - -#include "tuple_funcs.inl" - - -// TStruct. -template <typename T> -T TStruct::GetMember(const TStringBuf& memberName) { - size_t memberIndex = GetMemberIndex(memberName); - return GetMember<T>(memberIndex); -} - -template <typename T> -T TStruct::GetMember(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); - const auto& member = RootValue.GetStruct(memberIndex); - ENSURE_KIND(memberType, Data); - auto schemeType = memberType.GetData().GetScheme(); - return NPrivate::GetData<T>(member, schemeType); -} - -#include "struct_funcs.inl" - - -// TDict. -template <typename K, typename V> -THashMap<K, V> TDict::GetHashMap() const { - THashMap<K, V> m; - ui32 keySchemeType = RootType.GetDict().GetKey().GetData().GetScheme(); - for (const auto& kvPair : RootValue.GetDict()) { - auto dictKey = NPrivate::GetData<K>(kvPair.GetKey(), keySchemeType); - const auto& dictValue = kvPair.GetPayload(); - const auto& dictValueType = RootType.GetDict().GetPayload(); - m[dictKey] = V(dictValue, dictValueType); - } - return m; -} - - -#undef ENSURE_KIND - -} // namespace NResultLib -} // namespace NKikimr diff --git a/ydb/core/client/minikql_result_lib/objects_ut.cpp b/ydb/core/client/minikql_result_lib/objects_ut.cpp deleted file mode 100644 index 49b3d300dc..0000000000 --- a/ydb/core/client/minikql_result_lib/objects_ut.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "objects.h" - -#include <ydb/core/scheme/scheme_type_id.h> - -#include <library/cpp/testing/unittest/registar.h> - - -namespace NKikimr { - -using namespace NKikimrMiniKQL; -using namespace NResultLib; - -Y_UNIT_TEST_SUITE(TMiniKQLResultTest) { - -Y_UNIT_TEST(TOptionalTest) { - { // Optional of Bool. - TType type; - type.SetKind(ETypeKind::Optional); - type.MutableOptional()->MutableItem()->SetKind(ETypeKind::Data); - type.MutableOptional()->MutableItem()->MutableData()->SetScheme(NScheme::NTypeIds::Bool); - TValue value; - value.MutableOptional()->SetBool(true); - TOptional opt(value, type); - UNIT_ASSERT_EQUAL(opt.GetItem<bool>(), true); - } - { // Optional of Uint64. - TType type; - type.SetKind(ETypeKind::Optional); - type.MutableOptional()->MutableItem()->SetKind(ETypeKind::Data); - type.MutableOptional()->MutableItem()->MutableData()->SetScheme(NScheme::NTypeIds::Uint64); - TValue value; - value.MutableOptional()->SetUint64(200100); - TOptional opt(value, type); - UNIT_ASSERT_EQUAL(opt.GetItem<ui64>(), 200100); - } -} - -Y_UNIT_TEST(TListTest) { - { // List of Int32. - TType type; - type.SetKind(ETypeKind::List); - type.MutableList()->MutableItem()->SetKind(ETypeKind::Data); - type.MutableList()->MutableItem()->MutableData()->SetScheme(NScheme::NTypeIds::Int32); - TValue value; - value.AddList()->SetInt32(-100); - value.AddList()->SetInt32(0); - value.AddList()->SetInt32(100); - - TListType l(value, type); - - UNIT_ASSERT_EQUAL(l.GetSize(), 3); - UNIT_ASSERT_EQUAL(l.GetItem<i32>(0), -100); - UNIT_ASSERT_EQUAL(l.GetItem<i32>(1), 0); - UNIT_ASSERT_EQUAL(l.GetItem<i32>(2), 100); - - TVector<i32> v; - for (const auto& listItem : l.MakeIterable<i32>()) { - v.push_back(listItem); - } - UNIT_ASSERT_EQUAL(v.size(), 3); - UNIT_ASSERT_EQUAL(v[0], -100); - UNIT_ASSERT_EQUAL(v[1], 0); - UNIT_ASSERT_EQUAL(v[2], 100); - } - { // List of Optional of Int32. - TType type; - type.SetKind(ETypeKind::List); - type.MutableList()->MutableItem()->SetKind(ETypeKind::Optional); - type.MutableList()->MutableItem()->MutableOptional()->MutableItem()->SetKind(ETypeKind::Data); - type.MutableList()->MutableItem()->MutableOptional()->MutableItem()->MutableData()->SetScheme(NScheme::NTypeIds::Int32); - TValue value; - value.AddList()->MutableOptional()->SetInt32(-100); - value.AddList()->MutableOptional()->SetInt32(0); - value.AddList()->MutableOptional()->SetInt32(100); - TListType l(value, type); - - TVector<i32> v; - for (const TOptional& opt : l.MakeIterable<TOptional>()) { - v.push_back(opt.GetItem<i32>()); - } - UNIT_ASSERT_EQUAL(v.size(), 3); - UNIT_ASSERT_EQUAL(v[0], -100); - UNIT_ASSERT_EQUAL(v[1], 0); - UNIT_ASSERT_EQUAL(v[2], 100); - } -} - - -Y_UNIT_TEST(TTupleTest) { - { // Tuple of (Optional of Int32, List of Uint64). - TType type; - type.SetKind(ETypeKind::Tuple); - auto el0Type = type.MutableTuple()->AddElement(); - el0Type->SetKind(ETypeKind::Optional); - el0Type->MutableOptional()->MutableItem()->SetKind(ETypeKind::Data); - el0Type->MutableOptional()->MutableItem()->MutableData()->SetScheme(NScheme::NTypeIds::Int32); - - auto el1Type = type.MutableTuple()->AddElement(); - el1Type->SetKind(ETypeKind::List); - el1Type->MutableList()->MutableItem()->SetKind(ETypeKind::Data); - el1Type->MutableList()->MutableItem()->MutableData()->SetScheme(NScheme::NTypeIds::Uint64); - - TValue value; - value.AddTuple()->MutableOptional()->SetInt32(911); - auto el1 = value.AddTuple(); - el1->AddList()->SetUint64(0); - el1->AddList()->SetUint64(1); - el1->AddList()->SetUint64(2); - - TTuple t(value, type); - - TOptional opt = t.GetElement<TOptional>(0); - UNIT_ASSERT_EQUAL(opt.GetItem<i32>(), 911); - TListType l = t.GetElement<TListType>(1); - - TVector<ui64> v; - for (ui64 item : l.MakeIterable<ui64>()) { - v.push_back(item); - } - UNIT_ASSERT_EQUAL(v.size(), 3); - UNIT_ASSERT_EQUAL(v[0], 0); - UNIT_ASSERT_EQUAL(v[1], 1); - UNIT_ASSERT_EQUAL(v[2], 2); - } -} - -Y_UNIT_TEST(TStructTest) { - { // Struct of {"a" : Int64, "b" : Int32}. - TType type; - type.SetKind(ETypeKind::Struct); - auto mem1Type = type.MutableStruct()->AddMember(); - mem1Type->SetName("a"); - mem1Type->MutableType()->SetKind(ETypeKind::Data); - mem1Type->MutableType()->MutableData()->SetScheme(NScheme::NTypeIds::Int64); - auto mem2Type = type.MutableStruct()->AddMember(); - mem2Type->SetName("b"); - mem2Type->MutableType()->SetKind(ETypeKind::Data); - mem2Type->MutableType()->MutableData()->SetScheme(NScheme::NTypeIds::Int32); - - TValue value; - value.AddStruct()->SetInt64(-1000); - value.AddStruct()->SetInt32(1000); - - TStruct s(value, type); - - UNIT_ASSERT_EQUAL(s.GetMember<i64>("a"), -1000); - UNIT_ASSERT_EQUAL(s.GetMember<i32>("b"), 1000); - - auto aIndex = s.GetMemberIndex("a"); - auto bIndex = s.GetMemberIndex("b"); - UNIT_ASSERT_EQUAL(s.GetMember<i64>(aIndex), -1000); - UNIT_ASSERT_EQUAL(s.GetMember<i32>(bIndex), 1000); - } -} - -} - -} // namespace NKikimr diff --git a/ydb/core/client/minikql_result_lib/optional_funcs.inl b/ydb/core/client/minikql_result_lib/optional_funcs.inl deleted file mode 100644 index 56cc00dcc7..0000000000 --- a/ydb/core/client/minikql_result_lib/optional_funcs.inl +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - - -#define ENSURE_HAS_ITEM() \ - do { \ - Y_ENSURE(HasItem(), "Optional is empty!"); \ - } while (0); - -template <> -inline void TOptional::GetItem<void>() const { - return; -} - -template <> -inline TOptional TOptional::GetItem<TOptional>() const { - ENSURE_HAS_ITEM(); - const auto& itemType = RootType.GetOptional().GetItem(); - return TOptional(RootValue.GetOptional(), itemType); -} - -template <> -inline TListType TOptional::GetItem<TListType>() const { - ENSURE_HAS_ITEM(); - const auto& itemType = RootType.GetOptional().GetItem(); - return TListType(RootValue.GetOptional(), itemType); -} - -template <> -inline TTuple TOptional::GetItem<TTuple>() const { - ENSURE_HAS_ITEM(); - const auto& itemType = RootType.GetOptional().GetItem(); - return TTuple(RootValue.GetOptional(), itemType); -} - -template <> -inline TStruct TOptional::GetItem<TStruct>() const { - ENSURE_HAS_ITEM(); - const auto& itemType = RootType.GetOptional().GetItem(); - return TStruct(RootValue.GetOptional(), itemType); -} - -template <> -inline TDict TOptional::GetItem<TDict>() const { - ENSURE_HAS_ITEM(); - const auto& itemType = RootType.GetOptional().GetItem(); - return TDict(RootValue.GetOptional(), itemType); -} - -#undef ENSURE_HAS_ITEM diff --git a/ydb/core/client/minikql_result_lib/struct_funcs.inl b/ydb/core/client/minikql_result_lib/struct_funcs.inl deleted file mode 100644 index 4c95387842..0000000000 --- a/ydb/core/client/minikql_result_lib/struct_funcs.inl +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - - -template <> -inline void TStruct::GetMember<void>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - return; -} - -template <> -inline TOptional TStruct::GetMember<TOptional>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); - const auto& member = RootValue.GetStruct(memberIndex); - return TOptional(member, memberType); -} - -template <> -inline TListType TStruct::GetMember<TListType>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); - const auto& member = RootValue.GetStruct(memberIndex); - return TListType(member, memberType); -} - -template <> -inline TTuple TStruct::GetMember<TTuple>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); - const auto& member = RootValue.GetStruct(memberIndex); - return TTuple(member, memberType); -} - -template <> -inline TStruct TStruct::GetMember<TStruct>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); - const auto& member = RootValue.GetStruct(memberIndex); - return TStruct(member, memberType); -} - -template <> -inline TDict TStruct::GetMember<TDict>(size_t memberIndex) { - Y_ENSURE(CheckIndex(memberIndex), "Struct member index" << memberIndex << " is out of bounds."); - const auto& memberType = RootType.GetStruct().GetMember(memberIndex).GetType(); - const auto& member = RootValue.GetStruct(memberIndex); - return TDict(member, memberType); -} diff --git a/ydb/core/client/minikql_result_lib/tuple_funcs.inl b/ydb/core/client/minikql_result_lib/tuple_funcs.inl deleted file mode 100644 index 9c11f2f61f..0000000000 --- a/ydb/core/client/minikql_result_lib/tuple_funcs.inl +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - - -template <> -inline void TTuple::GetElement<void>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - return; -} - -template <> -inline TOptional TTuple::GetElement<TOptional>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - const auto& elementType = RootType.GetTuple().GetElement(index); - const auto& element = RootValue.GetTuple(index); - return TOptional(element, elementType); -} - -template <> -inline TListType TTuple::GetElement<TListType>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - const auto& elementType = RootType.GetTuple().GetElement(index); - const auto& element = RootValue.GetTuple(index); - return TListType(element, elementType); -} - -template <> -inline TTuple TTuple::GetElement<TTuple>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - const auto& elementType = RootType.GetTuple().GetElement(index); - const auto& element = RootValue.GetTuple(index); - return TTuple(element, elementType); -} - -template <> -inline TStruct TTuple::GetElement<TStruct>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - const auto& elementType = RootType.GetTuple().GetElement(index); - const auto& element = RootValue.GetTuple(index); - return TStruct(element, elementType); -} - -template <> -inline TDict TTuple::GetElement<TDict>(size_t index) const { - Y_ENSURE(CheckIndex(index), "Tuple element index" << index << " is out of bounds."); - const auto& elementType = RootType.GetTuple().GetElement(index); - const auto& element = RootValue.GetTuple(index); - return TDict(element, elementType); -} diff --git a/ydb/core/client/minikql_result_lib/ya.make b/ydb/core/client/minikql_result_lib/ya.make deleted file mode 100644 index 8f01aa5ce8..0000000000 --- a/ydb/core/client/minikql_result_lib/ya.make +++ /dev/null @@ -1,22 +0,0 @@ -LIBRARY() - -SRCS( - objects.h - objects.cpp - converter.h - converter.cpp -) - -PEERDIR( - contrib/libs/protobuf - ydb/core/protos - ydb/core/scheme - ydb/library/mkql_proto/protos - ydb/public/lib/deprecated/kicli -) - -END() - -RECURSE_FOR_TESTS( - ut -) diff --git a/ydb/core/client/ya.make b/ydb/core/client/ya.make index de08f2dd3f..68eda3106c 100644 --- a/ydb/core/client/ya.make +++ b/ydb/core/client/ya.make @@ -14,11 +14,6 @@ END() RECURSE( metadata minikql_compile - minikql_result_lib scheme_cache_lib server ) - -RECURSE_FOR_TESTS( - ut -) diff --git a/ydb/core/kqp/provider/ut/ya.make b/ydb/core/kqp/provider/ut/ya.make index 0b71054c6a..184888ba2e 100644 --- a/ydb/core/kqp/provider/ut/ya.make +++ b/ydb/core/kqp/provider/ut/ya.make @@ -7,7 +7,6 @@ SRCS( ) PEERDIR( - ydb/core/client/minikql_result_lib ydb/core/kqp/ut/common ydb/library/yql/sql/pg_dummy library/cpp/testing/gmock_in_unittest diff --git a/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp b/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp index a5422321bc..eaf8201ca7 100644 --- a/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp +++ b/ydb/core/kqp/provider/yql_kikimr_gateway_ut.cpp @@ -1,5 +1,4 @@ #include <ydb/core/client/minikql_compile/mkql_compile_service.h> -#include <ydb/core/client/minikql_result_lib/converter.h> #include <ydb/core/kqp/gateway/actors/kqp_ic_gateway_actors.h> #include <ydb/core/kqp/gateway/kqp_gateway.h> #include <ydb/core/kqp/gateway/kqp_metadata_loader.h> @@ -12,7 +11,6 @@ namespace NYql { using namespace NKikimr; using namespace NKikimr::NKqp; using namespace NMiniKQL; -using namespace NResultLib; using namespace NYdb::NTable; namespace { |