diff options
author | a-romanov <Anton.Romanov@ydb.tech> | 2023-04-25 11:40:52 +0300 |
---|---|---|
committer | a-romanov <Anton.Romanov@ydb.tech> | 2023-04-25 11:40:52 +0300 |
commit | dfed128c2a0ff861bd5ee54c046e4cc7f955e229 (patch) | |
tree | 3c726cab34b6f5c67247d4722b0300817d2f3d4b | |
parent | 79d61286efe6199726d310ceca583741a0c21caf (diff) | |
download | ydb-dfed128c2a0ff861bd5ee54c046e4cc7f955e229.tar.gz |
YQL-8971 YQL-15435 Disable constraints check on peephole final stage.
5 files changed, 17 insertions, 11 deletions
diff --git a/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp b/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp index 9077a8531f1..8866afc300f 100644 --- a/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp +++ b/ydb/library/yql/core/peephole_opt/yql_opt_peephole_physical.cpp @@ -2069,6 +2069,7 @@ IGraphTransformer::TStatus PeepHoleBlockStage(const TExprNode::TPtr& input, TExp }, ctx, settings); } +template<bool FinalStage> void AddStandardTransformers(TTransformationPipeline& pipelene, IGraphTransformer* typeAnnotator) { auto issueCode = TIssuesIds::CORE_EXEC; pipelene.AddServiceTransformers(issueCode); @@ -2078,7 +2079,7 @@ void AddStandardTransformers(TTransformationPipeline& pipelene, IGraphTransforme pipelene.AddTypeAnnotationTransformer(issueCode); } - pipelene.AddPostTypeAnnotation(true, issueCode); + pipelene.AddPostTypeAnnotation(true, FinalStage, issueCode); pipelene.Add(TExprLogTransformer::Sync("PeepHoleOpt", NLog::EComponent::CorePeepHole, NLog::ELevel::TRACE), "PeepHoleOptTrace", issueCode, "PeepHoleOptTrace"); } @@ -7271,7 +7272,7 @@ THolder<IGraphTransformer> CreatePeepHoleCommonStageTransformer(TTypeAnnotationC peepholeSettings.CommonConfig->AfterCreate(&pipeline); } - AddStandardTransformers(pipeline, typeAnnotator); + AddStandardTransformers<false>(pipeline, typeAnnotator); if (peepholeSettings.CommonConfig) { peepholeSettings.CommonConfig->AfterTypeAnnotation(&pipeline); } @@ -7306,7 +7307,7 @@ THolder<IGraphTransformer> CreatePeepHoleFinalStageTransformer(TTypeAnnotationCo peepholeSettings.FinalConfig->AfterCreate(&pipeline); } - AddStandardTransformers(pipeline, typeAnnotator); + AddStandardTransformers<true>(pipeline, typeAnnotator); if (peepholeSettings.FinalConfig) { peepholeSettings.FinalConfig->AfterTypeAnnotation(&pipeline); } diff --git a/ydb/library/yql/core/services/yql_transform_pipeline.cpp b/ydb/library/yql/core/services/yql_transform_pipeline.cpp index ae425f34c8e..bc87e1ff56d 100644 --- a/ydb/library/yql/core/services/yql_transform_pipeline.cpp +++ b/ydb/library/yql/core/services/yql_transform_pipeline.cpp @@ -111,9 +111,9 @@ TTransformationPipeline& TTransformationPipeline::AddTypeAnnotation(EYqlIssueCod return *this; } -TTransformationPipeline& TTransformationPipeline::AddPostTypeAnnotation(bool forSubGraph, EYqlIssueCode issueCode) { +TTransformationPipeline& TTransformationPipeline::AddPostTypeAnnotation(bool forSubGraph, bool disableConstraintCheck, EYqlIssueCode issueCode) { Transformers_.push_back(TTransformStage( - CreateConstraintTransformer(*TypeAnnotationContext_, false, forSubGraph), "Constraints", issueCode)); + CreateConstraintTransformer(*TypeAnnotationContext_, false, forSubGraph, disableConstraintCheck), "Constraints", issueCode)); Transformers_.push_back(TTransformStage( CreateFunctorTransformer( [](const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx) { diff --git a/ydb/library/yql/core/services/yql_transform_pipeline.h b/ydb/library/yql/core/services/yql_transform_pipeline.h index 7e2f5c911e6..eb3e035c5ce 100644 --- a/ydb/library/yql/core/services/yql_transform_pipeline.h +++ b/ydb/library/yql/core/services/yql_transform_pipeline.h @@ -30,7 +30,7 @@ public: TTransformationPipeline& AddPreIOAnnotation(EYqlIssueCode issueCode = TIssuesIds::CORE_PRE_TYPE_ANN); TTransformationPipeline& AddIOAnnotation(EYqlIssueCode issueCode = TIssuesIds::CORE_PRE_TYPE_ANN); TTransformationPipeline& AddTypeAnnotation(EYqlIssueCode issueCode = TIssuesIds::CORE_TYPE_ANN); - TTransformationPipeline& AddPostTypeAnnotation(bool forSubGraph = false, EYqlIssueCode issueCode = TIssuesIds::CORE_POST_TYPE_ANN); + TTransformationPipeline& AddPostTypeAnnotation(bool forSubGraph = false, bool disableConstraintCheck = false, EYqlIssueCode issueCode = TIssuesIds::CORE_POST_TYPE_ANN); TTransformationPipeline& AddCommonOptimization(EYqlIssueCode issueCode = TIssuesIds::CORE_OPTIMIZATION); TTransformationPipeline& AddFinalCommonOptimization(EYqlIssueCode issueCode = TIssuesIds::CORE_OPTIMIZATION); TTransformationPipeline& AddOptimization(bool checkWorld = true, bool withFinalOptimization = true, EYqlIssueCode issueCode = TIssuesIds::CORE_OPTIMIZATION); diff --git a/ydb/library/yql/core/yql_expr_constraint.cpp b/ydb/library/yql/core/yql_expr_constraint.cpp index 48c8603f167..2bbb590404c 100644 --- a/ydb/library/yql/core/yql_expr_constraint.cpp +++ b/ydb/library/yql/core/yql_expr_constraint.cpp @@ -2648,7 +2648,7 @@ private: } } } - } else if (auto l = GetPathToKey(SkipCallables(body.Head(), {"Length"}), args), r = GetPathToKey(SkipCallables(body.Tail(), {"Length"}), args); l && r && *l == *r) { + } else if (auto l = GetPathToKey(body.Head(), args), r = GetPathToKey(body.Tail(), args); l && r && *l == *r) { if constexpr (Wide) { auto path = l->first; path.emplace_front(ctx.GetIndexAsString(l->second)); @@ -3373,6 +3373,7 @@ public: } }; +template<bool DisableCheck> class TConstraintTransformer : public TGraphTransformerBase { public: TConstraintTransformer(TAutoPtr<IGraphTransformer> callableTransformer, TTypeAnnotationContext& types) @@ -3758,6 +3759,9 @@ private: } void CheckExpected(const TExprNode& input, TExprContext& ctx) { + if constexpr (DisableCheck) + return; + if (const auto it = Types.ExpectedConstraints.find(input.UniqueId()); it != Types.ExpectedConstraints.cend()) { for (const TConstraintNode* expectedConstr: it->second) { if (!Types.DisableConstraintCheck.contains(expectedConstr->GetName())) { @@ -3786,7 +3790,6 @@ private: } } } - private: TAutoPtr<IGraphTransformer> CallableTransformer; std::deque<TExprNode::TPtr> CallableInputs; @@ -3798,9 +3801,11 @@ private: } // namespace -TAutoPtr<IGraphTransformer> CreateConstraintTransformer(TTypeAnnotationContext& types, bool instantOnly, bool subGraph) { +TAutoPtr<IGraphTransformer> CreateConstraintTransformer(TTypeAnnotationContext& types, bool instantOnly, bool subGraph, bool disableCheck) { TAutoPtr<IGraphTransformer> callableTransformer(new TCallableConstraintTransformer(types, instantOnly, subGraph)); - return new TConstraintTransformer(callableTransformer, types); + return disableCheck ? + static_cast<IGraphTransformer*>(new TConstraintTransformer<true>(callableTransformer, types)): + static_cast<IGraphTransformer*>(new TConstraintTransformer<false>(callableTransformer, types)); } TAutoPtr<IGraphTransformer> CreateDefCallableConstraintTransformer() { diff --git a/ydb/library/yql/core/yql_expr_constraint.h b/ydb/library/yql/core/yql_expr_constraint.h index 76f64608ab3..f11f1603a32 100644 --- a/ydb/library/yql/core/yql_expr_constraint.h +++ b/ydb/library/yql/core/yql_expr_constraint.h @@ -10,7 +10,7 @@ namespace NYql { -TAutoPtr<IGraphTransformer> CreateConstraintTransformer(TTypeAnnotationContext& types, bool instantOnly = false, bool subGraph = false); +TAutoPtr<IGraphTransformer> CreateConstraintTransformer(TTypeAnnotationContext& types, bool instantOnly = false, bool subGraph = false, bool disableCheck = false); TAutoPtr<IGraphTransformer> CreateDefCallableConstraintTransformer(); IGraphTransformer::TStatus UpdateLambdaConstraints(const TExprNode& lambda); |