Skip to content

Commit af08334

Browse files
committed
sql: fix checkScanParallelizationIfLocal for groupNode
This commit fixes a bug in `checkScanParallelizationIfLocal` that caused it to ignore all but the last aggregate function in a `groupNode`. This has been fixed and a test has been added. In addition, an early return has been added to the `renderNode` case. Release note: None
1 parent a70c8d0 commit af08334

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

pkg/sql/distsql_physical_planner.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5322,16 +5322,22 @@ func checkScanParallelizationIfLocal(
53225322
return
53235323
case *groupNode:
53245324
for _, f := range n.funcs {
5325-
prohibitParallelization = f.hasFilter()
5325+
if f.hasFilter() {
5326+
prohibitParallelization = true
5327+
// Do not recurse.
5328+
return
5329+
}
53265330
}
53275331
case *joinNode:
53285332
prohibitParallelization = n.pred.onCond != nil
53295333
case *renderNode:
5330-
// Only support projections since render expressions might be handled
5331-
// via a wrapped row-by-row processor.
5334+
// Only support projections since render expressions might be
5335+
// handled via a wrapped row-by-row processor.
53325336
for _, e := range n.render {
53335337
if _, isIVar := e.(*tree.IndexedVar); !isIVar {
53345338
prohibitParallelization = true
5339+
// Do not recurse.
5340+
return
53355341
}
53365342
}
53375343
case *scanNode:

pkg/sql/distsql_physical_planner_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,17 @@ func TestCheckScanParallelizationIfLocal(t *testing.T) {
19941994
// Filtering aggregation is not natively supported.
19951995
prohibitParallelization: true,
19961996
},
1997+
{
1998+
plan: planComponents{main: planMaybePhysical{planNode: &groupNode{
1999+
singleInputPlanNode: singleInputPlanNode{scanToParallelize},
2000+
funcs: []*aggregateFuncHolder{
2001+
{filterRenderIdx: 0},
2002+
{filterRenderIdx: tree.NoColumnIdx},
2003+
}},
2004+
}},
2005+
// Filtering aggregation is not natively supported.
2006+
prohibitParallelization: true,
2007+
},
19972008
{
19982009
plan: planComponents{main: planMaybePhysical{planNode: &indexJoinNode{
19992010
singleInputPlanNode: singleInputPlanNode{scanToParallelize},
@@ -2028,6 +2039,16 @@ func TestCheckScanParallelizationIfLocal(t *testing.T) {
20282039
// prohibit the parallelization for all non-IndexedVar expressions).
20292040
prohibitParallelization: true,
20302041
},
2042+
{
2043+
plan: planComponents{main: planMaybePhysical{planNode: &renderNode{
2044+
singleInputPlanNode: singleInputPlanNode{scanToParallelize},
2045+
render: []tree.TypedExpr{&tree.IndexedVar{Idx: 0}, &tree.IsNullExpr{}},
2046+
}}},
2047+
// Not a simple projection (some expressions might be handled by
2048+
// wrapping a row-execution processor, so we choose to be safe and
2049+
// prohibit the parallelization for all non-IndexedVar expressions).
2050+
prohibitParallelization: true,
2051+
},
20312052
{
20322053
plan: planComponents{main: planMaybePhysical{planNode: &sortNode{singleInputPlanNode: singleInputPlanNode{scanToParallelize}}}},
20332054
hasScanNodeToParallelize: true,

0 commit comments

Comments
 (0)