Skip to content

Commit

Permalink
physicalplan: add support for multi-stage execution of regr_avgx, reg…
Browse files Browse the repository at this point in the history
…r_avgy,

regr_intercept, regr_r2, and regr_slope aggregate functions.

See cockroachdb#58347.

Release note (performance improvement): regr_avgx, regr_avgy, regr_intercept,
regr_r2, and regr_slope aggregate functions are now evaluated more efficiently
in a distributed setting
  • Loading branch information
mneverov authored and RajivTS committed Mar 6, 2022
1 parent dbf4ab5 commit 8068295
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 54 deletions.
5 changes: 5 additions & 0 deletions pkg/sql/distsql/columnar_operators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ var aggregateFuncToNumArguments = map[execinfrapb.AggregatorSpec_Func]int{
execinfrapb.FinalRegrSxx: 1,
execinfrapb.FinalRegrSxy: 1,
execinfrapb.FinalRegrSyy: 1,
execinfrapb.FinalRegrAvgx: 1,
execinfrapb.FinalRegrAvgy: 1,
execinfrapb.FinalRegrIntercept: 1,
execinfrapb.FinalRegrR2: 1,
execinfrapb.FinalRegrSlope: 1,
}

// TestAggregateFuncToNumArguments ensures that all aggregate functions are
Expand Down
10 changes: 9 additions & 1 deletion pkg/sql/execinfra/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import "github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
//
// ATTENTION: When updating these fields, add a brief description of what
// changed to the version history below.
const Version execinfrapb.DistSQLVersion = 60
const Version execinfrapb.DistSQLVersion = 61

// MinAcceptedVersion is the oldest version that the server is compatible with.
// A server will not accept flows with older versions.
Expand All @@ -51,6 +51,14 @@ const MinAcceptedVersion execinfrapb.DistSQLVersion = 60
Please add new entries at the top.
- Version: 61 (MinAcceptedVersion: 60)
- final_regr_avgx, final_regr_avgy, final_regr_intercept, final_regr_r2, and
final_regr_slope aggregate functions were introduced to support local and
final aggregation of the corresponding builtin functions. It would be
unrecognized by a server running older versions, hence the version bump.
However, a server running v61 can still process all plans from servers
running v60, thus the MinAcceptedVersion is kept at 60.
- Version: 60 (MinAcceptedVersion: 60):
- Deprecated ExportWriterSpec and ParquetWriterSpec and merged them into ExportSpec
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/execinfrapb/aggregate_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,9 @@ const (
FinalRegrSxx = AggregatorSpec_FINAL_REGR_SXX
FinalRegrSxy = AggregatorSpec_FINAL_REGR_SXY
FinalRegrSyy = AggregatorSpec_FINAL_REGR_SYY
FinalRegrAvgx = AggregatorSpec_FINAL_REGR_AVGX
FinalRegrAvgy = AggregatorSpec_FINAL_REGR_AVGY
FinalRegrIntercept = AggregatorSpec_FINAL_REGR_INTERCEPT
FinalRegrR2 = AggregatorSpec_FINAL_REGR_R2
FinalRegrSlope = AggregatorSpec_FINAL_REGR_SLOPE
)
5 changes: 5 additions & 0 deletions pkg/sql/execinfrapb/processors_sql.proto
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@ message AggregatorSpec {
FINAL_REGR_SXX = 50;
FINAL_REGR_SXY = 51;
FINAL_REGR_SYY = 52;
FINAL_REGR_AVGX = 53;
FINAL_REGR_AVGY = 54;
FINAL_REGR_INTERCEPT = 55;
FINAL_REGR_R2 = 56;
FINAL_REGR_SLOPE = 57;
}

