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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
#include "yql_data_provider_impl.h"
#include <yql/essentials/core/yql_expr_constraint.h>
#include <yql/essentials/core/yql_expr_optimize.h>
#include <yql/essentials/core/expr_nodes/yql_expr_nodes.h>
#include <util/system/compiler.h>
namespace NYql {
using namespace NNodes;
void TPlanFormatterBase::WriteDetails(const TExprNode& node, NYson::TYsonWriter& writer) {
Y_UNUSED(node);
Y_UNUSED(writer);
}
bool TPlanFormatterBase::GetDependencies(const TExprNode& node, TExprNode::TListType& children, bool compact) {
Y_UNUSED(node);
Y_UNUSED(children);
Y_UNUSED(compact);
return false;
}
void TPlanFormatterBase::GetResultDependencies(const TExprNode::TPtr& node, TExprNode::TListType& children, bool compact) {
Y_UNUSED(node);
Y_UNUSED(children);
Y_UNUSED(compact);
}
ui32 TPlanFormatterBase::GetInputs(const TExprNode& node, TVector<TPinInfo>& inputs, bool withLimits) {
Y_UNUSED(node);
Y_UNUSED(inputs);
Y_UNUSED(withLimits);
return 0;
}
ui32 TPlanFormatterBase::GetOutputs(const TExprNode& node, TVector<TPinInfo>& outputs, bool withLimits) {
Y_UNUSED(node);
Y_UNUSED(outputs);
Y_UNUSED(withLimits);
return 0;
}
TString TPlanFormatterBase::GetProviderPath(const TExprNode& node) {
Y_UNUSED(node);
return TString();
}
void TPlanFormatterBase::WritePlanDetails(const TExprNode& node, NYson::TYsonWriter& writer, bool withLimits) {
Y_UNUSED(node);
Y_UNUSED(writer);
Y_UNUSED(withLimits);
}
void TPlanFormatterBase::WritePullDetails(const TExprNode& node, NYson::TYsonWriter& writer) {
Y_UNUSED(node);
Y_UNUSED(writer);
}
void TPlanFormatterBase::WritePinDetails(const TExprNode& node, NYson::TYsonWriter& writer) {
Y_UNUSED(node);
Y_UNUSED(writer);
}
TString TPlanFormatterBase::GetOperationDisplayName(const TExprNode& node) {
return TString(node.Content());
}
bool TPlanFormatterBase::WriteSchemaHeader(NYson::TYsonWriter& writer) {
Y_UNUSED(writer);
return false;
}
void TPlanFormatterBase::WriteTypeDetails(NYson::TYsonWriter& writer, const TTypeAnnotationNode& type) {
Y_UNUSED(writer);
Y_UNUSED(type);
}
void TTrackableNodeProcessorBase::GetUsedNodes(const TExprNode& node, TVector<TString>& usedNodeIds) {
Y_UNUSED(node);
usedNodeIds.clear();
}
void TTrackableNodeProcessorBase::GetCreatedNodes(const TExprNode& node, TVector<TExprNodeAndId>& createdNodes, TExprContext& ctx) {
Y_UNUSED(node);
Y_UNUSED(ctx);
createdNodes.clear();
}
IGraphTransformer& TTrackableNodeProcessorBase::GetCleanupTransformer() {
return NullTransformer_;
}
bool TDataProviderBase::Initialize(TExprContext& ctx) {
Y_UNUSED(ctx);
return true;
}
IGraphTransformer& TDataProviderBase::GetConfigurationTransformer() {
return NullTransformer_;
}
TExprNode::TPtr TDataProviderBase::GetClusterInfo(const TString& cluster, TExprContext& ctx) {
Y_UNUSED(cluster);
Y_UNUSED(ctx);
return {};
}
void TDataProviderBase::AddCluster(const TString& name, const THashMap<TString, TString>& properties) {
Y_UNUSED(name, properties);
}
const THashMap<TString, TString>* TDataProviderBase::GetClusterTokens() {
return nullptr;
}
IGraphTransformer& TDataProviderBase::GetIODiscoveryTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetEpochsTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetIntentDeterminationTransformer() {
return NullTransformer_;
}
bool TDataProviderBase::ValidateParameters(TExprNode& node, TExprContext& ctx, TMaybe<TString>& cluster) {
Y_UNUSED(node);
Y_UNUSED(ctx);
cluster = Nothing();
return true;
}
bool TDataProviderBase::CanParse(const TExprNode& node) {
Y_UNUSED(node);
return false;
}
void TDataProviderBase::FillModifyCallables(THashSet<TStringBuf>& callables) {
Y_UNUSED(callables);
}
IGraphTransformer& TDataProviderBase::GetTypeAnnotationTransformer(bool instantOnly) {
Y_UNUSED(instantOnly);
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetConstraintTransformer(bool instantOnly, bool subGraph) {
Y_UNUSED(instantOnly);
Y_UNUSED(subGraph);
if (!DefConstraintTransformer_) {
DefConstraintTransformer_ = CreateDefCallableConstraintTransformer();
}
return *DefConstraintTransformer_;
}
TExprNode::TPtr TDataProviderBase::RewriteIO(const TExprNode::TPtr& node, TExprContext& ctx) {
Y_UNUSED(ctx);
return node;
}
void TDataProviderBase::PostRewriteIO() {
}
void TDataProviderBase::Reset() {
GetConfigurationTransformer().Rewind();
GetIODiscoveryTransformer().Rewind();
GetEpochsTransformer().Rewind();
GetIntentDeterminationTransformer().Rewind();
for (auto flag : {true, false}) {
GetTypeAnnotationTransformer(flag).Rewind();
}
for (auto flag1 : {true, false}) {
for (auto flag2 : {true, false}) {
GetConstraintTransformer(flag1, flag2).Rewind();
}
}
GetRecaptureOptProposalTransformer().Rewind();
GetStatisticsProposalTransformer().Rewind();
GetLogicalOptProposalTransformer().Rewind();
GetPhysicalOptProposalTransformer().Rewind();
GetPhysicalFinalizingTransformer().Rewind();
GetLoadTableMetadataTransformer().Rewind();
GetCallableExecutionTransformer().Rewind();
GetFinalizingTransformer().Rewind();
GetPlanInfoTransformer().Rewind();
GetTrackableNodeProcessor().GetCleanupTransformer().Rewind();
}
IGraphTransformer& TDataProviderBase::GetRecaptureOptProposalTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetStatisticsProposalTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetLogicalOptProposalTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetPhysicalOptProposalTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetPhysicalFinalizingTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetLoadTableMetadataTransformer() {
return NullTransformer_;
}
bool TDataProviderBase::IsPersistent(const TExprNode& node) {
Y_UNUSED(node);
return false;
}
bool TDataProviderBase::IsRead(const TExprNode& node) {
Y_UNUSED(node);
return false;
}
bool TDataProviderBase::IsWrite(const TExprNode& node) {
Y_UNUSED(node);
return false;
}
bool TDataProviderBase::CanBuildResult(const TExprNode& node, TSyncMap& syncList) {
Y_UNUSED(node);
Y_UNUSED(syncList);
return false;
}
bool TDataProviderBase::CanPullResult(const TExprNode& node, TSyncMap& syncList, bool& canRef) {
Y_UNUSED(node);
Y_UNUSED(syncList);
Y_UNUSED(canRef);
return false;
}
bool TDataProviderBase::GetExecWorld(const TExprNode::TPtr& node, TExprNode::TPtr& root) {
root = nullptr;
Y_UNUSED(node);
return false;
}
bool TDataProviderBase::CanEvaluate(const TExprNode& node) {
Y_UNUSED(node);
return false;
}
void TDataProviderBase::EnterEvaluation(ui64 id) {
Y_UNUSED(id);
}
void TDataProviderBase::LeaveEvaluation(ui64 id) {
Y_UNUSED(id);
}
TExprNode::TPtr TDataProviderBase::CleanupWorld(const TExprNode::TPtr& node, TExprContext& ctx) {
return DefaultCleanupWorld(node, ctx);
}
TExprNode::TPtr TDataProviderBase::OptimizePull(const TExprNode::TPtr& source, const TFillSettings& fillSettings,
TExprContext& ctx, IOptimizationContext& optCtx)
{
Y_UNUSED(fillSettings);
Y_UNUSED(ctx);
Y_UNUSED(optCtx);
return source;
}
bool TDataProviderBase::CanExecute(const TExprNode& node) {
Y_UNUSED(node);
return false;
}
bool TDataProviderBase::ValidateExecution(const TExprNode& node, TExprContext& ctx) {
Y_UNUSED(node);
Y_UNUSED(ctx);
return true;
}
void TDataProviderBase::GetRequiredChildren(const TExprNode& node, TExprNode::TListType& children) {
GetDependencies(node, children, false);
}
IGraphTransformer& TDataProviderBase::GetCallableExecutionTransformer() {
return NullTransformer_;
}
IGraphTransformer& TDataProviderBase::GetFinalizingTransformer() {
return NullTransformer_;
}
bool TDataProviderBase::CollectDiagnostics(NYson::TYsonWriter& writer) {
Y_UNUSED(writer);
return false;
}
bool TDataProviderBase::GetTasksInfo(NYson::TYsonWriter& writer) {
Y_UNUSED(writer);
return false;
}
bool TDataProviderBase::CollectStatistics(NYson::TYsonWriter& writer, bool totalOnly) {
Y_UNUSED(writer);
Y_UNUSED(totalOnly);
return false;
}
bool TDataProviderBase::CollectDiscoveredData(NYson::TYsonWriter& writer) {
Y_UNUSED(writer);
return false;
}
IPlanFormatter& TDataProviderBase::GetPlanFormatter() {
return *this;
}
ITrackableNodeProcessor& TDataProviderBase::GetTrackableNodeProcessor() {
return NullTrackableNodeProcessor_;
}
IGraphTransformer& TDataProviderBase::GetPlanInfoTransformer() {
return NullTransformer_;
}
IDqIntegration* TDataProviderBase::GetDqIntegration() {
return nullptr;
}
IDqOptimization* TDataProviderBase::GetDqOptimization() {
return nullptr;
}
TExprNode::TPtr DefaultCleanupWorld(const TExprNode::TPtr& node, TExprContext& ctx) {
auto root = node;
auto status = OptimizeExpr(root, root, [&](const TExprNode::TPtr& node, TExprContext& ctx) -> TExprNode::TPtr {
Y_UNUSED(ctx);
if (auto right = TMaybeNode<TCoRight>(node)) {
auto cons = right.Cast().Input().Maybe<TCoCons>();
if (cons) {
return cons.Cast().Input().Ptr();
}
if (right.Cast().Input().Ref().IsCallable("PgReadTable!")) {
const auto& read = right.Cast().Input().Ref();
return ctx.Builder(node->Pos())
.Callable("PgTableContent")
.Add(0, read.Child(1)->TailPtr())
.Add(1, read.ChildPtr(2))
.Add(2, read.ChildPtr(3))
.Add(3, read.ChildPtr(4))
.Seal()
.Build();
}
}
return node;
}, ctx, TOptimizeExprSettings(nullptr));
YQL_ENSURE(status.Level != IGraphTransformer::TStatus::Error);
return root;
}
} // namespace NYql
|