Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-22.1: physicalplan: don't combine render nodes into one processor #100368

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ vectorized: true
table: orders@orders_pkey
spans: [/'ap-southeast-2'/'94e4b847-8f2f-4ac5-83f1-641d6e3df727' - /'ap-southeast-2'/'94e4b847-8f2f-4ac5-83f1-641d6e3df727'] [/'us-east-1'/'94e4b847-8f2f-4ac5-83f1-641d6e3df727' - /'us-east-1'/'94e4b847-8f2f-4ac5-83f1-641d6e3df727']
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJysVN1uGjsQvj9PYc1NzolM2L8AWSmSoxzaElFIIVIr1Qht1kPiBuyt7W23irjqs_W9qt0lpBsVpKS9ANsz83m-b3bG92A_LyGG_ofL4dlgRP79fzC9mr4b_kem_WH__IpoI9DMpaAkM3ql7VG1bAwyRXI2rTfzr9Ld6tzNq4AH7yER0qY6V64ZWEeRV5Px2zqFJRfjwWiThIwfdkdSLTRhPPe8EDeRte39m_6kv6VHTsnBSYTRdS_qtnqLYNGKkvS41QsXfqsT-aKDoVh0g-4BUFBa4ChZoYX4I0Qwo5AZnaK12pSm-ypgIAqIPQpSZbkrzTMKqTYI8T046ZYIMVwl10ucYCLQtD2gINAlclldWzNl9TLP7vAbUDjXy3ylbNwoqkyRklIRUJhmSeluc2Ac2hw4L04izgss_657rzkveov2xY_vnBcLX3Be-EKdlofuAYe2RxIliE-0u0UDszUFnbtH-tYlNwixv6Yvk-j_XYmlGO9FMndKC3ZKe1Rk0chkSXJVMUTREDVb_6YGI93SWTtoqh_KlXTE30nFe06VB-oLG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rbB_l5wsB8c7AW39oNbe8HtLfB09eJ3AAAA__8C2Vgm

# Regression test for #74890. Code should not panic due to distribution already
# provided by input.
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/pg_catalog
Original file line number Diff line number Diff line change
Expand Up @@ -5909,3 +5909,8 @@ WHERE
AND t.typname LIKE 'myt%';
----
0

# Regression test for a panic after physical planning combined rendering steps
# (#95633).
statement ok
SELECT d.datname, pg_catalog.pg_get_userbyid(d.datdba) FROM pg_catalog.pg_database d;
4 changes: 2 additions & 2 deletions pkg/sql/opt/exec/execbuilder/testdata/distsql_merge_join
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ vectorized: true
table: outer_c1@outer_c1_pkey
spans: FULL SCAN
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJzMll9r4kAUxd_3Uwz3SbcjyeSPtYGFFNcuFqtdtbCwSEmTuyprM9lJhC3F774kqbiGNpMwKr5IMpnf3DnnXDN5hfjPChzo_bgfXPeHpPG1P5lOvg-aZNIb9LpT8pncjEd3hK8TFI8RIzcPgwG5HfWHb0M-Iw-T_vAbaUTLgDWBQsgDHHrPGIPzExhQMICCCRQsoGDDjEIkuI9xzEU65TUD-sFfcHQKyzBaJ-nwjILPBYLzCskyWSE4MPWeVjhGL0ChpesGmHjLVVZmuz13e_EY_cYXoNDlq_VzGDsk3R0lkZeCk8hLhzS9pdnECwPCCE8WKGC2oelSb1vYVX56IQsvXuzXdBnMNjMKceLNERy2oR9I2a3DRYACg-I6F2nh3ax1-N68rFbRkjsUc7zlyxCFdrm_7PQlQiePa_Qw7Y2z0IDCCn8lDZddNL-I5XyRXwKFMYYBCod0R9eD3qTba7iMumaTEtegxLUocW1K3HbBop18s4L8GsKGvMUjjbHCzPdrW3u1WfUuMg7RRXZLY_qR2oidvo06Z9RGRvUozUNEyfSWxo71SjBOn-XVGWVpVs_SOkiWdkszjvW_NE-fJdPPKEyrepj6AcJsaccKsoYQ-z0h_laI_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Ftxf02SXgzVu_eERYJxkT5mdXXXD7FmqsARaBazE3FKSLdHN9tH672hjB6zvg41CsFnMbBaC2W0xtaVktQStAlZillgtkS3RbRc2vFnc76aK1bdKZknQKmAlZolZEtkS3a3Cft8Vm3WnYhZTm6IyuBJajVtimEy5THrxKGWSWcqUhin7Y5qWM00CV0KrcctMkyiXSS91jhhl4UpoNe6WmnKZ9OLDhElOE1buOJms_voVAAD__whhgYA=

