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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#pragma once
#include "sql_translation.h"
namespace NSQLTranslationV1 {
using namespace NSQLv1Generated;
class TSqlCallExpr: public TSqlTranslation {
public:
TSqlCallExpr(TContext& ctx, NSQLTranslation::ESqlMode mode)
: TSqlTranslation(ctx, mode)
{
}
TSqlCallExpr(const TSqlCallExpr& call, const TVector<TNodePtr>& args)
: TSqlTranslation(call.Ctx_, call.Mode_)
, Pos_(call.Pos_)
, Func_(call.Func_)
, Module_(call.Module_)
, Node_(call.Node_)
, Args_(args)
, AggMode_(call.AggMode_)
, DistinctAllowed_(call.DistinctAllowed_)
, UsingCallExpr_(call.UsingCallExpr_)
, IsExternalCall_(call.IsExternalCall_)
, CallConfig_(call.CallConfig_)
{
}
void AllowDistinct() {
DistinctAllowed_ = true;
}
void InitName(const TString& name);
void InitExpr(const TNodePtr& expr);
bool Init(const TRule_using_call_expr& node);
bool Init(const TRule_value_constructor& node);
bool Init(const TRule_invoke_expr& node);
bool ConfigureExternalCall(const TRule_external_call_settings& node);
void IncCounters();
TNodePtr BuildUdf(bool forReduce);
TNodePtr BuildCall();
TPosition GetPos() const {
return Pos_;
}
const TVector<TNodePtr>& GetArgs() const {
return Args_;
}
void SetOverWindow() {
YQL_ENSURE(AggMode_ == EAggregateMode::Normal);
AggMode_ = EAggregateMode::OverWindow;
}
void SetOverWindowDistinct() {
YQL_ENSURE(AggMode_ == EAggregateMode::Distinct);
AggMode_ = EAggregateMode::OverWindowDistinct;
}
void SetIgnoreNulls() {
Func_ += "_IgnoreNulls";
}
bool IsExternal() {
return IsExternalCall_;
}
private:
bool ExtractCallParam(const TRule_external_call_param& node);
bool FillArg(const TString& module, const TString& func, size_t& idx, const TRule_named_expr& node);
bool FillArgs(const TRule_named_expr_list& node);
private:
TPosition Pos_;
TString Func_;
TString Module_;
TNodePtr Node_;
TVector<TNodePtr> Args_;
TVector<TNodePtr> PositionalArgs_;
TVector<TNodePtr> NamedArgs_;
EAggregateMode AggMode_ = EAggregateMode::Normal;
TString WindowName_;
bool DistinctAllowed_ = false;
bool UsingCallExpr_ = false;
bool IsExternalCall_ = false;
TFunctionConfig CallConfig_;
};
} // namespace NSQLTranslationV1
|