@@ -224,15 +224,33 @@ struct TPublicIds {
224
224
225
225
struct TDqsPipelineConfigurator : public IPipelineConfigurator {
226
226
public:
227
- TDqsPipelineConfigurator (const TDqStatePtr& state)
227
+ TDqsPipelineConfigurator (const TDqStatePtr& state, const THashMap<TString, TString>& providerParams )
228
228
: State_(state)
229
+ , ProviderParams_(providerParams)
229
230
{
231
+ for (const auto & ds: State_->TypeCtx ->DataSources ) {
232
+ if (const auto dq = ds->GetDqIntegration ()) {
233
+ UniqIntegrations_.emplace (dq);
234
+ }
235
+ }
236
+ for (const auto & ds: State_->TypeCtx ->DataSinks ) {
237
+ if (const auto dq = ds->GetDqIntegration ()) {
238
+ UniqIntegrations_.emplace (dq);
239
+ }
240
+ }
230
241
}
231
242
private:
232
243
void AfterCreate (TTransformationPipeline*) const final {}
233
244
234
245
void AfterTypeAnnotation (TTransformationPipeline* pipeline) const final {
246
+ // First truncate graph by calculated precomputes
235
247
pipeline->Add (NDqs::CreateDqsReplacePrecomputesTransformer (*pipeline->GetTypeAnnotationContext (), State_->FunctionRegistry ), " ReplacePrecomputes" );
248
+
249
+ // Then apply provider specific transformers on truncated graph
250
+ std::for_each (UniqIntegrations_.cbegin (), UniqIntegrations_.cend (), [&](const auto dqInt) {
251
+ dqInt->ConfigurePeepholePipeline (true , ProviderParams_, pipeline);
252
+ });
253
+
236
254
if (State_->Settings ->UseBlockReader .Get ().GetOrElse (false )) {
237
255
pipeline->Add (NDqs::CreateDqsRewritePhyBlockReadOnDqIntegrationTransformer (*pipeline->GetTypeAnnotationContext ()), " ReplaceWideReadsWithBlock" );
238
256
}
@@ -255,10 +273,16 @@ struct TDqsPipelineConfigurator : public IPipelineConfigurator {
255
273
pipeline->Add (NDqs::CreateDqsRewritePhyCallablesTransformer (*pipeline->GetTypeAnnotationContext ()), " RewritePhyCallables" );
256
274
}
257
275
258
- void AfterOptimize (TTransformationPipeline*) const final {}
276
+ void AfterOptimize (TTransformationPipeline* pipeline) const final {
277
+ std::for_each (UniqIntegrations_.cbegin (), UniqIntegrations_.cend (), [&](const auto dqInt) {
278
+ dqInt->ConfigurePeepholePipeline (false , ProviderParams_, pipeline);
279
+ });
280
+ }
259
281
260
282
private:
261
283
TDqStatePtr State_;
284
+ THashMap<TString, TString> ProviderParams_;
285
+ std::unordered_set<IDqIntegration*> UniqIntegrations_;
262
286
};
263
287
264
288
TExprNode::TPtr DqMarkBlockStage (const TDqPhyStage& stage, TExprContext& ctx) {
@@ -792,9 +816,16 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
792
816
try {
793
817
auto result = TMaybeNode<TResult>(input).Cast ();
794
818
819
+ THashMap<TString, TString> resSettings;
820
+ for (auto s: result.Settings ()) {
821
+ if (auto val = s.Value ().Maybe <TCoAtom>()) {
822
+ resSettings.emplace (s.Name ().Value (), val.Cast ().Value ());
823
+ }
824
+ }
825
+
795
826
auto precomputes = FindIndependentPrecomputes (result.Input ().Ptr ());
796
827
if (!precomputes.empty ()) {
797
- auto status = HandlePrecomputes (precomputes, ctx);
828
+ auto status = HandlePrecomputes (precomputes, ctx, resSettings );
798
829
if (status.Level != TStatus::Ok) {
799
830
if (status == TStatus::Async) {
800
831
return std::make_pair (status, ExecState->Promise .GetFuture ().Apply ([execState = ExecState](const TFuture<void >& completedFuture) {
@@ -813,10 +844,19 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
813
844
settings->_AllResultsBytesLimit = 64_MB;
814
845
}
815
846
847
+ int level;
848
+ TExprNode::TPtr resInput = WrapLambdaBody (level, result.Input ().Ptr (), ctx);
849
+ {
850
+ auto block = MeasureBlock (" PeepHole" );
851
+ if (const auto status = PeepHole (resInput, resInput, ctx, resSettings); status.Level != TStatus::Ok) {
852
+ return SyncStatus (status);
853
+ }
854
+ }
855
+
816
856
THashMap<TString, TString> secureParams;
817
- NCommon::FillSecureParams (result. Input (). Ptr () , *State->TypeCtx , secureParams);
857
+ NCommon::FillSecureParams (resInput , *State->TypeCtx , secureParams);
818
858
819
- auto graphParams = GatherGraphParams (result. Input (). Ptr () );
859
+ auto graphParams = GatherGraphParams (resInput );
820
860
bool hasGraphParams = !graphParams.empty ();
821
861
822
862
TString type;
@@ -847,15 +887,6 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
847
887
settings->EnableFullResultWrite = enableFullResultWrite;
848
888
}
849
889
850
- int level;
851
- TExprNode::TPtr resInput = WrapLambdaBody (level, result.Input ().Ptr (), ctx);
852
- {
853
- auto block = MeasureBlock (" PeepHole" );
854
- if (const auto status = PeepHole (resInput, resInput, ctx); status.Level != TStatus::Ok) {
855
- return SyncStatus (status);
856
- }
857
- }
858
-
859
890
TString lambda;
860
891
bool untrustedUdfFlag;
861
892
TUploadList uploadList;
@@ -1111,6 +1142,13 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
1111
1142
TInstant startTime = TInstant::Now ();
1112
1143
auto pull = TPull (input);
1113
1144
1145
+ THashMap<TString, TString> pullSettings;
1146
+ for (auto s: pull.Settings ()) {
1147
+ if (auto val = s.Value ().Maybe <TCoAtom>()) {
1148
+ pullSettings.emplace (s.Name ().Value (), val.Cast ().Value ());
1149
+ }
1150
+ }
1151
+
1114
1152
YQL_ENSURE (!TMaybeNode<TDqQuery>(pull.Input ().Ptr ()) || State->Settings ->EnableComputeActor .Get ().GetOrElse (false ),
1115
1153
" DqQuery is not supported with worker actor" );
1116
1154
@@ -1120,7 +1158,7 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
1120
1158
1121
1159
auto precomputes = FindIndependentPrecomputes (pull.Input ().Ptr ());
1122
1160
if (!precomputes.empty ()) {
1123
- auto status = HandlePrecomputes (precomputes, ctx);
1161
+ auto status = HandlePrecomputes (precomputes, ctx, pullSettings );
1124
1162
if (status.Level != TStatus::Ok) {
1125
1163
if (status == TStatus::Async) {
1126
1164
return std::make_pair (status, ExecState->Promise .GetFuture ().Apply ([execState = ExecState](const TFuture<void >& completedFuture) {
@@ -1145,7 +1183,7 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
1145
1183
optimizedInput->SetTypeAnn (pull.Input ().Ref ().GetTypeAnn ());
1146
1184
optimizedInput->CopyConstraints (pull.Input ().Ref ());
1147
1185
1148
- auto status = PeepHole (optimizedInput, optimizedInput, ctx);
1186
+ auto status = PeepHole (optimizedInput, optimizedInput, ctx, pullSettings );
1149
1187
if (status.Level != TStatus::Ok) {
1150
1188
return SyncStatus (status);
1151
1189
}
@@ -1593,7 +1631,7 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
1593
1631
});
1594
1632
}
1595
1633
1596
- IGraphTransformer::TStatus HandlePrecomputes (const TNodeOnNodeOwnedMap& precomputes, TExprContext& ctx) {
1634
+ IGraphTransformer::TStatus HandlePrecomputes (const TNodeOnNodeOwnedMap& precomputes, TExprContext& ctx, const THashMap<TString, TString>& providerParams ) {
1597
1635
1598
1636
IDataProvider::TFillSettings fillSettings;
1599
1637
fillSettings.AllResultsBytesLimit .Clear ();
@@ -1620,7 +1658,7 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
1620
1658
1621
1659
auto optimizedInput = input;
1622
1660
optimizedInput->SetState (TExprNode::EState::ConstrComplete);
1623
- auto status = PeepHole (optimizedInput, optimizedInput, ctx);
1661
+ auto status = PeepHole (optimizedInput, optimizedInput, ctx, providerParams );
1624
1662
if (status.Level != TStatus::Ok) {
1625
1663
return combinedStatus.Combine (status);
1626
1664
}
@@ -1840,8 +1878,8 @@ class TDqExecTransformer: public TExecTransformerBase, TCounters
1840
1878
return combinedStatus;
1841
1879
}
1842
1880
1843
- IGraphTransformer::TStatus PeepHole (TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx) const {
1844
- TDqsPipelineConfigurator peepholeConfig (State);
1881
+ IGraphTransformer::TStatus PeepHole (TExprNode::TPtr input, TExprNode::TPtr& output, TExprContext& ctx, const THashMap<TString, TString>& providerParams ) const {
1882
+ TDqsPipelineConfigurator peepholeConfig (State, providerParams );
1845
1883
TDqsFinalPipelineConfigurator finalPeepholeConfg;
1846
1884
TPeepholeSettings peepholeSettings;
1847
1885
peepholeSettings.CommonConfig = &peepholeConfig;
0 commit comments