query T
EXPLAIN (VERBOSE) SELECT * FROM outer_gc1 FULL OUTER JOIN outer_c1 USING (pid1, cid1, cid2)
Expand Down Expand Up @@ -891,7 +891,7 @@ vectorized: true
table: outer_c1@outer_c1_pkey
spans: FULL SCAN
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJyckt9um0wQxe-_p1jNlf15InvB6R-kShu5pCIidgpYqlRZEWWnFJWwdBekRpbfvQJax6DYcXuD2LNzht8ZZgvmRw4OuJ_u_CtvyUbvvTAKP_pjFrq-u4jY_-w6WN0yVVek79OEs-u177Oblbf8rSWcrUNv-YGNykxyZMmfpzUGhEJJWsYPZMD5DBwQLmGDUGqVkDFKN_K2LfLkT3BmCFlR1lUjbxASpQmcLVRZlRM4sFQXqpzagCCpirO8LdshqLp6MpkqTgmc-Q4PGvPTjaP4S04BxZL0dNZrD_vgYv92X36nR0BYqLx-KIzDhsGRpd0hTeImc1jGTdkFHIPl_wrLn4Pds56FeiaidRTxiawulJakSQ7_0Mslz-S8JZ3SjcoK0lOrnzN6LMnpNnG1jtyg3UdAyOlrNRJ8gsKaoLAn43c6S7_1JUAIqJCkHbZYXfluuHBHgqN4NcYDwULxuifYKN6MkYk5MnGJTLw9Oim7N6kXVjogU6rC0Fk7PWvGRDKlbuxG1TqhO62S9jPdcdX6WkGSqbrbeXfwiu6qATw085Nmu2fmQ7P1F2ZraLZPmmcD7M3uv18BAAD__7KcfNU=
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJyck1Fvm0AMx9_3KU5-ShZXyQFpO6RJV2V0oqKhC4k0aYoqBh5Doxw7DmlVlO8-AVsaooamfUH4f_6bn7FvA-XvDGxwvt55V-6cDT65wTL44g1Z4HjObMnes-uFf8tkpUndJxFn1yvPYze-O_-nRZytAnf-mQ2KNObIov9PYwgIuYxpHj5QCfY34IAwhTVCoWREZSlVLW-aJDf-A_YEIc2LStfyGiGSisDegE51RmDDXJ7JYmwBQkw6TLMmbYsgK_1kKnWYENjTLe4V5v2Fl-H3jBYUxqTGk0552DUudm_3xS96BISZzKqHvLTZYePIkjZIorDuOSjCOu0MjsHyt8Ly52B3rCehnohoHEV8IqtyqWJSFB9O6OWUZ_q8JZXQjUxzUmOj2-fysSC73UR_tXQWzT4CQkY_9EDwEQpjhMIcDT-qNPnZlQDBr7TNBEdhoDBRWCimKM5RXKC4RPHh6D8wXzOmdlnNLviC8piUzWb-lecEM2dQU5wPcU8wUFx0BBPF5RCZsJCJKbIePqvD98JlWlBZyLykk27TpB4QxQm1Ay9lpSK6UzJqPtOGfuNrhJhK3Z5O28DN26MacN_Me81mx8wPzcYrzMah2ew1W_3YVq95cmBeb9_9DQAA__8XQ7Wb

