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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#pragma once
#include <yql/essentials/ast/yql_expr.h>
#include <yql/essentials/minikql/mkql_program_builder.h>
#include <unordered_map>
namespace NYql {
class TKernelRequestBuilder {
public:
enum class EUnaryOp {
Not,
Size,
Minus,
Abs,
Just
};
enum class EBinaryOp {
And = 0,
Or,
Xor,
Add,
Sub,
Mul,
Div,
Mod,
StartsWith,
EndsWith,
StringContains,
Equals,
NotEquals,
Less,
LessOrEqual,
Greater,
GreaterOrEqual,
Coalesce
};
TKernelRequestBuilder(const NKikimr::NMiniKQL::IFunctionRegistry& functionRegistry);
~TKernelRequestBuilder();
ui32 AddUnaryOp(EUnaryOp op, const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* retType);
ui32 AddBinaryOp(EBinaryOp op, const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* arg2Type, const TTypeAnnotationNode* retType);
ui32 AddIf(const TTypeAnnotationNode* conditionType, const TTypeAnnotationNode* thenType, const TTypeAnnotationNode* elseType);
ui32 Udf(const TString& name, bool isPolymorphic, const TTypeAnnotationNode::TListType& argTypes, const TTypeAnnotationNode* retType);
ui32 AddScalarApply(const TExprNode& lambda, const TTypeAnnotationNode::TListType& argTypes, TExprContext& ctx);
// (json/json?,utf8)->bool/bool?
ui32 JsonExists(const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* arg2Type, const TTypeAnnotationNode* retType);
ui32 JsonValue(const TTypeAnnotationNode* arg1Type, const TTypeAnnotationNode* arg2Type, const TTypeAnnotationNode* retType);
TString Serialize();
private:
NKikimr::NMiniKQL::TRuntimeNode MakeArg(const TTypeAnnotationNode* type);
NKikimr::NMiniKQL::TBlockType* MakeType(const TTypeAnnotationNode* type);
private:
NKikimr::NMiniKQL::TScopedAlloc Alloc_;
const NKikimr::NMiniKQL::TTypeEnvironment Env_;
NKikimr::NMiniKQL::TProgramBuilder Pb_;
std::vector<NKikimr::NMiniKQL::TRuntimeNode> Items_;
std::vector<NKikimr::NMiniKQL::TRuntimeNode> ArgsItems_;
std::unordered_map<const TTypeAnnotationNode*, NKikimr::NMiniKQL::TBlockType*> CachedTypes_;
std::unordered_map<const TTypeAnnotationNode*, NKikimr::NMiniKQL::TRuntimeNode> CachedArgs_;
};
}
|