1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include <library/cpp/testing/unittest/registar.h>
#include "mkql_functions.h"
#include <yql/essentials/minikql/invoke_builtins/mkql_builtins.h>
namespace NKikimr::NMiniKQL {
Y_UNIT_TEST_SUITE(TMiniKQLArrowFunctions) {
Y_UNIT_TEST(Add) {
TScopedAlloc alloc(__LOCATION__);
TTypeEnvironment env(alloc);
auto builtins = CreateBuiltinRegistry();
auto uint64Type = TDataType::Create(NUdf::GetDataTypeInfo(NUdf::EDataSlot::Uint64).TypeId, env);
auto uint64TypeOpt = TOptionalType::Create(uint64Type, env);
auto scalarType = TBlockType::Create(uint64Type, TBlockType::EShape::Scalar, env);
auto arrayType = TBlockType::Create(uint64Type, TBlockType::EShape::Many, env);
auto scalarTypeOpt = TBlockType::Create(uint64TypeOpt, TBlockType::EShape::Scalar, env);
auto arrayTypeOpt = TBlockType::Create(uint64TypeOpt, TBlockType::EShape::Many, env);
UNIT_ASSERT(!FindArrowFunction("_Add_", {}, scalarType, *builtins));
UNIT_ASSERT(!FindArrowFunction("Add", {}, scalarType, *builtins));
UNIT_ASSERT(!FindArrowFunction("Add", TVector<TType*>{ scalarType }, scalarType, *builtins));
UNIT_ASSERT(!FindArrowFunction("Add", TVector<TType*>{ arrayType }, arrayType, *builtins));
UNIT_ASSERT(!FindArrowFunction("Add", TVector<TType*>{ scalarTypeOpt }, scalarType, *builtins));
UNIT_ASSERT(!FindArrowFunction("Add", TVector<TType*>{ arrayTypeOpt }, arrayType, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayType, arrayType }, arrayType, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarType, arrayType }, arrayType, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayType, scalarType }, arrayType, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarType, scalarType }, scalarType, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayType, arrayTypeOpt }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarType, arrayTypeOpt }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayType, scalarTypeOpt }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarType, scalarTypeOpt }, scalarTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayTypeOpt, arrayType }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarTypeOpt, arrayType }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayTypeOpt, scalarType }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarTypeOpt, scalarType }, scalarTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayTypeOpt, arrayTypeOpt }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarTypeOpt, arrayTypeOpt }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ arrayTypeOpt, scalarTypeOpt }, arrayTypeOpt, *builtins));
UNIT_ASSERT(FindArrowFunction("Add", TVector<TType*>{ scalarTypeOpt, scalarTypeOpt }, scalarTypeOpt, *builtins));
}
}
}
|