diff options
author | aneporada <aneporada@ydb.tech> | 2023-10-16 11:45:58 +0300 |
---|---|---|
committer | aneporada <aneporada@ydb.tech> | 2023-10-16 12:31:34 +0300 |
commit | 0c5dd1a2fe6d964b0b7bac8bc2fe671fe1b4ac87 (patch) | |
tree | 8efc3c450c242e182d08bd75a6e0ff4fb9336e50 | |
parent | 2adc87fd5e5f06e2068c2e095bc9c8355e5ed52d (diff) | |
download | ydb-0c5dd1a2fe6d964b0b7bac8bc2fe671fe1b4ac87.tar.gz |
Remove unneded check
-rw-r--r-- | ydb/library/yql/core/common_opt/yql_co_simple1.cpp | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp index 601f1c764a..042057c32f 100644 --- a/ydb/library/yql/core/common_opt/yql_co_simple1.cpp +++ b/ydb/library/yql/core/common_opt/yql_co_simple1.cpp @@ -3048,48 +3048,45 @@ TExprNode::TPtr Normalize(const TCoAggregate& node, TExprContext& ctx) { TExprNode::TPtr aggTupleNode = aggTuple.Ptr(); if (needRebuildNames && aggTuple.Trait().Maybe<TCoAggregationTraits>()) { auto traits = aggTuple.Trait().Cast<TCoAggregationTraits>(); - const TTypeAnnotationNode* finishType = traits.FinishHandler().Ref().GetTypeAnn(); - if (finishType->GetKind() == ETypeAnnotationKind::Tuple && finishType->Cast<TTupleExprType>()->GetSize() == names.size()) { - needRebuild = true; - TMap<TStringBuf, size_t> originalIndexes; - for (size_t i = 0; i < names.size(); ++i) { - YQL_ENSURE(originalIndexes.insert({ names[i], i}).second); - } - YQL_ENSURE(names.size() == originalIndexes.size()); - - TExprNodeList nameNodes; - TExprNodeList finishBody; - TExprNode::TPtr arg = ctx.NewArgument(traits.FinishHandler().Pos(), "arg"); - auto originalTuple = ctx.Builder(traits.FinishHandler().Pos()) - .Apply(traits.FinishHandler().Ref()) - .With(0, arg) - .Seal() - .Build(); + needRebuild = true; + TMap<TStringBuf, size_t> originalIndexes; + for (size_t i = 0; i < names.size(); ++i) { + YQL_ENSURE(originalIndexes.insert({ names[i], i}).second); + } + YQL_ENSURE(names.size() == originalIndexes.size()); + + TExprNodeList nameNodes; + TExprNodeList finishBody; + TExprNode::TPtr arg = ctx.NewArgument(traits.FinishHandler().Pos(), "arg"); + auto originalTuple = ctx.Builder(traits.FinishHandler().Pos()) + .Apply(traits.FinishHandler().Ref()) + .With(0, arg) + .Seal() + .Build(); - for (auto& [name, idx] : originalIndexes) { - nameNodes.emplace_back(ctx.NewAtom(aggTuple.ColumnName().Pos(), name)); - finishBody.emplace_back(ctx.Builder(traits.FinishHandler().Pos()) - .Callable("Nth") - .Add(0, originalTuple) - .Atom(1, idx) - .Seal() - .Build()); - } + for (auto& [name, idx] : originalIndexes) { + nameNodes.emplace_back(ctx.NewAtom(aggTuple.ColumnName().Pos(), name)); + finishBody.emplace_back(ctx.Builder(traits.FinishHandler().Pos()) + .Callable("Nth") + .Add(0, originalTuple) + .Atom(1, idx) + .Seal() + .Build()); + } - auto finishLambda = ctx.NewLambda(traits.FinishHandler().Pos(), - ctx.NewArguments(traits.FinishHandler().Pos(), { arg }), - (originalIndexes.size() == 1) ? finishBody.front() : ctx.NewList(traits.FinishHandler().Pos(), std::move(finishBody))); + auto finishLambda = ctx.NewLambda(traits.FinishHandler().Pos(), + ctx.NewArguments(traits.FinishHandler().Pos(), { arg }), + (originalIndexes.size() == 1) ? finishBody.front() : ctx.NewList(traits.FinishHandler().Pos(), std::move(finishBody))); - aggTupleNode = Build<TCoAggregateTuple>(ctx, aggTuple.Pos()) - .InitFrom(aggTuple) - .ColumnName((originalIndexes.size() == 1) ? nameNodes.front() : ctx.NewList(aggTuple.ColumnName().Pos(), std::move(nameNodes))) - .Trait<TCoAggregationTraits>() - .InitFrom(traits) - .FinishHandler(finishLambda) - .Build() - .Done().Ptr(); - Sort(names); - } + aggTupleNode = Build<TCoAggregateTuple>(ctx, aggTuple.Pos()) + .InitFrom(aggTuple) + .ColumnName((originalIndexes.size() == 1) ? nameNodes.front() : ctx.NewList(aggTuple.ColumnName().Pos(), std::move(nameNodes))) + .Trait<TCoAggregationTraits>() + .InitFrom(traits) + .FinishHandler(finishLambda) + .Build() + .Done().Ptr(); + Sort(names); } YQL_ENSURE(!names.empty()); |