diff options
author | vvvv <vvvv@ydb.tech> | 2022-10-13 20:26:24 +0300 |
---|---|---|
committer | vvvv <vvvv@ydb.tech> | 2022-10-13 20:26:24 +0300 |
commit | 2177049175218651b61a5003dbc8404d1fcffc6d (patch) | |
tree | b9980eed96930df516d2745d5d879d866a3408c0 | |
parent | 8c73d2dbb962db9f42899beb19eb98f290173dee (diff) | |
download | ydb-2177049175218651b61a5003dbc8404d1fcffc6d.tar.gz |
init+save should be used over distincts
-rw-r--r-- | ydb/library/yql/core/yql_aggregate_expander.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/ydb/library/yql/core/yql_aggregate_expander.cpp b/ydb/library/yql/core/yql_aggregate_expander.cpp index a9289372513..295e66fac5a 100644 --- a/ydb/library/yql/core/yql_aggregate_expander.cpp +++ b/ydb/library/yql/core/yql_aggregate_expander.cpp @@ -1973,7 +1973,50 @@ TExprNode::TPtr TAggregateExpander::GeneratePhases() { .Seal(); } - GenerateInitForDistinct(parent, pos, indicies, distinctField); + for (ui32 i: indicies) { + auto trait = Traits[i]; + auto initLambda = trait->Child(1); + auto saveLambda = trait->Child(3); + if (initLambda->Head().ChildrenSize() == 1) { + parent.List(pos++) + .Add(0, InitialColumnNames[i]) + .Apply(1, *saveLambda) + .With(0) + .Apply(*initLambda) + .With(0) + .Callable("Member") + .Arg(0, "item") + .Add(1, distinctField) + .Seal() + .Done() + .Seal() + .Done() + .Seal() + .Seal(); + } else { + parent.List(pos++) + .Add(0, InitialColumnNames[i]) + .Apply(1, *saveLambda) + .With(0) + .Apply(*initLambda) + .With(0) + .Callable("Member") + .Arg(0, "item") + .Add(1, distinctField) + .Seal() + .Done() + .With(1) + .Callable("Uint32") + .Atom(0, ToString(i), TNodeFlags::Default) + .Seal() + .Done() + .Seal() + .Done() + .Seal() + .Seal(); + } + } + return parent; }) .Seal() |