enum Type {
Expand Down
10 changes: 10 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/distsql_agg
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,21 @@ SELECT covar_pop(y, x)::decimal FROM statistics_agg_test
----
3.75

query FFF
SELECT regr_intercept(y, x), regr_r2(y, x), regr_slope(y, x) FROM statistics_agg_test
----
48.4545454545455 0.00204565911136568 0.454545454545455

query FFF
SELECT regr_sxx(y, x), regr_sxy(y, x), regr_syy(y, x) FROM statistics_agg_test
----
825 375 83325

query FF
SELECT regr_avgx(y, x), regr_avgy(y, x) FROM statistics_agg_test
----
4.5 50.5

# Regression test for #37211 (incorrect ordering between aggregator stages).
statement ok
CREATE TABLE uv (u INT PRIMARY KEY, v INT);
Expand Down
23 changes: 15 additions & 8 deletions pkg/sql/opt/exec/execbuilder/testdata/distsql_agg
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ EXPLAIN (DISTSQL) SELECT
covar_pop(a, b),
regr_sxx(a, b),
regr_sxy(a, b),
regr_syy(a, b)
regr_syy(a, b),
regr_avgx(a, b),
regr_avgy(a, b),
regr_intercept(a, b),
regr_r2(a, b),
regr_slope(a, b)
FROM data GROUP BY b
----
distribution: full
Expand All @@ -68,7 +73,7 @@ vectorized: true
table: data@data_pkey
spans: FULL SCAN
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJzsmNFvujoUx9_vX9H0id3UaAHd5hP8NmdIHOwHbHfLzUKqNI5EqRdw2bLsf78pIoLbr9XhIw8b55R-T4_nWz8PfsD0vwUcwtHj3cS0bKBcW57v_Z6cAW80GV35YIoAeZ0r5AyBKWOLgMShEvBou8CSMp-xdZzlW5fkbfOM4vyZZmFIXythkJLlqpqvWJGul9tnEBXVXkkSkXhGt8lOzJOt8o0lAZnPlWD6ntG0bOdv3miUFY1HWZHmbefZjJVVEJieIZDQeRKkb297-Xs9fy9ycOM6tyAkGQFj17m_A7-ewBQiGLOQ2mRJUzj8F2KIoAoR1CCCOkSwD58RXCVsRtOUJXzLRy6wwjc47CEYxat1xpefEZyxhMLhB8yibEHhEPpkuqAuJSFNuj2IYEgzEi3yY3gXxiqJliR5hwhescV6GadDwBtFILeJP_h8-DPKIILeivAtnS4GJA4BBix7oQl8_kSQrbNdG2lG5hQO8Sc6vFVzPk_onGQs6fbrnRp8Gqb9FNiOH9j3k4liqGe8m_tbxcA8unLubb-IfznOJDDta8XQytRxiyzfGLjOP57C01vzsVDdWnYReb_da-vmZpvd3wZWWfvRcQNzPFYMPS9t-ZuD-tuMn5MnvmvanuVbjh24o7E78jwemuOxOxqb_kgxMOKfoT643Sym7-CFpC97Y8Dw-XM3XPWPw93VWccsCWlCw1qlvI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dczCAoqKMFqPo_VAWo-kNVFaj6W4FkyxgKaywLRPOD3LtGq1yLRqtci0arXQNIFcZNonqFaa9vrx1_8BAAD__yCBgnk=


statement ok
Expand Down Expand Up @@ -266,7 +271,7 @@ Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJy0lNGK4jAUhu_3K
# Regression aggregate functions have two local, and one final stage aggregations.
# Calculation and rendering are happening at the end.
query T
EXPLAIN (DISTSQL) SELECT covar_pop(a, c), regr_sxx(a, c), regr_sxy(a, c), regr_syy(a, c) FROM data
EXPLAIN (DISTSQL) SELECT covar_pop(a, c), regr_sxx(a, c), regr_sxy(a, c), regr_syy(a, c), regr_avgx(a, c), regr_avgy(a, c), regr_intercept(a, c), regr_r2(a, c), regr_slope(a, c) FROM data
----
distribution: full
vectorized: true
Expand All @@ -278,12 +283,13 @@ vectorized: true
table: data@data_pkey
spans: FULL SCAN
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJy8lNGrokAUxt_3rxjOU8GEjVq361PSekNoq1VZuiwhszq4QTnujC1F9L8v5oVbUaMY7VvnTJ_fN78znAPIP2uwwFnMJ7Y7Ra2vrh_43ydt5DsTZxSgiP-lIsx41qIYRW2MBEtEKHe7q3p_We8_avTmzb6hmOYUMKQ8ZlO6YRKsn0AAgw4YDMBgAoYeLDFkgkdMSi6KvxxOAjfegdXFsEqzbV60lxgiLhhYB8hX-ZqBBQH9tWYeozETWhcwxCynq_XJprAeZmK1oWIPGEZ8vd2k0kJFOsDgZ7SoOhpBNI0RQTz_zQQsjxj4Nv90lDlNGFjkiOunspNEsITmXGi9y1CBZ099N3Bn09Bzxp7j-8VPezz2nLEdOK0hwUO9fTeFfjfFp_k25SJmgsUXzsujOie5ovfmTu1JOJr9sL1wPpu3hqQN-KNbJA_9xeJW8_1G871s3ruUcXEpUn_gpMnANdLR9AYjr8h1hrL_xJHr9enojejoHc1oQKci1xmdlyfSMerTMRrRMTqa2YBORa4zOoMn0jHr0zEb0TE7Wq8BnYpcZ3Re_9MyvZHCYzLjqWRXS_X2l7vFsmVxwsrNLPlWRGwueHSyKcvZSXdqxEzm5SkpCzctj4qA52KiFOsXYnIt1tXOFdaGUm2qxeYjuXtKcV_t3H_E-UUpHqidB484v6pn1a14JupHdu29PH75FwAA__9Lzzph
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJy8lV9ro0AUxd_3U8h9SmCCGTX941Mka4OQTbIqpWUJMqsXN2Add5yUlJLvvqgLja7VYOm-5R7neA4_L5NXyH8nYIL9sF1ZzloZfXU83_u-GiuevbIXvhLyZyaCjGcjRpRwTBSBsQjy47Exv9Tnl_rMnuNjU6if2KcSRYiZrKlCq7824RlWinLnbr4pEZMMCKQ8wjV7whzMH0CBgAYEdCBgAIEZ7AhkgoeY51wUR15LgxMdwZwS2KfZQRbyjkDIBYL5CnIvEwQTfPYzQRdZhEKdAoEIJdsnZUwRPc_E_omJFyCw4MnhKc1NpWgHBLyMFdNEpQpLI4UqXP5CAbsTAX6Qb4m5ZDGCSU_k8lZWHAuMmeRCndVL-a619hzf2awD1166tucVP63l0rWXlm-P5pTMtfG7LbR3W7yFH1IuIhQY1ZJ3p-6etEHvzllbq2CxubfcYLvZjuZ0DOSvWjQPvIeHNvGxRXxsEa37ZYvful-2nHXWvu0u7K3_7yNXa8lbbbZ2Kb-HUa9hpJevGB2yYiqdqNqAJevpdfbxrj5xybTL6WiD6GgTVR9Ap6fXGZ3rT6SjX05HH0RHn6jGADo9vc7o3HwiHeNyOsYgOsZEnQ2g09PrjM7tf7q-W1q4mGc8zbFxjbe_eVpc7xjFWP0X5PwgQtwKHpYx1bgpfaUQYS6rp7QanLR6VBQ8N9NOs1Yz06ZZ607uidY73Ua32fhI71mn-ao7-eojyded5pvu5JuPJN92f6tpz5p0L1kze3f68icAAP__g2h04w==


# Test various combinations of aggregation functions and verify that the
# aggregation processors are set up correctly.
query T
EXPLAIN (DISTSQL) SELECT sum(a), avg(b), sum(c), avg(d), stddev(a), stddev_samp(a), stddev_pop(a), variance(b), var_samp(b), var_pop(b), sum(a+b+c::INT+d), covar_pop(a, c), regr_sxx(a, c), regr_sxy(a, c), regr_syy(a, c) FROM data
EXPLAIN (DISTSQL) SELECT sum(a), avg(b), sum(c), avg(d), stddev(a), stddev_samp(a), stddev_pop(a), variance(b), var_samp(b), var_pop(b), sum(a+b+c::INT+d), covar_pop(a, c), regr_sxx(a, c), regr_sxy(a, c), regr_syy(a, c), regr_avgx(a, c), regr_avgy(a, c), regr_intercept(a, c), regr_r2(a, c), regr_slope(a, c) FROM data
----
distribution: full
vectorized: true
Expand All @@ -297,11 +303,11 @@ vectorized: true
table: data@data_pkey
spans: FULL SCAN
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJzcVl-LskoYvz-fYniujCZs1NrWq5HWXYRe61Xfl305REw6dILSzmixy9J3P4xaWbQWJ-iiC-X595vnz-8ZmC9I_12ACfb7aGA5LlJeHD_wfw4ayLcHdj9A6XqpsAZGbDNTpg2c62GpR1LPoohv8pBCnKRsuarqq6RQN0zMWRzy_JgNE0XgTpFRu_MVhaEmmjZQE4Wm6bhBT4oyW5jsYhlGsgzBZ2KSfnyc6J_H-mepo1dv-ANFLGOAIU4i7rIlT8H8Gwhg0ACDDhgMwNCBMYaVSEKepomQIV85wIk-wGxjmMerdSbNYwxhIjiYX5DNswUHEwI2XXCPs4gLtQ0YIp6x-SJPI1PTlZgvmfgEDP1ksV7GqYkYRlOMQowiwOCvmLS1VIJYHCGCkuwfLgCDx-OICxNRo6kolDSp1mhSvZwQRpRgRDWMqI4RNWC8xZCss0OdacZmHEyyxdf3Ys1mgs9Ylgi1c9yK_-uHQrWGrFdKupT6w19uUMq51dhLnYo_l_2f3ovz-lqeUXq0I8_hHCKlwLNc3wmcoTvx7DfP9n0pWm9vnv1mBbZCNSwTfte39m3fh3bXcSIiLnh01Ot4Wz8Z0j4zGrIvfjekiVM7nH1EV2qvjmsNJn7w8mL_VugTpgTT3qljMhqOzjh_W55juX1boc9YDkU_chWgi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ORa-4StCJpyy3ewwaTg5hhBzNcuhz__m51vpSZ32ps1pPo7olrKdRXbTjBrY3tKdBjc_T6pKOJ1N7bz-cmOJoqOXJwIj2VNrHiN7tvgFG9H73ka78yXgizxKRECIxpCd_EkYkhkgQkQit--We0yt7jlx_b5D_f2-opKNq33BzXOjm5Hz0f9TNoV3PonYDi1pH1b-BxQvdnLB496NY1K9nUb-BRb2jGt_A4oVuTlgc_CgWjetZNG5g0eiovW9g8UI3Jyze_ygWL7xBPZ6lSZzxszdZ_cpd-Vbj0YKXD7ss2YiQT0USFmlKdVLgCkPEs7z0klJx4tIlCzwFk0awVgGTc7DWnPlCar0RbTSDjVvq7jWC-82Z-7dkvmsED5ozD27JfN_MVffCNmneZOe5Z59__RcAAP__8oSfLA==


query T
EXPLAIN (DISTSQL) SELECT sum(a), min(b), max(c), count(d), avg(a+b+c::INT+d), stddev(a+b), variance(c::INT+d), covar_pop(b, d), regr_sxx(a, c), regr_sxy(a, c), regr_syy(a, c) FROM data
EXPLAIN (DISTSQL) SELECT sum(a), min(b), max(c), count(d), avg(a+b+c::INT+d), stddev(a+b), variance(c::INT+d), covar_pop(b, d), regr_sxx(a, c), regr_sxy(a, c), regr_syy(a, c), regr_avgx(a, c), regr_avgy(b, c), regr_intercept(a, b), regr_r2(b, c), regr_slope(a, c) FROM data
----
distribution: full
vectorized: true
Expand All @@ -315,7 +321,8 @@ vectorized: true
table: data@data_pkey
spans: FULL SCAN
·
Diagram: https://cockroachdb.github.io/distsqlplan/decode.html#eJzsVl1v6jgQfd9fYc2TEYPASfhonhzRtIrUht4kt9urFUImsVgkSFgnVK2q_veVAwXSbQN7eehLX8Bz5kzGc3ws-QXyfxZgg_twd-N4PqGXXhiFP24aJHRv3GFE8vWSigaS5TylU_0vnmjcQBJn67SgSQOJeJxRSgVpkmmDNEls254fDfRSZ_MiSeTjNo3kUai5SGNJt7QtK84ehZqsshWdYgkoOVOT_OmJCiTxPn6uxs_bmFwFo1uSiEIAQpol0hdLmYP9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e1Io7YJrkQkZikSva-B2VWomUzdKF2KyDHv3eE4p5zoFAksbC43ORgfUXUCCgAQEdCBhAwIQhgYVMI5FlqVSU18LBjddgNQhMk8UyV_CQQJRKAdYr5NN8JsCCkI9nwhc8FrLeAAKxyPl0VoRRodlCTudcvgCBdjpbzpPMQmr7BEUExUAgWHCF3dYp4kmMKErzv4UEAr5IYiEtxIwbjBm9YVrthunbBhFUIERZ30GFEVSAujLA8I1Ausz3e89yPhFg0TdyeX72ZCLFhOeprJvl9IKfT5gZNSDw5HqYmcXIfsasqUbt3k8vHPm9PwOspgWZ7gzbcfDDf3AfHzHTdhztgKOVOPqOox9winHo217ghm7PG_lOx3eCQA3tTsd3OnboYGYS1rqIaJDN9i9Z8TKiQVRpPuqF9mEv9i1YJqmMhRRxqf7Dt-pu0caJdtFdu7Rdu97rOnJVPY1dlc0SXiT76Hp2dxSEDw_OALMWYXeE3e8NA9t3ba_tYEYbhFFKGNX21nZvYPujfq-PGdX3sKraKHh-xowa_0F_nUJ_nULtQefUEvago9jmEex6oeO3nb4SYvPI5msnHIJur--8r787mqXzRhAz66xJEGsRxNRxvFdHsqE-ikgVkyoqVVxqqo-i09aH8tBL8qCXX0X0_19FdXpb177oMjqT4YG8m9-X0SdfRtrlatOuUJt2W9e_SG1nMjxQW-tbbZ-sNv1ytelXqE2_rRtfpLYzGR6o7e5bbZ-sNuNytRlXqM24rZtfpLYzGR6o7f5bbb_xWX-iF77IFmmSiaPn_emVG-rZL-KJ2PxHyNKljERfplERZjPtFX4FEIss31jpZuImG5Pa4KEzrXTWSs702FmrjnwmtF7pbVQ7G9fs26x0blZHbl4TuVXpfFcd-e6ayPfVvWqckUm1yI5jD9_--DcAAP__ERJXMA==


# Verify that local and final aggregation is correctly shared and de-duplicated.
query T
Expand Down
50 changes: 50 additions & 0 deletions pkg/sql/physicalplan/aggregator_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,54 @@ var DistAggregationTable = map[execinfrapb.AggregatorSpec_Func]DistAggregationIn
},
},
},

