@@ -124,13 +124,15 @@ class TS3PhysicalOptProposalTransformer : public TOptimizeTransformerBase {
124
124
auto keys = GetPartitionKeys (partBy);
125
125
126
126
auto sinkSettingsBuilder = Build<TExprList>(ctx, target.Pos ());
127
- if (partBy)
127
+ if (partBy) {
128
128
sinkSettingsBuilder.Add (std::move (partBy));
129
+ }
129
130
130
131
auto compression = GetCompression (settings);
131
132
const auto & extension = GetExtension (target.Format ().Value (), compression ? compression->Tail ().Content () : " " sv);
132
- if (compression)
133
+ if (compression) {
133
134
sinkSettingsBuilder.Add (std::move (compression));
135
+ }
134
136
135
137
auto sinkOutputSettingsBuilder = Build<TExprList>(ctx, target.Pos ());
136
138
if (auto csvDelimiter = GetCsvDelimiter (settings)) {
@@ -199,31 +201,17 @@ class TS3PhysicalOptProposalTransformer : public TOptimizeTransformerBase {
199
201
}
200
202
}
201
203
202
- if (! FindNode (input. Ptr (), [] ( const TExprNode::TPtr& node) { return node-> IsCallable ( TCoDataSource::CallableName ()); } )) {
204
+ if (IsDqPureExpr (input)) {
203
205
YQL_CLOG (INFO, ProviderS3) << " Rewrite pure S3WriteObject `" << cluster << " `.`" << target.Path ().StringValue () << " ` as stage with sink." ;
204
- auto shouldBePassedAsInput = FindNode (input.Ptr (), [] (const TExprNode::TPtr& node) { return node->IsCallable (TDqStage::CallableName ()); });
205
-
206
- auto stageInputs = Build<TExprList>(ctx, writePos);
207
- auto toFlow = Build<TCoToFlow>(ctx, writePos);
208
- TVector<TCoArgument> args;
209
-
210
- if (shouldBePassedAsInput) {
211
- auto arg = Build<TCoArgument>(ctx, writePos).Name (" in" ).Done ();
212
- stageInputs.Add (input);
213
- args.push_back (arg);
214
- toFlow.Input (arg);
215
- }
216
- else {
217
- toFlow.Input (input);
218
- }
219
-
220
206
return keys.empty () ?
221
207
Build<TDqStage>(ctx, writePos)
222
- .Inputs (stageInputs. Done () )
208
+ .Inputs (). Build ( )
223
209
.Program <TCoLambda>()
224
- .Args (args )
210
+ .Args ({} )
225
211
.Body <TS3SinkOutput>()
226
- .Input (toFlow.Done ())
212
+ .Input <TCoToFlow>()
213
+ .Input (input)
214
+ .Build ()
227
215
.Format (target.Format ())
228
216
.KeyColumns ().Build ()
229
217
.Settings (sinkOutputSettingsBuilder.Done ())
@@ -251,10 +239,12 @@ class TS3PhysicalOptProposalTransformer : public TOptimizeTransformerBase {
251
239
.Add <TDqCnHashShuffle>()
252
240
.Output <TDqOutput>()
253
241
.Stage <TDqStage>()
254
- .Inputs (stageInputs. Done () )
242
+ .Inputs (). Build ( )
255
243
.Program <TCoLambda>()
256
- .Args (args)
257
- .Body (toFlow.Done ())
244
+ .Args ({})
245
+ .Body <TCoToFlow>()
246
+ .Input (input)
247
+ .Build ()
258
248
.Build ()
259
249
.Settings ().Build ()
260
250
.Build ()
@@ -317,23 +307,26 @@ class TS3PhysicalOptProposalTransformer : public TOptimizeTransformerBase {
317
307
.Build ()
318
308
.Done ();
319
309
320
- auto outputsBuilder = Build<TDqStageOutputsList>(ctx, target.Pos ());
321
- if (inputStage.Outputs () && keys.empty ()) {
322
- outputsBuilder.InitFrom (inputStage.Outputs ().Cast ());
323
- }
324
- outputsBuilder.Add (sink);
310
+ auto outputsBuilder = Build<TDqStageOutputsList>(ctx, target.Pos ())
311
+ .Add (sink);
325
312
326
313
if (keys.empty ()) {
327
- const auto outputBuilder = Build<TS3SinkOutput>(ctx, target.Pos ())
328
- .Input (inputStage.Program ().Body ().Ptr ())
329
- .Format (target.Format ())
330
- .KeyColumns ().Add (std::move (keys)).Build ()
331
- .Settings (sinkOutputSettingsBuilder.Done ())
332
- .Done ();
333
-
334
314
return Build<TDqStage>(ctx, writePos)
335
- .InitFrom (inputStage)
336
- .Program (ctx.DeepCopyLambda (inputStage.Program ().Ref (), outputBuilder.Ptr ()))
315
+ .Inputs ()
316
+ .Add <TDqCnMap>()
317
+ .Output (dqUnion.Output ())
318
+ .Build ()
319
+ .Build ()
320
+ .Program <TCoLambda>()
321
+ .Args ({" in" })
322
+ .Body <TS3SinkOutput>()
323
+ .Input (" in" )
324
+ .Format (target.Format ())
325
+ .KeyColumns ().Add (std::move (keys)).Build ()
326
+ .Settings (sinkOutputSettingsBuilder.Done ())
327
+ .Build ()
328
+ .Build ()
329
+ .Settings ().Build ()
337
330
.Outputs (outputsBuilder.Done ())
338
331
.Done ();
339
332
} else {
0 commit comments