query T
EXPLAIN (VERBOSE) SELECT * FROM outer_c1 LEFT OUTER JOIN outer_p1 USING (pid1) WHERE pid1 >= 0 AND pid1 < 40
Expand Down
18 changes: 10 additions & 8 deletions pkg/sql/opt/exec/execbuilder/testdata/tpch_vec
Original file line number Diff line number Diff line change
Expand Up @@ -578,14 +578,16 @@ EXPLAIN (VEC) SELECT l_orderkey, sum(l_extendedprice * (1 - l_discount)) AS reve
└ Node 1
└ *colexec.topKSorter
└ *colexec.hashAggregator
└ *rowexec.joinReader
└ *colexecjoin.hashJoiner
├ *colfetcher.ColBatchScan
└ *colexecjoin.hashJoiner
├ *colexecsel.selLTInt64Int64ConstOp
│ └ *colfetcher.ColBatchScan
└ *colexecsel.selEQBytesBytesConstOp
└ *colfetcher.ColBatchScan
└ *colexecproj.projMultFloat64Float64Op
└ *colexecproj.projMinusFloat64ConstFloat64Op
└ *rowexec.joinReader
└ *colexecjoin.hashJoiner
├ *colfetcher.ColBatchScan
└ *colexecjoin.hashJoiner
├ *colexecsel.selLTInt64Int64ConstOp
│ └ *colfetcher.ColBatchScan
└ *colexecsel.selEQBytesBytesConstOp
└ *colfetcher.ColBatchScan

# Query 4
query T
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/physicalplan/physical_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,11 @@ func (p *PhysicalPlan) AddRendering(
}

post := p.GetLastStagePost()
if len(post.RenderExprs) > 0 {
if len(post.RenderExprs) > 0 || len(post.OutputColumns) > 0 {
post = execinfrapb.PostProcessSpec{}
// The last stage contains render expressions. The new renders refer to
// the output of these, so we need to add another "no-op" stage to which
// to attach the new rendering.
// The last stage contains render expressions, or is projecting input columns.
// The new renders refer to the output of these in a particular order, so we
// need to add another "no-op" stage to which to attach the new rendering.
p.AddNoGroupingStage(
execinfrapb.ProcessorCoreUnion{Noop: &execinfrapb.NoopCoreSpec{}},
post,
Expand Down
32 changes: 31 additions & 1 deletion pkg/sql/physicalplan/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ func TestProjectionAndRendering(t *testing.T) {
); err != nil {
t.Fatal(err)
}

},

expPost: execinfrapb.PostProcessSpec{
Expand All @@ -169,6 +168,37 @@ func TestProjectionAndRendering(t *testing.T) {
},
expResultTypes: "B,D,C",
},

// Rendering after projection.
{
post: execinfrapb.PostProcessSpec{
Projection: true,
OutputColumns: []uint32{3, 1, 4, 2},
},
resultTypes: "A,B,C,D",

action: func(p *PhysicalPlan) {
if err := p.AddRendering(
[]tree.TypedExpr{
&tree.IndexedVar{Idx: 0},
&tree.IndexedVar{Idx: 1},
&tree.IndexedVar{Idx: 2},
},
fakeExprContext{},
[]int{2, 0, 3, 1},
[]*types.T{strToType("C"), strToType("A"), strToType("D")},
execinfrapb.Ordering{},
); err != nil {
t.Fatal(err)
}
},

expPost: execinfrapb.PostProcessSpec{
Projection: true,
OutputColumns: []uint32{4, 3, 2},
},
expResultTypes: "C,A,D",
},
}

for testIdx, tc := range testCases {
Expand Down