Skip to content

Commit

Permalink
vendor: bump cockroachdb/apd to v3.1.0
Browse files Browse the repository at this point in the history
Picks up two PRs that improved the performance of `Quo`, `Sqrt`,
`Cbrt`, `Exp`, `Ln`, `Log`, and `Pow`:
- cockroachdb/apd#114
- cockroachdb/apd#115

Almost all of the testing changes here are due to the rounding behavior
in cockroachdb/apd#115. This brings us closer
to PG's behavior, but also creates a lot of noise in this diff.

Release note (performance improvement): The performance of many DECIMAL
arithmetic operators has been improved by as much as 60%. These operators
include division (`/`), `sqrt`, `cbrt`, `exp`, `ln`, `log`, and `pow`.
  • Loading branch information
nvanbenschoten committed Feb 1, 2022
1 parent baeba80 commit 2abb651
Show file tree
Hide file tree
Showing 24 changed files with 599 additions and 599 deletions.
6 changes: 3 additions & 3 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1114,10 +1114,10 @@ def go_deps():
name = "com_github_cockroachdb_apd_v3",
build_file_proto_mode = "disable_global",
importpath = "github.com/cockroachdb/apd/v3",
sha256 = "29727b520b1239e501cbad8d1215ca2d1d5f79c60ca26e6c954153fc81f6ceb4",
strip_prefix = "github.com/cockroachdb/apd/v3@v3.0.1",
sha256 = "0571a4bf35a79df25f1e4a0b807ce3e30f7edbf69412d0272affaa925e25f625",
strip_prefix = "github.com/cockroachdb/apd/v3@v3.1.0",
urls = [
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/apd/v3/com_github_cockroachdb_apd_v3-v3.0.1.zip",
"https://storage.googleapis.com/cockroach-godeps/gomod/github.com/cockroachdb/apd/v3/com_github_cockroachdb_apd_v3-v3.1.0.zip",
],
)
go_repository(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/bufbuild/buf v0.56.0
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/client9/misspell v0.3.4
github.com/cockroachdb/apd/v3 v3.0.1
github.com/cockroachdb/apd/v3 v3.1.0
github.com/cockroachdb/circuitbreaker v2.2.2-0.20190114160014-a614b14ccf63+incompatible
github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292
github.com/cockroachdb/cockroach-go/v2 v2.2.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 h1:zH8ljVhhq7yC0MIeUL/
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/apd/v3 v3.0.1 h1:g1iaIyOhxq9f6iQ95fiPFJl9uCU69B3NkGXE2RLdZpI=
github.com/cockroachdb/apd/v3 v3.0.1/go.mod h1:6qgPBMXjATAdD/VefbRP9NoSLKjbB4LCoA7gN4LpHs4=
github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w=
github.com/cockroachdb/apd/v3 v3.1.0/go.mod h1:6qgPBMXjATAdD/VefbRP9NoSLKjbB4LCoA7gN4LpHs4=
github.com/cockroachdb/circuitbreaker v2.2.2-0.20190114160014-a614b14ccf63+incompatible h1:u3uQ4oAKM5g2eODBAsDdDSrTs7zRWXtvu+nvSDA9098=
github.com/cockroachdb/circuitbreaker v2.2.2-0.20190114160014-a614b14ccf63+incompatible/go.mod h1:v3T8+rm/HmCL0D1BwDcGaHHAQDuFPW7EsnYs2nBRqUo=
github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 h1:dzj1/xcivGjNPwwifh/dWTczkwcuqsXXFHY1X/TZMtw=
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/clisqlshell/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func Example_sql() {
// ERROR: -e: woops! COPY has confused this client! Suggestion: use 'psql' for COPY
// sql -e select 1/(@1-2) from generate_series(1,3)
// ?column?
// -1
// -1.0000000000000000000
// (error encountered after some results were delivered)
// ERROR: division by zero
// SQLSTATE: 22012
Expand Down Expand Up @@ -190,9 +190,9 @@ func Example_sql_watch() {
// INSERT 1
// sql --watch .1s -e update d set x=x-1 returning 1/x as dec
// dec
// 0.5
// 0.50000000000000000000
// dec
// 1
// 1.0000000000000000000
// ERROR: division by zero
// SQLSTATE: 22012
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/sql/colexec/aggregators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ var aggregatorsTestCases = []aggregatorTestCase{
},
expected: colexectestutils.Tuples{
{0, "1.5333333333333333333", 4.6},
{1, 4.32, 8.64},
{1, "4.3200000000000000000", 8.64},
},
convToDecimal: true,
},
Expand Down Expand Up @@ -610,10 +610,10 @@ var aggregatorsTestCases = []aggregatorTestCase{
execinfrapb.ConcatAgg,
},
expected: colexectestutils.Tuples{
{0, 2, 2.1, 2, 4.2, 5, 2, 3, false, true, "zero", "zerozero"},
{1, 2, 2.6, 2, 5.2, 1, 0, 1, false, false, "one", "oneone"},
{2, 1, 1.1, 1, 1.1, 1, 1, 1, true, true, "two", "two"},
{3, 2, 4.6, 2, 9.2, 0, 0, 0, false, true, "three", "threethree"},
{0, 2, "2.1000000000000000000", 2, 4.2, 5, 2, 3, false, true, "zero", "zerozero"},
{1, 2, "2.6000000000000000000", 2, 5.2, 1, 0, 1, false, false, "one", "oneone"},
{2, 1, "1.1000000000000000000", 1, 1.1, 1, 1, 1, true, true, "two", "two"},
{3, 2, "4.6000000000000000000", 2, 9.2, 0, 0, 0, false, true, "three", "threethree"},
},
convToDecimal: true,
},
Expand Down Expand Up @@ -644,8 +644,8 @@ var aggregatorsTestCases = []aggregatorTestCase{
execinfrapb.ConcatAgg,
},
expected: colexectestutils.Tuples{
{nil, 1, 1.1, 1, 1.1, 1.1, 4, 4, 4, true, true, "a"},
{0, 2, 3.1, 1, 3.1, 3.1, 5, 5, 5, nil, nil, "b"},
{nil, 1, 1.1, 1, 1.1, "1.1000000000000000000", 4, 4, 4, true, true, "a"},
{0, 2, 3.1, 1, 3.1, "3.1000000000000000000", 5, 5, 5, nil, nil, "b"},
{1, 2, nil, 0, nil, nil, nil, nil, nil, false, false, nil},
},
convToDecimal: true,
Expand Down
19 changes: 10 additions & 9 deletions pkg/sql/colexec/colexecwindow/window_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func TestWindowFunctions(t *testing.T) {
expected: colexectestutils.Tuples{
{1, 7, dec("1.6666666666666666667")}, {1, 3, dec("1.6666666666666666667")},
{1, -5, dec("1.6666666666666666667")}, {2, nil, dec("0")},
{2, 0, dec("0")}, {3, 6, dec("6")},
{2, 0, dec("0")}, {3, 6, dec("6.0000000000000000000")},
},
windowerSpec: execinfrapb.WindowerSpec{
PartitionBy: []uint32{0},
Expand Down Expand Up @@ -512,8 +512,8 @@ func TestWindowFunctions(t *testing.T) {
{
tuples: colexectestutils.Tuples{{nil, 4}, {nil, -6}, {1, 2}, {1, nil}, {2, -3}, {3, 1}, {3, 7}},
expected: colexectestutils.Tuples{
{nil, 4, dec("-1")}, {nil, -6, dec("-1")},
{1, 2, dec("0")}, {1, nil, dec("0")}, {2, -3, dec("-0.75")},
{nil, 4, dec("-1.0000000000000000000")}, {nil, -6, dec("-1.0000000000000000000")},
{1, 2, dec("0")}, {1, nil, dec("0")}, {2, -3, dec("-0.75000000000000000000")},
{3, 1, dec("0.83333333333333333333")}, {3, 7, dec("0.83333333333333333333")}},
windowerSpec: execinfrapb.WindowerSpec{
WindowFns: []execinfrapb.WindowerSpec_WindowFn{
Expand Down Expand Up @@ -781,10 +781,10 @@ func TestWindowFunctions(t *testing.T) {
{1, 2, 5}, {2, 1, nil}, {3, 1, 8}, {3, 2, 1},
},
expected: colexectestutils.Tuples{
{nil, nil, -10, dec("-3")}, {nil, nil, 4, dec("-3")},
{nil, 1, 6, dec("0")}, {1, nil, 2, dec("2")},
{1, 2, 5, dec("3.5")}, {2, 1, nil, nil},
{3, 1, 8, dec("8")}, {3, 2, 1, dec("4.5")},
{nil, nil, -10, dec("-3.0000000000000000000")}, {nil, nil, 4, dec("-3.0000000000000000000")},
{nil, 1, 6, dec("0")}, {1, nil, 2, dec("2.0000000000000000000")},
{1, 2, 5, dec("3.5000000000000000000")}, {2, 1, nil, nil},
{3, 1, 8, dec("8.0000000000000000000")}, {3, 2, 1, dec("4.5000000000000000000")},
},
windowerSpec: execinfrapb.WindowerSpec{
PartitionBy: []uint32{0},
Expand Down Expand Up @@ -1003,8 +1003,9 @@ func TestWindowFunctions(t *testing.T) {
{
tuples: colexectestutils.Tuples{{1}, {2}, {nil}, {4}, {nil}, {6}},
expected: colexectestutils.Tuples{
{1, dec("3.25")}, {2, dec("3.25")}, {nil, dec("3.25")},
{4, dec("3.25")}, {nil, dec("3.25")}, {6, dec("3.25")},
{1, dec("3.2500000000000000000")}, {2, dec("3.2500000000000000000")},
{nil, dec("3.2500000000000000000")}, {4, dec("3.2500000000000000000")},
{nil, dec("3.2500000000000000000")}, {6, dec("3.2500000000000000000")},
},
windowerSpec: execinfrapb.WindowerSpec{
WindowFns: []execinfrapb.WindowerSpec_WindowFn{
Expand Down
16 changes: 8 additions & 8 deletions pkg/sql/logictest/testdata/logic_test/aggregate
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ SELECT jsonb_agg(s) FROM kv WHERE s IS NULL
query RRRR
SELECT avg(k), avg(v), sum(k), sum(v) FROM kv
----
5 2.8 30 14
5.0000000000000000000 2.8000000000000000000 30 14

query TTTT
SELECT min(i), avg(i), max(i), sum(i) FROM kv
Expand All @@ -622,24 +622,24 @@ SELECT min(i), avg(i), max(i), sum(i) FROM kv
query RRRR
SELECT avg(k::decimal), avg(v::decimal), sum(k::decimal), sum(v::decimal) FROM kv
----
5 2.8 30 14
5.0000000000000000000 2.8000000000000000000 30 14

query RRRR
SELECT avg(DISTINCT k), avg(DISTINCT v), sum(DISTINCT k), sum(DISTINCT v) FROM kv
----
5 3 30 6
5.0000000000000000000 3.0000000000000000000 30 6

query R
SELECT avg(k) * 2.0 + max(v)::DECIMAL FROM kv
----
14.0
14.00000000000000000000

# Verify things work with distsql when some of the nodes emit no results in the
# local stage.
query R
SELECT avg(k) * 2.0 + max(v)::DECIMAL FROM kv WHERE w*2 = k
----
14.0
14.00000000000000000000

# Grouping columns can be eliminated, but should still return zero rows (i.e.
# shouldn't use scalar GroupBy).
Expand Down Expand Up @@ -677,7 +677,7 @@ two 2 true 5
query RRRR
SELECT avg(b), sum(b), avg(d), sum(d) FROM abc
----
1.75 3.5 3.05 6.1
1.75 3.5 3.0500000000000000000 6.1

# Verify summing of intervals
statement ok
Expand Down Expand Up @@ -864,7 +864,7 @@ SELECT var_pop(x) FROM xyz WHERE x = 1
query RRR
SELECT stddev_samp(x), stddev(y::decimal), round(stddev_samp(z), 14) FROM xyz
----
3 2.1213203435596425732 2.51661147842358
3.0000000000000000000 2.1213203435596425732 2.51661147842358

query R
SELECT stddev(x) FROM xyz WHERE x = 1
Expand All @@ -874,7 +874,7 @@ NULL
query RRR
SELECT stddev_pop(x), stddev_pop(y::decimal), round(stddev_pop(z), 14) FROM xyz
----
2.4494897427831780982 1.5 2.05480466765633
2.4494897427831780982 1.5000000000000000000 2.05480466765633

query R
SELECT stddev_pop(x) FROM xyz WHERE x = 1
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/builtin_function
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ SELECT sign(-2.0), sign(-0.0), sign(0.0), sign(2.0)
query RR
SELECT sqrt(4.0::float), sqrt(9.0::decimal)
----
2 3
2 3.0000000000000000000

query error cannot take square root of a negative number
SELECT sqrt(-1.0::float)
Expand Down
18 changes: 9 additions & 9 deletions pkg/sql/logictest/testdata/logic_test/decimal
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ SELECT pow(4.727998800941528e-14::DECIMAL, 0.06081860494226844::DECIMAL)
query RR
SELECT pow(sqrt(1e-10::DECIMAL), 2), sqrt(pow(1e-5::DECIMAL, 2))
----
1E-10 0.00001
1.0000000000000000000E-10 0.000010000000000000000000

# inf returns 1e-16, 0, 2e-16
query RRR
SELECT 1e-16::DECIMAL / 2, 1e-16::DECIMAL / 3, 1e-16::DECIMAL / 2 * 2
----
5E-17 3.3333333333333333333E-17 1.0E-16
5.0000000000000000000E-17 3.3333333333333333333E-17 1.00000000000000000000E-16

# inf returns 1e-8, 0, 0, 0
query RRRR
Expand Down Expand Up @@ -474,21 +474,21 @@ FROM v AS v1(x1), v AS v2(x2) WHERE x2 != 0
0 Infinity 0E-2019 0 0
0 -Infinity -0E-2019 0 -0
0 NaN NaN NaN NaN
1 1 1 0 1
1 -1 -1 0 -1
1 1 1.0000000000000000000 0 1
1 -1 -1.0000000000000000000 0 -1
1 4.2 0.23809523809523809524 1.0 0
1 Infinity 0E-2019 1 0
1 -Infinity -0E-2019 1 -0
1 NaN NaN NaN NaN
-1 1 -1 -0 -1
-1 -1 1 -0 1
-1 1 -1.0000000000000000000 -0 -1
-1 -1 1.0000000000000000000 -0 1
-1 4.2 -0.23809523809523809524 -1.0 -0
-1 Infinity -0E-2019 -1 -0
-1 -Infinity 0E-2019 -1 0
-1 NaN NaN NaN NaN
4.2 1 4.2 0.2 4
4.2 -1 -4.2 0.2 -4
4.2 4.2 1 0.0 1
4.2 1 4.2000000000000000000 0.2 4
4.2 -1 -4.2000000000000000000 0.2 -4
4.2 4.2 1.0000000000000000000 0.0 1
4.2 Infinity 0E-2019 4.2 0
4.2 -Infinity -0E-2019 4.2 -0
4.2 NaN NaN NaN NaN
Expand Down
Loading

0 comments on commit 2abb651

Please sign in to comment.