Skip to content

Commit e0d1d96

Browse files
committed
Enable auto-block mode by default (ydb-platform#7567)
(cherry picked from commit 898a9ff)
1 parent 958ddcb commit e0d1d96

File tree

557 files changed

+48440
-39269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

557 files changed

+48440
-39269
lines changed

ydb/core/kqp/opt/kqp_query_plan.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ class TxPlanSerializer {
467467
if (!TryFromString(wideColumnName, idx)) {
468468
return wideColumnName;
469469
}
470+
471+
YQL_ENSURE(idx < settings.OutputNarrowType->GetSize(),
472+
"Failed to lookup column name for index " << idx << " in type " << settings.OutputNarrowType->ToString());
473+
470474
return TString(settings.OutputNarrowType->GetItems()[idx]->GetName());
471475
};
472476

ydb/core/kqp/opt/peephole/kqp_opt_peephole.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@ bool CanPropagateWideBlockThroughChannel(
276276
return false;
277277
}
278278

279-
auto outputItemType = program.Lambda().Ref().GetTypeAnn()->Cast<TStreamExprType>()->GetItemType();
280-
if (IsWideBlockType(*outputItemType)) {
281-
// output is already wide block
282-
return false;
283-
}
284-
285279
if (!stageSettings.WideChannels) {
286280
return false;
287281
}
@@ -299,6 +293,15 @@ bool CanPropagateWideBlockThroughChannel(
299293
return false;
300294
}
301295

296+
auto typeAnnotation = program.Lambda().Ref().GetTypeAnn();
297+
298+
YQL_ENSURE(typeAnnotation, "Program for stage " << output.Stage().Ref().UniqueId() << " doesn't have type annotation");
299+
300+
if (IsWideBlockType(*typeAnnotation->Cast<TStreamExprType>()->GetItemType())) {
301+
// output is already wide block
302+
return false;
303+
}
304+
302305
return true;
303306
}
304307

@@ -438,8 +441,6 @@ TMaybeNode<TKqpPhysicalTx> PeepholeOptimize(const TKqpPhysicalTx& tx, TExprConte
438441
.ArgsType(ExpandType(stage.Pos(), *ctx.MakeType<TTupleExprType>(argTypes), ctx))
439442
.Done();
440443

441-
YQL_ENSURE(programs.emplace(stage.Ref().UniqueId(), program).second);
442-
443444
const bool allowNonDeterministicFunctions = !program.Lambda().Body().Maybe<TKqpEffects>();
444445

445446
TExprNode::TPtr newProgram;
@@ -461,7 +462,7 @@ TMaybeNode<TKqpPhysicalTx> PeepholeOptimize(const TKqpPhysicalTx& tx, TExprConte
461462
}
462463

463464
optimizedStages.emplace(stage.Ref().UniqueId());
464-
programs.at(stage.Ref().UniqueId()) = TKqpProgram(newProgram);
465+
YQL_ENSURE(programs.emplace(stage.Ref().UniqueId(), TKqpProgram(newProgram)).second);
465466
}
466467

467468
TVector<TKqpParamBinding> bindings(tx.ParamBindings().begin(), tx.ParamBindings().end());

