diff --git a/ydb/library/yql/core/services/yql_transform_pipeline.cpp b/ydb/library/yql/core/services/yql_transform_pipeline.cpp index 2411dab4e40e..bc3dc7ec0c25 100644 --- a/ydb/library/yql/core/services/yql_transform_pipeline.cpp +++ b/ydb/library/yql/core/services/yql_transform_pipeline.cpp @@ -39,11 +39,6 @@ TTransformationPipeline& TTransformationPipeline::Add(IGraphTransformer& transfo return *this; } -TTransformationPipeline& TTransformationPipeline::Add(TTransformStage&& stage) { - Transformers_.push_back(std::move(stage)); - return *this; -} - TTransformationPipeline& TTransformationPipeline::AddServiceTransformers(EYqlIssueCode issueCode) { Transformers_.push_back(TTransformStage(CreateGcNodeTransformer(), "GC", issueCode)); return *this; diff --git a/ydb/library/yql/core/services/yql_transform_pipeline.h b/ydb/library/yql/core/services/yql_transform_pipeline.h index a92fd748389d..37b52d5e1f8b 100644 --- a/ydb/library/yql/core/services/yql_transform_pipeline.h +++ b/ydb/library/yql/core/services/yql_transform_pipeline.h @@ -47,7 +47,6 @@ class TTransformationPipeline EYqlIssueCode issueCode = TIssuesIds::DEFAULT_ERROR, const TString& issueMessage = {}); TTransformationPipeline& Add(IGraphTransformer& transformer, const TString& stageName, EYqlIssueCode issueCode = TIssuesIds::DEFAULT_ERROR, const TString& issueMessage = {}); - TTransformationPipeline& Add(TTransformStage&& stage); TAutoPtr Build(bool useIssueScopes = true); TAutoPtr BuildWithNoArgChecks(bool useIssueScopes = true); diff --git a/ydb/library/yql/dq/integration/yql_dq_integration.h b/ydb/library/yql/dq/integration/yql_dq_integration.h index 36c9c3bcd45e..7765ab128e28 100644 --- a/ydb/library/yql/dq/integration/yql_dq_integration.h +++ b/ydb/library/yql/dq/integration/yql_dq_integration.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -23,6 +22,7 @@ class TJsonValue; namespace NYql { struct TDqSettings; +class TTransformationPipeline; namespace NCommon { class TMkqlCallableCompilerBase; @@ -73,8 +73,8 @@ class IDqIntegration { // Return true if node was handled virtual bool FillSourcePlanProperties(const NNodes::TExprBase& node, TMap& properties) = 0; virtual bool FillSinkPlanProperties(const NNodes::TExprBase& node, TMap& properties) = 0; - // This transformer will be called before DQ peephole transformations - virtual std::vector GetPeepholeTransforms(bool beforeDq, const THashMap& params) = 0; + // Called to configure DQ peephole + virtual void ConfigurePeepholePipeline(bool beforeDqTransforms, const THashMap& params, TTransformationPipeline* pipeline) = 0; }; } // namespace NYql diff --git a/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.cpp b/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.cpp index d145a2b7dacf..6a65150f7f87 100644 --- a/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.cpp +++ b/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.cpp @@ -92,8 +92,7 @@ bool TDqIntegrationBase::FillSinkPlanProperties(const NNodes::TExprBase&, TMap TDqIntegrationBase::GetPeepholeTransforms(bool, const THashMap&) { - return {}; +void TDqIntegrationBase::ConfigurePeepholePipeline(bool, const THashMap&, TTransformationPipeline*) { } } // namespace NYql diff --git a/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.h b/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.h index 4cd160b6d4e8..a2720db03331 100644 --- a/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.h +++ b/ydb/library/yql/providers/common/dq/yql_dq_integration_impl.h @@ -26,7 +26,7 @@ class TDqIntegrationBase: public IDqIntegration { void WriteFullResultTableRef(NYson::TYsonWriter& writer, const TVector& columns, const THashMap& graphParams) override; bool FillSourcePlanProperties(const NNodes::TExprBase& node, TMap& properties) override; bool FillSinkPlanProperties(const NNodes::TExprBase& node, TMap& properties) override; - std::vector GetPeepholeTransforms(bool beforeDq, const THashMap& params) override; + void ConfigurePeepholePipeline(bool beforeDqTransforms, const THashMap& params, TTransformationPipeline* pipeline) override; protected: bool CanBlockReadTypes(const TStructExprType* node); diff --git a/ydb/library/yql/providers/dq/provider/exec/yql_dq_exectransformer.cpp b/ydb/library/yql/providers/dq/provider/exec/yql_dq_exectransformer.cpp index 23ece1ca0ac9..5c1afce66844 100644 --- a/ydb/library/yql/providers/dq/provider/exec/yql_dq_exectransformer.cpp +++ b/ydb/library/yql/providers/dq/provider/exec/yql_dq_exectransformer.cpp @@ -243,13 +243,14 @@ struct TDqsPipelineConfigurator : public IPipelineConfigurator { void AfterCreate(TTransformationPipeline*) const final {} void AfterTypeAnnotation(TTransformationPipeline* pipeline) const final { + // First truncate graph by calculated precomputes + pipeline->Add(NDqs::CreateDqsReplacePrecomputesTransformer(*pipeline->GetTypeAnnotationContext(), State_->FunctionRegistry), "ReplacePrecomputes"); + + // Then apply provider specific transformers on truncated graph std::for_each(UniqIntegrations_.cbegin(), UniqIntegrations_.cend(), [&](const auto dqInt) { - for (auto& stage: dqInt->GetPeepholeTransforms(true, ProviderParams_)) { - pipeline->Add(std::move(stage)); - } + dqInt->ConfigurePeepholePipeline(true, ProviderParams_, pipeline); }); - pipeline->Add(NDqs::CreateDqsReplacePrecomputesTransformer(*pipeline->GetTypeAnnotationContext(), State_->FunctionRegistry), "ReplacePrecomputes"); if (State_->Settings->UseBlockReader.Get().GetOrElse(false)) { pipeline->Add(NDqs::CreateDqsRewritePhyBlockReadOnDqIntegrationTransformer(*pipeline->GetTypeAnnotationContext()), "ReplaceWideReadsWithBlock"); } @@ -274,9 +275,7 @@ struct TDqsPipelineConfigurator : public IPipelineConfigurator { void AfterOptimize(TTransformationPipeline* pipeline) const final { std::for_each(UniqIntegrations_.cbegin(), UniqIntegrations_.cend(), [&](const auto dqInt) { - for (auto& stage: dqInt->GetPeepholeTransforms(false, ProviderParams_)) { - pipeline->Add(std::move(stage)); - } + dqInt->ConfigurePeepholePipeline(false, ProviderParams_, pipeline); }); }