diff options
author | a-romanov <Anton.Romanov@ydb.tech> | 2023-04-17 14:49:06 +0300 |
---|---|---|
committer | a-romanov <Anton.Romanov@ydb.tech> | 2023-04-17 14:49:06 +0300 |
commit | fa6ae2b70fc772e6565490de49a1ba127051d55e (patch) | |
tree | 26d21cb27871c9147cb6bf685cf0441560990381 | |
parent | 48f39417d2f45675bd9f661122c1f46ec0d82740 (diff) | |
download | ydb-fa6ae2b70fc772e6565490de49a1ba127051d55e.tar.gz |
YQL-15864 YQL-15415 Drop DqUnorderedInStage optimizer.
-rw-r--r-- | ydb/library/yql/core/yql_opt_utils.cpp | 70 | ||||
-rw-r--r-- | ydb/library/yql/core/yql_opt_utils.h | 2 | ||||
-rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_log.cpp | 18 | ||||
-rw-r--r-- | ydb/library/yql/dq/opt/dq_opt_log.h | 3 | ||||
-rw-r--r-- | ydb/library/yql/providers/dq/opt/logical_optimize.cpp | 5 |
5 files changed, 0 insertions, 98 deletions
diff --git a/ydb/library/yql/core/yql_opt_utils.cpp b/ydb/library/yql/core/yql_opt_utils.cpp index c0c1bdfd1d..33ff385011 100644 --- a/ydb/library/yql/core/yql_opt_utils.cpp +++ b/ydb/library/yql/core/yql_opt_utils.cpp @@ -1348,76 +1348,6 @@ bool WarnUnroderedSubquery(const TExprNode& unourderedSubquery, TExprContext& ct return ctx.AddWarning(issue); } -IGraphTransformer::TStatus LocalUnorderedOptimize(TExprNode::TPtr input, TExprNode::TPtr& output, const std::function<bool(const TExprNode*)>& stopTraverse, TExprContext& ctx, TTypeAnnotationContext* typeCtx) { - output = input; - TProcessedNodesSet processedNodes; - bool hasUnordered = false; - VisitExpr(input, [&stopTraverse, &processedNodes, &hasUnordered](const TExprNode::TPtr& node) { - if (stopTraverse(node.Get())) { - processedNodes.insert(node->UniqueId()); - return false; - } - else if (TCoUnorderedBase::Match(node.Get())) { - hasUnordered = true; - } - return true; - }); - if (!hasUnordered) { - return IGraphTransformer::TStatus::Ok; - } - - TOptimizeExprSettings settings(typeCtx); - settings.ProcessedNodes = &processedNodes; // Prevent optimizer to go deeper - - static THashSet<TStringBuf> CALLABLE = { - "AssumeUnique", "AssumeDistinct", - "Map", "OrderedMap", - "Filter", "OrderedFilter", - "FlatMap", "OrderedFlatMap", - "FoldMap", "Fold1Map", "Chain1Map", - "Take", "Skip", - "TakeWhile", "SkipWhile", - "TakeWhileInclusive", "SkipWhileInclusive", - "SkipNullMembers", "FilterNullMembers", - "SkipNullElements", "FilterNullElements", - "Condense", "Condense1", - "MapJoinCore", "CommonJoinCore", - "CombineCore", "ExtractMembers", - "PartitionByKey", "PartitionsByKeys", - "FromFlow", "ToFlow", "Collect", "Iterator"}; - static THashSet<TStringBuf> SORTED = {"AssumeSorted", "Sort"}; - - auto status = OptimizeExpr(input, output, [&](const TExprNode::TPtr& node, TExprContext& ctx) -> TExprNode::TPtr { - if (TCoUnorderedBase::Match(node.Get())) { - if (node->Head().IsCallable(CALLABLE)) { - auto res = ctx.SwapWithHead(*node); - auto name = res->Content(); - if (name.SkipPrefix("Ordered")) { - res = ctx.RenameNode(*res, name); - } - return res; - } - if (node->Head().IsCallable(SORTED)) { - return node->Head().HeadPtr(); - } - } - - return node; - }, ctx, settings); - - if (status.Level == IGraphTransformer::TStatus::Error) { - return status; - } - - if (input != output && input->IsLambda()) { - output = ctx.DeepCopyLambda(*output); - status = status.Combine(IGraphTransformer::TStatus::Repeat); - } - - return status; - -} - std::pair<TExprNode::TPtr, TExprNode::TPtr> ReplaceDependsOn(TExprNode::TPtr lambda, TExprContext& ctx, TTypeAnnotationContext* typeCtx) { auto placeHolder = ctx.NewArgument(lambda->Pos(), "placeholder"); diff --git a/ydb/library/yql/core/yql_opt_utils.h b/ydb/library/yql/core/yql_opt_utils.h index c71c35647e..caa29d0e49 100644 --- a/ydb/library/yql/core/yql_opt_utils.h +++ b/ydb/library/yql/core/yql_opt_utils.h @@ -110,8 +110,6 @@ TExprNode::TPtr OptimizeIfPresent(const TExprNode::TPtr& node, TExprContext& ctx TExprNode::TPtr OptimizeExists(const TExprNode::TPtr& node, TExprContext& ctx); bool WarnUnroderedSubquery(const TExprNode& unourderedSubquery, TExprContext& ctx); -IGraphTransformer::TStatus LocalUnorderedOptimize(TExprNode::TPtr input, TExprNode::TPtr& output, - const std::function<bool(const TExprNode*)>& stopTraverse, TExprContext& ctx, TTypeAnnotationContext* typeCtx); std::pair<TExprNode::TPtr, TExprNode::TPtr> ReplaceDependsOn(TExprNode::TPtr lambda, TExprContext& ctx, TTypeAnnotationContext* typeCtx); diff --git a/ydb/library/yql/dq/opt/dq_opt_log.cpp b/ydb/library/yql/dq/opt/dq_opt_log.cpp index ff50790156..4787cc1b11 100644 --- a/ydb/library/yql/dq/opt/dq_opt_log.cpp +++ b/ydb/library/yql/dq/opt/dq_opt_log.cpp @@ -217,24 +217,6 @@ NNodes::TExprBase DqMergeQueriesWithSinks(NNodes::TExprBase dqQueryNode, TExprCo return dqQueryNode; } -NNodes::TMaybeNode<NNodes::TExprBase> DqUnorderedInStage(NNodes::TExprBase node, - const std::function<bool(const TExprNode*)>& stopTraverse, TExprContext& ctx, TTypeAnnotationContext* typeCtx) -{ - auto stage = node.Cast<TDqStageBase>(); - - TExprNode::TPtr newProgram; - auto status = LocalUnorderedOptimize(stage.Program().Ptr(), newProgram, stopTraverse, ctx, typeCtx); - if (status.Level == IGraphTransformer::TStatus::Error) { - return {}; - } - - if (stage.Program().Ptr() != newProgram) { - return NNodes::TExprBase(ctx.ChangeChild(node.Ref(), TDqStageBase::idx_Program, std::move(newProgram))); - } - - return node; -} - NNodes::TExprBase DqFlatMapOverExtend(NNodes::TExprBase node, TExprContext& ctx) { auto maybeFlatMap = node.Maybe<TCoFlatMapBase>(); diff --git a/ydb/library/yql/dq/opt/dq_opt_log.h b/ydb/library/yql/dq/opt/dq_opt_log.h index 596ffd80ac..aeadc564fe 100644 --- a/ydb/library/yql/dq/opt/dq_opt_log.h +++ b/ydb/library/yql/dq/opt/dq_opt_log.h @@ -28,9 +28,6 @@ NNodes::TExprBase DqMergeQueriesWithSinks(NNodes::TExprBase dqQueryNode, TExprCo NNodes::TExprBase DqFlatMapOverExtend(NNodes::TExprBase node, TExprContext& ctx); -NNodes::TMaybeNode<NNodes::TExprBase> DqUnorderedInStage(NNodes::TExprBase node, - const std::function<bool(const TExprNode*)>& stopTraverse, TExprContext& ctx, TTypeAnnotationContext* typeCtx); - NNodes::TExprBase DqSqlInDropCompact(NNodes::TExprBase node, TExprContext& ctx); IGraphTransformer::TStatus DqWrapRead(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExprContext& ctx, TTypeAnnotationContext& typesCtx, const TDqSettings& config); diff --git a/ydb/library/yql/providers/dq/opt/logical_optimize.cpp b/ydb/library/yql/providers/dq/opt/logical_optimize.cpp index e2b02648cc..a5afeb0484 100644 --- a/ydb/library/yql/providers/dq/opt/logical_optimize.cpp +++ b/ydb/library/yql/providers/dq/opt/logical_optimize.cpp @@ -59,7 +59,6 @@ public: AddHandler(0, &TCoCalcOverWindowGroup::Match, HNDL(ExpandWindowFunctions)); AddHandler(0, &TCoFlatMapBase::Match, HNDL(FlatMapOverExtend)); AddHandler(0, &TDqQuery::Match, HNDL(MergeQueriesWithSinks)); - AddHandler(0, &TDqStageBase::Match, HNDL(UnorderedInStage)); AddHandler(0, &TCoSqlIn::Match, HNDL(SqlInDropCompact)); #undef HNDL } @@ -139,10 +138,6 @@ protected: return DqMergeQueriesWithSinks(node, ctx); } - TMaybeNode<TExprBase> UnorderedInStage(TExprBase node, TExprContext& ctx) const { - return DqUnorderedInStage(node, TDqReadWrapBase::Match, ctx, Types); - } - TMaybeNode<TExprBase> SqlInDropCompact(TExprBase node, TExprContext& ctx) const { return DqSqlInDropCompact(node, ctx); } |