ydb/core/kqp/ut/query/kqp_limits_ut.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ Y_UNIT_TEST_SUITE(KqpLimits) {
10141014

10151015
UNIT_ASSERT_VALUES_EQUAL(plan["Plan"]["Node Type"].GetStringSafe(), "Query");
10161016
UNIT_ASSERT_VALUES_EQUAL(plan["Plan"]["Plans"][0]["Node Type"].GetStringSafe(), "ResultSet");
1017-
UNIT_ASSERT_VALUES_EQUAL(plan["Plan"]["Plans"][0]["Plans"][0]["Node Type"].GetStringSafe(), "Collect");
1017+
UNIT_ASSERT_VALUES_EQUAL(plan["Plan"]["Plans"][0]["Plans"][0]["Node Type"].GetStringSafe(), "Stage");
10181018
UNIT_ASSERT_VALUES_EQUAL(plan["Plan"]["Plans"][0]["Plans"][0]["Plans"][0]["Node Type"].GetStringSafe(), "Merge");
10191019
UNIT_ASSERT_VALUES_EQUAL(plan["Plan"]["Plans"][0]["Plans"][0]["Plans"][0]["SortColumns"].GetArraySafe()[0], "Key (Asc)");
10201020

ydb/core/protos/table_service_config.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ message TTableServiceConfig {
297297
BLOCK_CHANNELS_AUTO = 1;
298298
BLOCK_CHANNELS_FORCE = 2;
299299
}
300-
optional EBlockChannelsMode BlockChannelsMode = 61 [default = BLOCK_CHANNELS_SCALAR];
300+
optional EBlockChannelsMode BlockChannelsMode = 61 [default = BLOCK_CHANNELS_AUTO];
301301

302302
optional uint64 QueryReplayCacheUploadTTLSec = 62 [default = 36000];
303303

ydb/tests/functional/canonical/canondata/test_sql.TestCanonicalFolder1.test_case_join_group_by_lookup.script-script_/join_group_by_lookup.script.plan

+50-41
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"Plans": [
1212
{
1313
"Node Type": "ResultSet_2",
14-
"PlanNodeId": 20,
14+
"PlanNodeId": 21,
1515
"PlanNodeType": "ResultSet",
1616
"Plans": [
1717
{
@@ -20,18 +20,18 @@
2020
{
2121
"Inputs": [
2222
{
23-
"ExternalPlanNodeId": 18
23+
"ExternalPlanNodeId": 19
2424
}
2525
],
2626
"Limit": "1001",
2727
"Name": "Limit"
2828
}
2929
],
30-
"PlanNodeId": 19,
30+
"PlanNodeId": 20,
3131
"Plans": [
3232
{
3333
"Node Type": "Merge",
34-
"PlanNodeId": 18,
34+
"PlanNodeId": 19,
3535
"PlanNodeType": "Connection",
3636
"Plans": [
3737
{
@@ -48,23 +48,23 @@
4848
"TopSortBy": ""
4949
},
5050
{
51-
"Condition": "a.Group = t.Group",
51+
"Condition": "Group = Group",
5252
"Inputs": [
5353
{
54-
"ExternalPlanNodeId": 16
54+
"ExternalPlanNodeId": 17
5555
},
5656
{
57-
"ExternalPlanNodeId": 14
57+
"ExternalPlanNodeId": 15
5858
}
5959
],
6060
"Name": "LeftJoin (MapJoin)"
6161
}
6262
],
63-
"PlanNodeId": 17,
63+
"PlanNodeId": 18,
6464
"Plans": [
6565
{
6666
"Node Type": "Map",
67-
"PlanNodeId": 16,
67+
"PlanNodeId": 17,
6868
"PlanNodeType": "Connection",
6969
"Plans": [
7070
{
@@ -73,26 +73,26 @@
7373
"Operators": [
7474
{
7575
"Inputs": [],
76-
"Iterator": "precompute_0_0",
77-
"Name": "Iterator"
76+
"Name": "ToFlow",
77+
"ToFlow": "precompute_0_0"
7878
}
7979
],
80-
"PlanNodeId": 15
80+
"PlanNodeId": 16
8181
}
8282
]
8383
},
8484
{
8585
"Node Type": "Broadcast",
86-
"PlanNodeId": 14,
86+
"PlanNodeId": 15,
8787
"PlanNodeType": "Connection",
8888
"Plans": [
8989
{
90-
"Node Type": "Collect",
91-
"PlanNodeId": 13,
90+
"Node Type": "Stage",
91+
"PlanNodeId": 14,
9292
"Plans": [
9393
{
9494
"Node Type": "UnionAll",
95-
"PlanNodeId": 12,
95+
"PlanNodeId": 13,
9696
"PlanNodeType": "Connection",
9797
"Plans": [
9898
{
@@ -127,7 +127,7 @@
127127
"Name": "Iterator"
128128
}
129129
],
130-
"PlanNodeId": 11,
130+
"PlanNodeId": 12,
131131
"Tables": [
132132
"base_join_group_by_lookup_script_script/Temp"
133133
]
@@ -154,7 +154,7 @@
154154
{
155155
"Node Type": "Precompute_1",
156156
"Parent Relationship": "InitPlan",
157-
"PlanNodeId": 9,
157+
"PlanNodeId": 10,
158158
"PlanNodeType": "Materialize",
159159
"Plans": [
160160
{
@@ -167,68 +167,77 @@
167167
"Name": "PartitionByKey"
168168
}
169169
],
170-
"PlanNodeId": 8
170+
"PlanNodeId": 9
171171
}
172172
],
173173
"Subplan Name": "CTE precompute_1_0"
174174
},
175175
{
176176
"Node Type": "Precompute_0",
177177
"Parent Relationship": "InitPlan",
178-
"PlanNodeId": 6,
178+
"PlanNodeId": 7,
179179
"PlanNodeType": "Materialize",
180180
"Plans": [
181181
{
182182
"Node Type": "Collect",
183-
"PlanNodeId": 5,
183+
"PlanNodeId": 6,
184184
"Plans": [
185185
{
186186
"Node Type": "UnionAll",
187-
"PlanNodeId": 4,
187+
"PlanNodeId": 5,
188188
"PlanNodeType": "Connection",
189189
"Plans": [
190190
{
191191
"Node Type": "Stage",
192-
"PlanNodeId": 3,
192+
"PlanNodeId": 4,
193193
"Plans": [
194194
{
195195
"KeyColumns": [
196196
"Group"
197197
],
198198
"Node Type": "HashShuffle",
199-
"PlanNodeId": 2,
199+
"PlanNodeId": 3,
200200
"PlanNodeType": "Connection",
201201
"Plans": [
202202
{
203-
"Node Type": "Aggregate-TableFullScan",
203+
"Node Type": "Aggregate",
204204
"Operators": [
205205
{
206206
"Aggregation": "{_yql_agg_0: SUM(state._yql_agg_0,1)}",
207207
"GroupBy": "item.Group",
208208
"Inputs": [
209209
{
210-
"InternalOperatorId": 1
210+
"ExternalPlanNodeId": 1
211211
}
212212
],
213213
"Name": "Aggregate"
214-
},
214+
}
215+
],
216+
"PlanNodeId": 2,
217+
"Plans": [
215218
{
216-
"Inputs": [],
217-
"Name": "TableFullScan",
218-
"ReadColumns": [
219-
"Group"
220-
],
221-
"ReadRanges": [
222-
"Group (-\u221e, +\u221e)",
223-
"Name (-\u221e, +\u221e)"
219+
"Node Type": "TableFullScan",
220+
"Operators": [
221+
{
222+
"Inputs": [],
223+
"Name": "TableFullScan",
224+
"ReadColumns": [
225+
"Group"
226+
],
227+
"ReadRanges": [
228+
"Group (-\u221e, +\u221e)",
229+
"Name (-\u221e, +\u221e)"
230+
],
231+
"ReadRangesPointPrefixLen": "0",
232+
"Scan": "Parallel",
233+
"Table": "base_join_group_by_lookup_script_script/Input1"
234+
}
224235
],
225-
"Scan": "Parallel",
226-
"Table": "base_join_group_by_lookup_script_script/Input1"
236+
"PlanNodeId": 1,
237+
"Tables": [
238+
"base_join_group_by_lookup_script_script/Input1"
239+
]
227240
}
228-
],
229-
"PlanNodeId": 1,
230-
"Tables": [
231-
"base_join_group_by_lookup_script_script/Input1"
232241
]
233242
}
234243
]

0 commit comments

Comments
 (0)