aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@yandex-team.com>2025-05-29 16:00:55 +0300
committervvvv <vvvv@yandex-team.com>2025-05-29 16:29:23 +0300
commita6ee162f366bdaf117eec487b68ee65eb8ccbf54 (patch)
treeafc57d76389a048adedea103a722a977f2a85b2d
parent276ad0632b30660bce752d0193a1beb759af2444 (diff)
downloadydb-a6ee162f366bdaf117eec487b68ee65eb8ccbf54.tar.gz
YQL-20024 better limit of wide width
commit_hash:f635da54623fda4a3de6b196be8522710b204c0d
-rw-r--r--yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp29
-rw-r--r--yt/yql/tests/sql/suites/aggregate/too_wide.sql122
2 files changed, 143 insertions, 8 deletions
diff --git a/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp b/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp
index 2759510b09a..3f62f755562 100644
--- a/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp
+++ b/yql/essentials/core/peephole_opt/yql_opt_peephole_physical.cpp
@@ -4263,12 +4263,15 @@ TExprNode::TPtr OptimizeExpandMap(const TExprNode::TPtr& node, TExprContext& ctx
input.Child(4U)->Tail().IsCallable("Just") && ETypeAnnotationKind::Struct == input.Child(4U)->Tail().Head().GetTypeAnn()->GetKind()) {
if (const auto inItemType = GetSeqItemType(input.Head().GetTypeAnn()); ETypeAnnotationKind::Struct == inItemType->GetKind()) {
if (const auto inStructType = inItemType->Cast<TStructExprType>(); inStructType->GetSize() > 0U) {
- YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << input.Content();
-
const auto& output = input.Child(4U)->Tail().Head();
const auto structType = output.GetTypeAnn()->Cast<TStructExprType>();
const auto outputWidth = structType->GetSize();
+ if (outputWidth > WideLimit) {
+ return node;
+ }
+
+ YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << input.Content();
const auto inputWidth = inStructType->GetSize();
TExprNode::TListType inputFilelds, stateFields, outputFields, init, update, finish;
@@ -4660,12 +4663,15 @@ TExprNode::TPtr OptimizeMember(const TExprNode::TPtr& node, TExprContext& ctx) {
TExprNode::TPtr OptimizeCondense1(const TExprNode::TPtr& node, TExprContext& ctx) {
if (node->Head().IsCallable("NarrowMap") &&
ETypeAnnotationKind::Struct == node->Tail().Tail().GetTypeAnn()->GetKind()) {
- YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << node->Head().Content();
const auto inputWidth = node->Head().Tail().Head().ChildrenSize();
TExprNode::TListType fields, init, update;
const auto outputWidth = CollectStateNodes(*node->Child(1U), node->Tail(), fields, init, update, ctx);
+ if (outputWidth > WideLimit) {
+ return node;
+ }
+ YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << node->Head().Content();
return ctx.Builder(node->Pos())
.Callable("NarrowMap")
.Callable(0, "WideCondense1")
@@ -4751,14 +4757,16 @@ TExprNode::TPtr OptimizeCondense1(const TExprNode::TPtr& node, TExprContext& ctx
TExprNode::TPtr OptimizeCombineCore(const TExprNode::TPtr& node, TExprContext& ctx) {
if (node->Head().IsCallable("NarrowMap") && node->Child(4U)->Tail().IsCallable("Just")) {
- YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << node->Head().Content();
-
const auto& output = node->Child(4U)->Tail().Head();
const auto inputWidth = node->Head().Tail().Head().ChildrenSize();
const auto structType = ETypeAnnotationKind::Struct == output.GetTypeAnn()->GetKind() ? output.GetTypeAnn()->Cast<TStructExprType>() : nullptr;
const auto outputWidth = structType ? structType->GetSize() : 1U;
+ if (outputWidth > WideLimit) {
+ return node;
+ }
+ YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << node->Head().Content();
TExprNode::TListType stateFields, outputFields, init, update, finish;
outputFields.reserve(outputWidth);
finish.reserve(outputWidth);
@@ -5064,12 +5072,17 @@ TExprNode::TPtr OptimizeChopper(const TExprNode::TPtr& node, TExprContext& ctx)
node->Tail().GetTypeAnn()->GetKind() == ETypeAnnotationKind::Flow &&
node->Tail().GetTypeAnn()->Cast<TFlowExprType>()->GetItemType()->GetKind() == ETypeAnnotationKind::Struct &&
node->Tail().GetTypeAnn()->Cast<TFlowExprType>()->GetItemType()->Cast<TStructExprType>()->GetSize() > 0U) {
- YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << node->Head().Content();
const auto inputWidth = node->Head().Tail().Head().ChildrenSize();
const auto structType = node->Tail().GetTypeAnn()->Cast<TFlowExprType>()->GetItemType()->Cast<TStructExprType>();
const auto outputWidth = structType->GetSize();
+ if (outputWidth > WideLimit) {
+ return node;
+ }
+
+ YQL_CLOG(DEBUG, CorePeepHole) << "Swap " << node->Content() << " with " << node->Head().Content();
+
TExprNode::TListType fields;
fields.reserve(outputWidth);
for (const auto& item : structType->GetItems())
@@ -5665,9 +5678,9 @@ TExprNode::TPtr OptimizeWideCombiner(const TExprNode::TPtr& node, TExprContext&
if (needKeyFlatten.front()) {
const auto flattenSize = *needKeyFlatten.front();
- if (flattenSize > WideLimit) {
+ /*if (flattenSize > WideLimit) { don't emit wide combiner with too many keys
return node;
- }
+ }*/
YQL_CLOG(DEBUG, CorePeepHole) << "Flatten key by tuple for " << node->Content() << " from " << originalKeySize << " to " << flattenSize;
auto children = node->ChildrenList();
diff --git a/yt/yql/tests/sql/suites/aggregate/too_wide.sql b/yt/yql/tests/sql/suites/aggregate/too_wide.sql
new file mode 100644
index 00000000000..71b4319224a
--- /dev/null
+++ b/yt/yql/tests/sql/suites/aggregate/too_wide.sql
@@ -0,0 +1,122 @@
+use plato;
+
+select * from (select cast(value as Int32) as value from Input) group by
+value+0,
+value+1,
+value+2,
+value+3,
+value+4,
+value+5,
+value+6,
+value+7,
+value+8,
+value+9,
+value+10,
+value+11,
+value+12,
+value+13,
+value+14,
+value+15,
+value+16,
+value+17,
+value+18,
+value+19,
+value+20,
+value+21,
+value+22,
+value+23,
+value+24,
+value+25,
+value+26,
+value+27,
+value+28,
+value+29,
+value+30,
+value+31,
+value+32,
+value+33,
+value+34,
+value+35,
+value+36,
+value+37,
+value+38,
+value+39,
+value+40,
+value+41,
+value+42,
+value+43,
+value+44,
+value+45,
+value+46,
+value+47,
+value+48,
+value+49,
+value+50,
+value+51,
+value+52,
+value+53,
+value+54,
+value+55,
+value+56,
+value+57,
+value+58,
+value+59,
+value+60,
+value+61,
+value+62,
+value+63,
+value+64,
+value+65,
+value+66,
+value+67,
+value+68,
+value+69,
+value+70,
+value+71,
+value+72,
+value+73,
+value+74,
+value+75,
+value+76,
+value+77,
+value+78,
+value+79,
+value+80,
+value+81,
+value+82,
+value+83,
+value+84,
+value+85,
+value+86,
+value+87,
+value+88,
+value+89,
+value+90,
+value+91,
+value+92,
+value+93,
+value+94,
+value+95,
+value+96,
+value+97,
+value+98,
+value+99,
+value+100,
+value+101,
+value+102,
+value+103,
+value+104,
+value+105,
+value+106,
+value+107,
+value+108,
+value+109,
+value+110,
+value+111,
+value+112,
+value+113,
+value+114,
+value+115,
+value+116,
+value+117,
+value+118