execinfrapb.RegrAvgx: {
LocalStage: []execinfrapb.AggregatorSpec_Func{execinfrapb.TransitionRegrAggregate},
FinalStage: []FinalStageInfo{
{
Fn: execinfrapb.FinalRegrAvgx,
LocalIdxs: passThroughLocalIdxs,
},
},
},

execinfrapb.RegrAvgy: {
LocalStage: []execinfrapb.AggregatorSpec_Func{execinfrapb.TransitionRegrAggregate},
FinalStage: []FinalStageInfo{
{
Fn: execinfrapb.FinalRegrAvgy,
LocalIdxs: passThroughLocalIdxs,
},
},
},

execinfrapb.RegrIntercept: {
LocalStage: []execinfrapb.AggregatorSpec_Func{execinfrapb.TransitionRegrAggregate},
FinalStage: []FinalStageInfo{
{
Fn: execinfrapb.FinalRegrIntercept,
LocalIdxs: passThroughLocalIdxs,
},
},
},

execinfrapb.RegrR2: {
LocalStage: []execinfrapb.AggregatorSpec_Func{execinfrapb.TransitionRegrAggregate},
FinalStage: []FinalStageInfo{
{
Fn: execinfrapb.FinalRegrR2,
LocalIdxs: passThroughLocalIdxs,
},
},
},

execinfrapb.RegrSlope: {
LocalStage: []execinfrapb.AggregatorSpec_Func{execinfrapb.TransitionRegrAggregate},
FinalStage: []FinalStageInfo{
{
Fn: execinfrapb.FinalRegrSlope,
LocalIdxs: passThroughLocalIdxs,
},
},
},
}
Loading

0 comments on commit 8068295

Please sign in to comment.