From a134352e19e4275b019081bd1944587e1b29abf0 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Mon, 31 Jan 2022 13:37:07 -0500 Subject: [PATCH] vendor: bump cockroachdb/apd to v3.1.0 Picks up two PRs that improved the performance of `Quo`, `Sqrt`, `Cbrt`, `Exp`, `Ln`, `Log`, and `Pow`: - https://github.com/cockroachdb/apd/pull/114 - https://github.com/cockroachdb/apd/pull/115 Almost all of the testing changes here are due to the rounding behavior in https://github.com/cockroachdb/apd/pull/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`. --- DEPS.bzl | 6 +- go.mod | 2 +- go.sum | 4 +- pkg/cli/clisqlshell/sql_test.go | 6 +- pkg/sql/colexec/aggregators_test.go | 14 +- .../colexecwindow/window_functions_test.go | 19 +- .../logictest/testdata/logic_test/aggregate | 16 +- .../testdata/logic_test/builtin_function | 2 +- pkg/sql/logictest/testdata/logic_test/decimal | 18 +- .../logictest/testdata/logic_test/distsql_agg | 238 +++--- pkg/sql/logictest/testdata/logic_test/edge | 6 +- pkg/sql/logictest/testdata/logic_test/prepare | 8 +- .../testdata/logic_test/scram_221_upgrade | 1 - pkg/sql/logictest/testdata/logic_test/typing | 4 +- .../logictest/testdata/logic_test/vectorize | 6 +- .../testdata/logic_test/vectorize_window | 24 +- pkg/sql/logictest/testdata/logic_test/window | 786 +++++++++--------- .../opt/norm/testdata/rules/fold_constants | 2 +- .../tree/testdata/eval/arithmetic_operators | 4 +- pkg/sql/sem/tree/testdata/eval/builtins | 2 +- .../sem/tree/testdata/eval/float_decimal_div | 6 +- pkg/sql/sem/tree/testdata/eval/int_arith | 20 +- pkg/sql/sem/tree/testdata/eval/unary | 2 +- vendor | 2 +- 24 files changed, 599 insertions(+), 599 deletions(-) diff --git a/DEPS.bzl b/DEPS.bzl index 3984fa75f3c8..73d322dc86ca 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -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( diff --git a/go.mod b/go.mod index 0f4cffc19dce..f4fcebfdff39 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 48b87d963af3..29e4a7d43ebe 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/cli/clisqlshell/sql_test.go b/pkg/cli/clisqlshell/sql_test.go index 6fb3af5c659f..beec09430d94 100644 --- a/pkg/cli/clisqlshell/sql_test.go +++ b/pkg/cli/clisqlshell/sql_test.go @@ -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 @@ -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 } diff --git a/pkg/sql/colexec/aggregators_test.go b/pkg/sql/colexec/aggregators_test.go index 2e253bfeefbf..56294607353f 100644 --- a/pkg/sql/colexec/aggregators_test.go +++ b/pkg/sql/colexec/aggregators_test.go @@ -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, }, @@ -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, }, @@ -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, diff --git a/pkg/sql/colexec/colexecwindow/window_functions_test.go b/pkg/sql/colexec/colexecwindow/window_functions_test.go index 28e8851d7ced..68905ca5c9a7 100644 --- a/pkg/sql/colexec/colexecwindow/window_functions_test.go +++ b/pkg/sql/colexec/colexecwindow/window_functions_test.go @@ -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}, @@ -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{ @@ -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}, @@ -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{ diff --git a/pkg/sql/logictest/testdata/logic_test/aggregate b/pkg/sql/logictest/testdata/logic_test/aggregate index b2a1980df818..b09ba87a4e06 100644 --- a/pkg/sql/logictest/testdata/logic_test/aggregate +++ b/pkg/sql/logictest/testdata/logic_test/aggregate @@ -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 @@ -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). @@ -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 @@ -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 @@ -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 diff --git a/pkg/sql/logictest/testdata/logic_test/builtin_function b/pkg/sql/logictest/testdata/logic_test/builtin_function index 4379dfba72f4..b91ac4b6a356 100644 --- a/pkg/sql/logictest/testdata/logic_test/builtin_function +++ b/pkg/sql/logictest/testdata/logic_test/builtin_function @@ -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) diff --git a/pkg/sql/logictest/testdata/logic_test/decimal b/pkg/sql/logictest/testdata/logic_test/decimal index be6c597eb1fb..5282c0ca853e 100644 --- a/pkg/sql/logictest/testdata/logic_test/decimal +++ b/pkg/sql/logictest/testdata/logic_test/decimal @@ -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 @@ -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 diff --git a/pkg/sql/logictest/testdata/logic_test/distsql_agg b/pkg/sql/logictest/testdata/logic_test/distsql_agg index 67d568331e0e..df7b5606ca1b 100644 --- a/pkg/sql/logictest/testdata/logic_test/distsql_agg +++ b/pkg/sql/logictest/testdata/logic_test/distsql_agg @@ -79,7 +79,7 @@ SELECT sum(a), min(b), max(c), count(d) FROM data query R SELECT avg(a+b+c::INT+d) FROM data ---- -22 +22.000000000000000000 query RRR SELECT sum(a), round(stddev(b), 1), round(stddev_pop(b), 1) FROM data @@ -104,37 +104,37 @@ SELECT variance(a+b+c::INT+d), var_pop(a+b+c::INT+d) FROM data query RIRRRRRRRR SELECT sum(a), sum_int(a), avg(b), sum(c), avg(d), stddev(a), stddev_pop(a), variance(b), var_pop(b), sum(a+b+c::INT+d) FROM data ---- -55000 55000 5.5 55000 5.5 2.8724249481071304094 2.8722813232690143299 8.2508250825082508251 8.25 220000 +55000 55000 5.5000000000000000000 55000 5.5000000000000000000 2.8724249481071304094 2.8722813232690143299 8.2508250825082508251 8.25 220000 query RIRIRRRRR SELECT sum(a), min(b), max(c), count(d), avg(a+b+c::INT+d), stddev(a+b), stddev_pop(a+b), variance(c::INT+d), var_pop(c::INT+d) FROM data ---- -55000 1 10 10000 22 4.0622223185119375800 4.0620192023179801802 16.50165016501650165 16.5 +55000 1 10 10000 22.000000000000000000 4.0622223185119375800 4.0620192023179801802 16.50165016501650165 16.5 query RRRRIRRRRR SELECT sum(a), stddev(a), stddev_pop(a), avg(a) FILTER (WHERE a > 5), count(b), avg(b), variance(b), var_pop(b) FILTER (WHERE b < 8), sum(b) FILTER (WHERE b < 8), stddev(b) FILTER (WHERE b > 2) FROM data ---- -55000 2.8724249481071304094 2.8722813232690143299 8 10000 5.5 8.2508250825082508251 4 28000 2.2914310663953007487 +55000 2.8724249481071304094 2.8722813232690143299 8.0000000000000000000 10000 5.5000000000000000000 8.2508250825082508251 4 28000 2.2914310663953007487 query RRR SELECT sum(a), avg(DISTINCT a), variance(a) FILTER (WHERE a > 0) FROM data ---- -55000 5.5 8.2508250825082508251 +55000 5.5000000000000000000 8.2508250825082508251 query RRIRR SELECT sum(a), avg(a), count(a), stddev(a), variance(a) FROM data ---- -55000 5.5 10000 2.8724249481071304094 8.2508250825082508251 +55000 5.5000000000000000000 10000 2.8724249481071304094 8.2508250825082508251 query RRRRR SELECT sum(a), avg(b), sum(a), sum(a), avg(b) FROM data ---- -55000 5.5 55000 55000 5.5 +55000 5.5000000000000000000 55000 55000 5.5000000000000000000 query RRIRR SELECT avg(c), sum(c), sum_int(c::INT), avg(d), sum(d) FROM data ---- -5.5 55000 55000 5.5 55000 +5.5 55000 55000 5.5000000000000000000 55000 query II SELECT max(a), min(b) FROM data HAVING min(b) > 2 @@ -196,106 +196,106 @@ SELECT DISTINCT a, b FROM data WHERE (a + b + c::INT) = 27 ORDER BY b,a query RRRI SELECT c, d, sum(a+c::INT) + avg(b+d), sum_int(a+c::INT) + avg(b+d)::INT FROM data GROUP BY c, d ORDER BY c, d ---- -1 1 656.5 657 -1 2 657.5 658 -1 3 658.5 659 -1 4 659.5 660 -1 5 660.5 661 -1 6 661.5 662 -1 7 662.5 663 -1 8 663.5 664 -1 9 664.5 665 -1 10 665.5 666 -2 1 756.5 757 -2 2 757.5 758 -2 3 758.5 759 -2 4 759.5 760 -2 5 760.5 761 -2 6 761.5 762 -2 7 762.5 763 -2 8 763.5 764 -2 9 764.5 765 -2 10 765.5 766 -3 1 856.5 857 -3 2 857.5 858 -3 3 858.5 859 -3 4 859.5 860 -3 5 860.5 861 -3 6 861.5 862 -3 7 862.5 863 -3 8 863.5 864 -3 9 864.5 865 -3 10 865.5 866 -4 1 956.5 957 -4 2 957.5 958 -4 3 958.5 959 -4 4 959.5 960 -4 5 960.5 961 -4 6 961.5 962 -4 7 962.5 963 -4 8 963.5 964 -4 9 964.5 965 -4 10 965.5 966 -5 1 1056.5 1057 -5 2 1057.5 1058 -5 3 1058.5 1059 -5 4 1059.5 1060 -5 5 1060.5 1061 -5 6 1061.5 1062 -5 7 1062.5 1063 -5 8 1063.5 1064 -5 9 1064.5 1065 -5 10 1065.5 1066 -6 1 1156.5 1157 -6 2 1157.5 1158 -6 3 1158.5 1159 -6 4 1159.5 1160 -6 5 1160.5 1161 -6 6 1161.5 1162 -6 7 1162.5 1163 -6 8 1163.5 1164 -6 9 1164.5 1165 -6 10 1165.5 1166 -7 1 1256.5 1257 -7 2 1257.5 1258 -7 3 1258.5 1259 -7 4 1259.5 1260 -7 5 1260.5 1261 -7 6 1261.5 1262 -7 7 1262.5 1263 -7 8 1263.5 1264 -7 9 1264.5 1265 -7 10 1265.5 1266 -8 1 1356.5 1357 -8 2 1357.5 1358 -8 3 1358.5 1359 -8 4 1359.5 1360 -8 5 1360.5 1361 -8 6 1361.5 1362 -8 7 1362.5 1363 -8 8 1363.5 1364 -8 9 1364.5 1365 -8 10 1365.5 1366 -9 1 1456.5 1457 -9 2 1457.5 1458 -9 3 1458.5 1459 -9 4 1459.5 1460 -9 5 1460.5 1461 -9 6 1461.5 1462 -9 7 1462.5 1463 -9 8 1463.5 1464 -9 9 1464.5 1465 -9 10 1465.5 1466 -10 1 1556.5 1557 -10 2 1557.5 1558 -10 3 1558.5 1559 -10 4 1559.5 1560 -10 5 1560.5 1561 -10 6 1561.5 1562 -10 7 1562.5 1563 -10 8 1563.5 1564 -10 9 1564.5 1565 -10 10 1565.5 1566 +1 1 656.5000000000000000000 657 +1 2 657.5000000000000000000 658 +1 3 658.5000000000000000000 659 +1 4 659.5000000000000000000 660 +1 5 660.500000000000000000 661 +1 6 661.500000000000000000 662 +1 7 662.500000000000000000 663 +1 8 663.500000000000000000 664 +1 9 664.500000000000000000 665 +1 10 665.500000000000000000 666 +2 1 756.5000000000000000000 757 +2 2 757.5000000000000000000 758 +2 3 758.5000000000000000000 759 +2 4 759.5000000000000000000 760 +2 5 760.500000000000000000 761 +2 6 761.500000000000000000 762 +2 7 762.500000000000000000 763 +2 8 763.500000000000000000 764 +2 9 764.500000000000000000 765 +2 10 765.500000000000000000 766 +3 1 856.5000000000000000000 857 +3 2 857.5000000000000000000 858 +3 3 858.5000000000000000000 859 +3 4 859.5000000000000000000 860 +3 5 860.500000000000000000 861 +3 6 861.500000000000000000 862 +3 7 862.500000000000000000 863 +3 8 863.500000000000000000 864 +3 9 864.500000000000000000 865 +3 10 865.500000000000000000 866 +4 1 956.5000000000000000000 957 +4 2 957.5000000000000000000 958 +4 3 958.5000000000000000000 959 +4 4 959.5000000000000000000 960 +4 5 960.500000000000000000 961 +4 6 961.500000000000000000 962 +4 7 962.500000000000000000 963 +4 8 963.500000000000000000 964 +4 9 964.500000000000000000 965 +4 10 965.500000000000000000 966 +5 1 1056.5000000000000000000 1057 +5 2 1057.5000000000000000000 1058 +5 3 1058.5000000000000000000 1059 +5 4 1059.5000000000000000000 1060 +5 5 1060.500000000000000000 1061 +5 6 1061.500000000000000000 1062 +5 7 1062.500000000000000000 1063 +5 8 1063.500000000000000000 1064 +5 9 1064.500000000000000000 1065 +5 10 1065.500000000000000000 1066 +6 1 1156.5000000000000000000 1157 +6 2 1157.5000000000000000000 1158 +6 3 1158.5000000000000000000 1159 +6 4 1159.5000000000000000000 1160 +6 5 1160.500000000000000000 1161 +6 6 1161.500000000000000000 1162 +6 7 1162.500000000000000000 1163 +6 8 1163.500000000000000000 1164 +6 9 1164.500000000000000000 1165 +6 10 1165.500000000000000000 1166 +7 1 1256.5000000000000000000 1257 +7 2 1257.5000000000000000000 1258 +7 3 1258.5000000000000000000 1259 +7 4 1259.5000000000000000000 1260 +7 5 1260.500000000000000000 1261 +7 6 1261.500000000000000000 1262 +7 7 1262.500000000000000000 1263 +7 8 1263.500000000000000000 1264 +7 9 1264.500000000000000000 1265 +7 10 1265.500000000000000000 1266 +8 1 1356.5000000000000000000 1357 +8 2 1357.5000000000000000000 1358 +8 3 1358.5000000000000000000 1359 +8 4 1359.5000000000000000000 1360 +8 5 1360.500000000000000000 1361 +8 6 1361.500000000000000000 1362 +8 7 1362.500000000000000000 1363 +8 8 1363.500000000000000000 1364 +8 9 1364.500000000000000000 1365 +8 10 1365.500000000000000000 1366 +9 1 1456.5000000000000000000 1457 +9 2 1457.5000000000000000000 1458 +9 3 1458.5000000000000000000 1459 +9 4 1459.5000000000000000000 1460 +9 5 1460.500000000000000000 1461 +9 6 1461.500000000000000000 1462 +9 7 1462.500000000000000000 1463 +9 8 1463.500000000000000000 1464 +9 9 1464.500000000000000000 1465 +9 10 1465.500000000000000000 1466 +10 1 1556.5000000000000000000 1557 +10 2 1557.5000000000000000000 1558 +10 3 1558.5000000000000000000 1559 +10 4 1559.5000000000000000000 1560 +10 5 1560.500000000000000000 1561 +10 6 1561.500000000000000000 1562 +10 7 1562.500000000000000000 1563 +10 8 1563.500000000000000000 1564 +10 9 1564.500000000000000000 1565 +10 10 1565.500000000000000000 1566 # Test plans with empty streams. statement ok @@ -361,16 +361,16 @@ SELECT sum(a), sum(b), sum(c) FROM data GROUP BY d HAVING sum(a+b) > 10 query RR rowsort SELECT avg(a+b), c FROM data GROUP BY c, d HAVING c = d ---- -11 1 -11 2 -11 3 -11 4 -11 5 -11 6 -11 7 -11 8 -11 9 -11 10 +11.000000000000000000 3 +11.000000000000000000 10 +11.000000000000000000 5 +11.000000000000000000 4 +11.000000000000000000 6 +11.000000000000000000 7 +11.000000000000000000 1 +11.000000000000000000 8 +11.000000000000000000 2 +11.000000000000000000 9 query RRIR rowsort SELECT sum(a+b), sum(a+b) FILTER (WHERE a < d), sum_int(a+b) FILTER (WHERE a < d), sum(a+b) FILTER (WHERE a = c) FROM data GROUP BY d @@ -410,7 +410,7 @@ VALUES (1, 2, 1.0, 'string1'), (4, 3, 2.3, 'string2') query IIR SELECT max(t.a), min(t.b), avg(t.c) FROM (VALUES (1, 2, 3), (4, 5, 6), (7, 8, 0)) AS t(a, b, c) WHERE b > 3 ---- -7 5 3 +7 5 3.0000000000000000000 query ITIR SELECT * FROM (VALUES (1, '222'), (2, '444')) t1(a,b) JOIN (VALUES (1, 100.0), (3, 32.0)) t2(a,b) ON t1.a = t2.a diff --git a/pkg/sql/logictest/testdata/logic_test/edge b/pkg/sql/logictest/testdata/logic_test/edge index dedeb431aebf..8ea8b4ad9810 100644 --- a/pkg/sql/logictest/testdata/logic_test/edge +++ b/pkg/sql/logictest/testdata/logic_test/edge @@ -183,7 +183,7 @@ FROM WHERE t.key = 'max' ---- -131068 8589934588 36893488147419103228 32767 2147483647 9223372036854775807 +131068 8589934588 36893488147419103228 32767.000000000000000 2147483647.0000000000 9223372036854775807.0 query II SELECT @@ -215,7 +215,7 @@ FROM WHERE t.key = 'min' ---- --131072 -8589934592 -36893488147419103232 -1.36112938655412e+39 -Inf -32768 -2147483648 -9223372036854775808 -3.40282346638529e+38 -Inf +-131072 -8589934592 -36893488147419103232 -1.36112938655412e+39 -Inf -32768.000000000000000 -2147483648.0000000000 -9223372036854775808.0 -3.40282346638529e+38 -Inf query II SELECT @@ -245,7 +245,7 @@ SELECT FROM t ---- --1 -1 -1 0 0 -0.5 -0.5 -0.5 0 0 +-1 -1 -1 0 0 -0.50000000000000000000 -0.50000000000000000000 -0.50000000000000000000 0 0 query III SELECT diff --git a/pkg/sql/logictest/testdata/logic_test/prepare b/pkg/sql/logictest/testdata/logic_test/prepare index e957d88eb23f..089f1eca2020 100644 --- a/pkg/sql/logictest/testdata/logic_test/prepare +++ b/pkg/sql/logictest/testdata/logic_test/prepare @@ -196,8 +196,8 @@ PREPARE x AS SELECT avg(column1) OVER (PARTITION BY column2) FROM (VALUES (1, 2) query R rowsort EXECUTE x ---- -1 -3 +1.0000000000000000000 +3.0000000000000000000 statement PREPARE y AS SELECT avg(a.column1) OVER (PARTITION BY a.column2) FROM (VALUES (1, 2), (3, 4)) a @@ -205,8 +205,8 @@ PREPARE y AS SELECT avg(a.column1) OVER (PARTITION BY a.column2) FROM (VALUES (1 query R rowsort EXECUTE y ---- -1 -3 +1.0000000000000000000 +3.0000000000000000000 statement DEALLOCATE ALL diff --git a/pkg/sql/logictest/testdata/logic_test/scram_221_upgrade b/pkg/sql/logictest/testdata/logic_test/scram_221_upgrade index 8608c7db99a7..2874881b3a69 100644 --- a/pkg/sql/logictest/testdata/logic_test/scram_221_upgrade +++ b/pkg/sql/logictest/testdata/logic_test/scram_221_upgrade @@ -13,4 +13,3 @@ query T show password_encryption ---- crdb-bcrypt - diff --git a/pkg/sql/logictest/testdata/logic_test/typing b/pkg/sql/logictest/testdata/logic_test/typing index 1d0abda00b79..a1a3c6a39128 100644 --- a/pkg/sql/logictest/testdata/logic_test/typing +++ b/pkg/sql/logictest/testdata/logic_test/typing @@ -36,7 +36,7 @@ INSERT INTO d(x) VALUES (((9 / 3) * (1 / 3))), (2.0), (2.4 + 4.6) query R rowsort SELECT * FROM d ---- -0.99999999999999999999 +0.999999999999999999990000000000000000000 2.0 7.0 @@ -46,7 +46,7 @@ UPDATE d SET x = x + 1 WHERE x + sqrt(x) >= 2 + .1 query R rowsort SELECT * FROM d ---- -0.99999999999999999999 +0.999999999999999999990000000000000000000 3.0 8.0 diff --git a/pkg/sql/logictest/testdata/logic_test/vectorize b/pkg/sql/logictest/testdata/logic_test/vectorize index 89dfa56e0986..4cdf66068483 100644 --- a/pkg/sql/logictest/testdata/logic_test/vectorize +++ b/pkg/sql/logictest/testdata/logic_test/vectorize @@ -258,7 +258,7 @@ SELECT a*b, a*c, b*c, b*d, c*d FROM intdecfloat query RRRRR SELECT a/b, a/c, b/c, b/d, c/d FROM intdecfloat ---- -0.5 0.33333333333333333333 0.66666666666666666667 0.5 0.75 +0.50000000000000000000 0.33333333333333333333 0.66666666666666666667 0.50000000000000000000 0.75000000000000000000 # vectorized decimal arithmetic statement ok @@ -273,7 +273,7 @@ SELECT a*b FROM decimals query R SELECT a/b FROM decimals ---- -1.0E+201 +1.0000000000000000000E+201 query R SELECT a+b FROM decimals @@ -499,7 +499,7 @@ SELECT * FROM t38754 query T SELECT a/b FROM a WHERE b = 2 ---- -0.5 +0.50000000000000000000 # Test mixed types comparison. query I diff --git a/pkg/sql/logictest/testdata/logic_test/vectorize_window b/pkg/sql/logictest/testdata/logic_test/vectorize_window index 26b1e91f8bd7..246613c36670 100644 --- a/pkg/sql/logictest/testdata/logic_test/vectorize_window +++ b/pkg/sql/logictest/testdata/logic_test/vectorize_window @@ -252,19 +252,19 @@ SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER FROM t WINDOW w AS (ORDER BY c, b) ---- 0 1 0 0 0 1 1 0 0 0 true true foo -1 1 1 1 1 2 2 0.5 1 0 false true foobar +1 1 1 1 1 2 2 0.50000000000000000000 1 0 false true foobar 0 2 2 1 1 3 3 0.33333333333333333333 1 0 false true foobarbaz -1 2 3 2 2 4 4 0.5 1 0 false true foobarbazdeadbeef +1 2 3 2 2 4 4 0.50000000000000000000 1 0 false true foobarbazdeadbeef query IIIIRIIRIIBBT rowsort SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER w, avg(a) OVER w, max(a) OVER w, min(a) OVER w, bool_and(d) OVER w, bool_or(d) OVER w, concat_agg(e) OVER w FROM t WINDOW w AS (PARTITION BY a ORDER BY c) ---- -0 1 0 0 0 1 1 0 0 0 true true foo -0 2 2 0 0 2 2 0 0 0 true true foobaz -1 1 1 1 1 1 1 1 1 1 false false bar -1 2 3 2 2 2 2 1 1 1 false false bardeadbeef +0 1 0 0 0 1 1 0 0 0 true true foo +0 2 2 0 0 2 2 0 0 0 true true foobaz +1 1 1 1 1 1 1 1.0000000000000000000 1 1 false false bar +1 2 3 2 2 2 2 1.0000000000000000000 1 1 false false bardeadbeef query IIIIRIIRIIBBT rowsort SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER w, avg(a) OVER w, @@ -272,9 +272,9 @@ SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER FROM t WINDOW w AS (ORDER BY c, b ROWS BETWEEN 5 PRECEDING AND CURRENT ROW) ---- 0 1 0 0 0 1 1 0 0 0 true true foo -1 1 1 1 1 2 2 0.5 1 0 false true foobar +1 1 1 1 1 2 2 0.50000000000000000000 1 0 false true foobar 0 2 2 1 1 3 3 0.33333333333333333333 1 0 false true foobarbaz -1 2 3 2 2 4 4 0.5 1 0 false true foobarbazdeadbeef +1 2 3 2 2 4 4 0.50000000000000000000 1 0 false true foobarbazdeadbeef query IIIIRIIRIIBBT rowsort SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER w, avg(a) OVER w, @@ -282,9 +282,9 @@ SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER FROM t WINDOW w AS (ORDER BY c, b GROUPS BETWEEN 5 PRECEDING AND CURRENT ROW) ---- 0 1 0 0 0 1 1 0 0 0 true true foo -1 1 1 1 1 2 2 0.5 1 0 false true foobar +1 1 1 1 1 2 2 0.50000000000000000000 1 0 false true foobar 0 2 2 1 1 3 3 0.33333333333333333333 1 0 false true foobarbaz -1 2 3 2 2 4 4 0.5 1 0 false true foobarbazdeadbeef +1 2 3 2 2 4 4 0.50000000000000000000 1 0 false true foobarbazdeadbeef query IIIIRIIRIIBBT rowsort SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER w, avg(a) OVER w, @@ -292,6 +292,6 @@ SELECT a, b, c, sum_int(a) OVER w, sum(a) OVER w, count(*) OVER w, count(a) OVER FROM t WINDOW w AS (ORDER BY c RANGE BETWEEN 5 PRECEDING AND CURRENT ROW) ---- 0 1 0 0 0 1 1 0 0 0 true true foo -1 1 1 1 1 2 2 0.5 1 0 false true foobar +1 1 1 1 1 2 2 0.50000000000000000000 1 0 false true foobar 0 2 2 1 1 3 3 0.33333333333333333333 1 0 false true foobarbaz -1 2 3 2 2 4 4 0.5 1 0 false true foobarbazdeadbeef +1 2 3 2 2 4 4 0.50000000000000000000 1 0 false true foobarbazdeadbeef diff --git a/pkg/sql/logictest/testdata/logic_test/window b/pkg/sql/logictest/testdata/logic_test/window index e12dad886561..929b65baa112 100644 --- a/pkg/sql/logictest/testdata/logic_test/window +++ b/pkg/sql/logictest/testdata/logic_test/window @@ -50,12 +50,12 @@ SELECT 1 FROM kv GROUP BY 1 HAVING sum(1) OVER (PARTITION BY 1) > 1 query R SELECT avg(k) OVER () FROM kv ORDER BY 1 ---- -5 -5 -5 -5 -5 -5 +5.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 query R SELECT avg(k) OVER (PARTITION BY v) FROM kv ORDER BY 1 @@ -63,160 +63,160 @@ SELECT avg(k) OVER (PARTITION BY v) FROM kv ORDER BY 1 4.6666666666666666667 4.6666666666666666667 4.6666666666666666667 -5 -5.5 -5.5 +5.0000000000000000000 +5.5000000000000000000 +5.5000000000000000000 query R SELECT avg(k) OVER (PARTITION BY w) FROM kv ORDER BY 1 ---- -3.5 -3.5 -4 -4 -7.5 -7.5 +3.5000000000000000000 +3.5000000000000000000 +4.0000000000000000000 +4.0000000000000000000 +7.5000000000000000000 +7.5000000000000000000 query R SELECT avg(k) OVER (PARTITION BY b) FROM kv ORDER BY 1 ---- -4.25 -4.25 -4.25 -4.25 -6.5 -6.5 +4.2500000000000000000 +4.2500000000000000000 +4.2500000000000000000 +4.2500000000000000000 +6.5000000000000000000 +6.5000000000000000000 query R SELECT avg(k) OVER (PARTITION BY w, b) FROM kv ORDER BY 1 ---- -3 -3.5 -3.5 -5 -7 -8 +3.0000000000000000000 +3.5000000000000000000 +3.5000000000000000000 +5.0000000000000000000 +7.0000000000000000000 +8.0000000000000000000 query R SELECT avg(k) OVER (PARTITION BY kv.*) FROM kv ORDER BY 1 ---- -1 -3 -5 -6 -7 -8 +1.0000000000000000000 +3.0000000000000000000 +5.0000000000000000000 +6.0000000000000000000 +7.0000000000000000000 +8.0000000000000000000 query R SELECT avg(k) OVER (ORDER BY w) FROM kv ORDER BY 1 ---- -5 -5 -5.5 -5.5 -7.5 -7.5 +5.0000000000000000000 +5.0000000000000000000 +5.5000000000000000000 +5.5000000000000000000 +7.5000000000000000000 +7.5000000000000000000 query R SELECT avg(k) OVER (ORDER BY b) FROM kv ORDER BY 1 ---- -5 -5 -5 -5 -6.5 -6.5 +5.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 +6.5000000000000000000 +6.5000000000000000000 query R SELECT avg(k) OVER (ORDER BY w, b) FROM kv ORDER BY 1 ---- -5 -5.4 -5.5 -5.5 -7.5 -8 +5.0000000000000000000 +5.4000000000000000000 +5.5000000000000000000 +5.5000000000000000000 +7.5000000000000000000 +8.0000000000000000000 query R SELECT avg(k) OVER (ORDER BY 1-w) FROM kv ORDER BY 1 ---- -3.75 -3.75 -4 -4 -5 -5 +3.7500000000000000000 +3.7500000000000000000 +4.0000000000000000000 +4.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 query R SELECT avg(k) OVER (ORDER BY kv.*) FROM kv ORDER BY 1 ---- -1 -2 -3 -3.75 -4.4 -5 +1.0000000000000000000 +2.0000000000000000000 +3.0000000000000000000 +3.7500000000000000000 +4.4000000000000000000 +5.0000000000000000000 query R SELECT avg(k) OVER (ORDER BY w DESC) FROM kv ORDER BY 1 ---- -3.75 -3.75 -4 -4 -5 -5 +3.7500000000000000000 +3.7500000000000000000 +4.0000000000000000000 +4.0000000000000000000 +5.0000000000000000000 +5.0000000000000000000 query R SELECT avg(k) OVER (PARTITION BY v ORDER BY w) FROM kv ORDER BY 1 ---- 4.6666666666666666667 4.6666666666666666667 -5 -5.5 -7 -8 +5.0000000000000000000 +5.5000000000000000000 +7.0000000000000000000 +8.0000000000000000000 query R SELECT avg(k) OVER w FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY 1 ---- 4.6666666666666666667 4.6666666666666666667 -5 -5.5 -7 -8 +5.0000000000000000000 +5.5000000000000000000 +7.0000000000000000000 +8.0000000000000000000 query R SELECT avg(k) OVER (w) FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY 1 ---- 4.6666666666666666667 4.6666666666666666667 -5 -5.5 -7 -8 +5.0000000000000000000 +5.5000000000000000000 +7.0000000000000000000 +8.0000000000000000000 query R SELECT avg(k) OVER (w ORDER BY w) FROM kv WINDOW w AS (PARTITION BY v) ORDER BY 1 ---- 4.6666666666666666667 4.6666666666666666667 -5 -5.5 -7 -8 +5.0000000000000000000 +5.5000000000000000000 +7.0000000000000000000 +8.0000000000000000000 query IIIRRTBTR colnames SELECT *, avg(k) OVER (w ORDER BY w) FROM kv WINDOW w AS (PARTITION BY v) ORDER BY 1 ---- k v w f d s b i avg 1 2 3 1 1 a true 00:01:00 4.6666666666666666667 -3 4 5 2 8 a true 00:00:02 5.5 -5 NULL 5 9.9 -321 NULL false NULL 5 +3 4 5 2 8 a true 00:00:02 5.5000000000000000000 +5 NULL 5 9.9 -321 NULL false NULL 5.0000000000000000000 6 2 3 4.4 4.4 b true 00:00:00.001 4.6666666666666666667 -7 2 2 6 7.9 b true 4 days 7 -8 4 2 3 3 A false 3 years 8 +7 2 2 6 7.9 b true 4 days 7.0000000000000000000 +8 4 2 3 3 A false 3 years 8.0000000000000000000 query IIIRRTBTR colnames SELECT *, avg(k) OVER w FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY avg(k) OVER w, k @@ -224,10 +224,10 @@ SELECT *, avg(k) OVER w FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY k v w f d s b i avg 1 2 3 1 1 a true 00:01:00 4.6666666666666666667 6 2 3 4.4 4.4 b true 00:00:00.001 4.6666666666666666667 -5 NULL 5 9.9 -321 NULL false NULL 5 -3 4 5 2 8 a true 00:00:02 5.5 -7 2 2 6 7.9 b true 4 days 7 -8 4 2 3 3 A false 3 years 8 +5 NULL 5 9.9 -321 NULL false NULL 5.0000000000000000000 +3 4 5 2 8 a true 00:00:02 5.5000000000000000000 +7 2 2 6 7.9 b true 4 days 7.0000000000000000000 +8 4 2 3 3 A false 3 years 8.0000000000000000000 query IIIRRTBT colnames SELECT * FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY avg(k) OVER w DESC, k @@ -272,17 +272,17 @@ SELECT avg(avg(k) OVER ()) FROM kv ORDER BY 1 query R SELECT avg(avg(k)) OVER () FROM kv ORDER BY 1 ---- -5 +5.0000000000000000000 query RR SELECT avg(k) OVER (), avg(v) OVER () FROM kv ORDER BY 1 ---- -5 2.8 -5 2.8 -5 2.8 -5 2.8 -5 2.8 -5 2.8 +5.0000000000000000000 2.8000000000000000000 +5.0000000000000000000 2.8000000000000000000 +5.0000000000000000000 2.8000000000000000000 +5.0000000000000000000 2.8000000000000000000 +5.0000000000000000000 2.8000000000000000000 +5.0000000000000000000 2.8000000000000000000 query error OVER specified, but now\(\) is neither a window function nor an aggregate function SELECT now() OVER () FROM kv ORDER BY 1 @@ -322,42 +322,42 @@ SELECT avg(f) OVER (PARTITION BY v ORDER BY w) FROM kv ORDER BY 1 query R SELECT avg(d) OVER (PARTITION BY v ORDER BY w) FROM kv ORDER BY 1 ---- --321 - 3 - 4.4333333333333333333 - 4.4333333333333333333 - 5.5 - 7.9 +-321.00000000000000000 +3.0000000000000000000 +4.4333333333333333333 +4.4333333333333333333 +5.5000000000000000000 +7.9000000000000000000 query R SELECT avg(d) OVER (PARTITION BY w ORDER BY v) FROM kv ORDER BY 1 ---- --321 --156.5 - 2.7 - 2.7 - 5.45 - 7.9 +-321.00000000000000000 +-156.50000000000000000 +2.7000000000000000000 +2.7000000000000000000 +5.4500000000000000000 +7.9000000000000000000 query R SELECT (avg(d) OVER (PARTITION BY v ORDER BY w) + avg(d) OVER (PARTITION BY v ORDER BY w)) FROM kv ORDER BY 1 ---- --642 - 6 - 8.8666666666666666666 - 8.8666666666666666666 - 11.0 - 15.8 +-642.00000000000000000 +6.0000000000000000000 +8.8666666666666666666 +8.8666666666666666666 +11.0000000000000000000 +15.8000000000000000000 query R SELECT (avg(d) OVER (PARTITION BY v ORDER BY w) + avg(d) OVER (PARTITION BY w ORDER BY v)) FROM kv ORDER BY 1 ---- --642 --151.0 - 7.1333333333333333333 - 7.1333333333333333333 - 8.45 - 15.8 +-642.00000000000000000 +-151.0000000000000000000 +7.1333333333333333333 +7.1333333333333333333 +8.4500000000000000000 +15.8000000000000000000 query R SELECT avg(d) OVER (PARTITION BY v) FROM kv WHERE FALSE ORDER BY 1 @@ -370,7 +370,7 @@ SELECT avg(d) OVER (PARTITION BY v, v, v, v, v, v, v, v, v, v) FROM kv WHERE FAL query R SELECT avg(d) OVER (PARTITION BY v, v, v, v, v, v, v, v, v, v) FROM kv WHERE k = 3 ORDER BY 1 ---- -8 +8.0000000000000000000 query IT SELECT k, concat_agg(s) OVER (PARTITION BY k ORDER BY w) FROM kv ORDER BY 1 @@ -545,22 +545,22 @@ SELECT k, max(stddev) OVER (ORDER BY d DESC) FROM (SELECT k, d, stddev(d) OVER ( query IRIII SELECT k, (rank() OVER wind + avg(w) OVER wind), w, (v + row_number() OVER wind), v FROM kv WINDOW wind AS (ORDER BY k) ORDER BY 1 ---- -1 4 3 3 2 -3 6 5 6 4 +1 4.0000000000000000000 3 3 2 +3 6.0000000000000000000 5 6 4 5 7.3333333333333333333 5 NULL NULL -6 8 3 6 2 -7 8.6 2 7 2 +6 8.0000000000000000000 3 6 2 +7 8.6000000000000000000 2 7 2 8 9.3333333333333333333 2 10 4 query TIRRI SELECT s, w + k, (sum(w) OVER wind + avg(d) OVER wind), (min(w) OVER wind + d), v FROM kv WINDOW wind AS (ORDER BY w, k) ORDER BY k ---- a 4 10.9666666666666666667 3 2 -a 8 19.86 10 4 -NULL 10 -29.45 -319 NULL -b 9 14.075 6.4 2 -b 9 9.9 9.9 2 -A 10 9.45 5 4 +a 8 19.8600000000000000000 10 4 +NULL 10 -29.450000000000000000 -319 NULL +b 9 14.0750000000000000000 6.4 2 +b 9 9.9000000000000000000 9.9 2 +A 10 9.4500000000000000000 5 4 query IIII SELECT k, v + w, round(rank() OVER wind + lead(k, 3, v) OVER wind + lag(w, 1, 2) OVER wind + f::DECIMAL + avg(d) OVER wind)::INT, round(row_number() OVER wind::FLOAT + round(f) + dense_rank() OVER wind::FLOAT)::INT FROM kv WINDOW wind as (PARTITION BY v ORDER BY k) ORDER BY k @@ -605,8 +605,8 @@ NULL NULL query R SELECT f::DECIMAL + round(max(k) * w * avg(d) OVER wind) + (lead(f, 2, 17::FLOAT) OVER wind::DECIMAL / d * row_number() OVER wind) FROM kv GROUP BY k, w, f, d WINDOW wind AS (ORDER BY k) ORDER BY k ---- -13.9 -71.10 +13.9000000000000000000 +71.10000000000000000000 -2590.156074766355140186916 -1376.87272727272727272728 -822.2405063291139240505 @@ -615,19 +615,19 @@ SELECT f::DECIMAL + round(max(k) * w * avg(d) OVER wind) + (lead(f, 2, 17::FLOAT query R SELECT round(max(w) * w * avg(w) OVER wind) + (lead(w, 2, 17) OVER wind::DECIMAL / w * row_number() OVER wind) FROM kv GROUP BY w WINDOW wind AS (PARTITION BY w) ORDER BY 1 ---- -16.5 +16.5000000000000000000 32.6666666666666666667 -128.4 +128.4000000000000000000 query IRRIRIR SELECT k, avg(d) OVER w1, avg(d) OVER w2, row_number() OVER w2, sum(f) OVER w1, row_number() OVER w1, sum(f) OVER w2 FROM kv WINDOW w1 AS (ORDER BY k), w2 AS (ORDER BY w, k) ORDER BY k ---- -1 1 3.9666666666666666667 3 1 1 10 -3 4.5 4.86 5 3 2 16.4 -5 -104 -49.45 6 12.9 3 26.3 -6 -76.9 4.075 4 17.3 4 14.4 -7 -59.94 7.9 1 23.3 5 6 -8 -49.45 5.45 2 26.3 6 9 +1 1.0000000000000000000 3.9666666666666666667 3 1 1 10 +3 4.5000000000000000000 4.8600000000000000000 5 3 2 16.4 +5 -104.00000000000000000 -49.450000000000000000 6 12.9 3 26.3 +6 -76.900000000000000000 4.0750000000000000000 4 17.3 4 14.4 +7 -59.940000000000000000 7.9000000000000000000 1 23.3 5 6 +8 -49.450000000000000000 5.4500000000000000000 2 26.3 6 9 query R SELECT round((avg(d) OVER wind) * max(k) + (lag(d, 1, 42.0) OVER wind) * max(d)) FROM kv GROUP BY d, k WINDOW wind AS (ORDER BY k) ORDER BY k @@ -643,11 +643,11 @@ query RR SELECT avg(k) OVER w, avg(k) OVER w + 1 FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY k ---- 4.6666666666666666667 5.6666666666666666667 -5.5 6.5 -5 6 +5.5000000000000000000 6.5000000000000000000 +5.0000000000000000000 6.0000000000000000000 4.6666666666666666667 5.6666666666666666667 -7 8 -8 9 +7.0000000000000000000 8.0000000000000000000 +8.0000000000000000000 9.0000000000000000000 statement OK INSERT INTO kv VALUES @@ -781,27 +781,27 @@ query IRI SELECT k, (rank() OVER w + avg(w) OVER w), k FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY 1 ---- 1 4.6666666666666666667 1 -3 5.5 3 -5 6 5 +3 5.5000000000000000000 3 +5 6.0000000000000000000 5 6 4.6666666666666666667 6 -7 3 7 -8 3 8 -9 8.25 9 +7 3.0000000000000000000 7 +8 3.0000000000000000000 8 +9 8.2500000000000000000 9 10 8.3333333333333333333 10 -11 9 11 +11 9.0000000000000000000 11 query IRI SELECT k, (avg(w) OVER w + rank() OVER w), k FROM kv WINDOW w AS (PARTITION BY v ORDER BY w) ORDER BY 1 ---- 1 4.6666666666666666667 1 -3 5.5 3 -5 6 5 +3 5.5000000000000000000 3 +5 6.0000000000000000000 5 6 4.6666666666666666667 6 -7 3 7 -8 3 8 -9 8.25 9 +7 3.0000000000000000000 7 +8 3.0000000000000000000 8 +9 8.2500000000000000000 9 10 8.3333333333333333333 10 -11 9 11 +11 9.0000000000000000000 11 query II SELECT k, dense_rank() OVER () FROM kv ORDER BY 1 @@ -2010,12 +2010,12 @@ SELECT max(i) * (row_number() OVER (ORDER BY max(i))) FROM (SELECT 1 AS i, 2 AS query R SELECT (1/j) * max(i) * (row_number() OVER (ORDER BY max(i))) FROM (SELECT 1 AS i, 2 AS j) GROUP BY j ---- -0.5 +0.50000000000000000000 query R SELECT max(i) * (1/j) * (row_number() OVER (ORDER BY max(i))) FROM (SELECT 1 AS i, 2 AS j) GROUP BY j ---- -0.5 +0.50000000000000000000 # regression test for #23798 until #10495 is fixed. statement error function reserved for internal use @@ -2128,17 +2128,17 @@ iPad 700.00 NULL query TTRR SELECT product_name, group_name, price, avg(price) OVER (PARTITION BY group_name ORDER BY price, product_name ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS avg_of_three FROM products ORDER BY group_name, price, product_name ---- -Lenovo Thinkpad Laptop 700.00 700.00 -Sony VAIO Laptop 700.00 733.33333333333333333 -Dell Laptop 800.00 900.00 -HP Elite Laptop 1200.00 1000.00 -Microsoft Lumia Smartphone 200.00 300.00 -HTC One Smartphone 400.00 366.66666666666666667 -Nexus Smartphone 500.00 600.00 -iPhone Smartphone 900.00 700.00 -Kindle Fire Tablet 150.00 175.00 -Samsung Tablet 200.00 350.00 -iPad Tablet 700.00 450.00 +Lenovo Thinkpad Laptop 700.00 700.00000000000000000 +Sony VAIO Laptop 700.00 733.33333333333333333 +Dell Laptop 800.00 900.00000000000000000 +HP Elite Laptop 1200.00 1000.0000000000000000 +Microsoft Lumia Smartphone 200.00 300.00000000000000000 +HTC One Smartphone 400.00 366.66666666666666667 +Nexus Smartphone 500.00 600.00000000000000000 +iPhone Smartphone 900.00 700.00000000000000000 +Kindle Fire Tablet 150.00 175.00000000000000000 +Samsung Tablet 200.00 350.00000000000000000 +iPad Tablet 700.00 450.00000000000000000 query TTRR SELECT product_name, group_name, price, avg(priceFloat) OVER (PARTITION BY group_name ORDER BY price, product_name ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS avg_of_three_floats FROM products ORDER BY group_name, price, product_name @@ -2158,32 +2158,32 @@ iPad Tablet 700.00 450 query TTRR SELECT product_name, group_name, price, avg(priceInt) OVER (PARTITION BY group_name ORDER BY price, product_name ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS avg_of_three_ints FROM products ORDER BY group_name, price, product_name ---- -Lenovo Thinkpad Laptop 700.00 700 +Lenovo Thinkpad Laptop 700.00 700.00000000000000000 Sony VAIO Laptop 700.00 733.33333333333333333 -Dell Laptop 800.00 900 -HP Elite Laptop 1200.00 1000 -Microsoft Lumia Smartphone 200.00 300 +Dell Laptop 800.00 900.00000000000000000 +HP Elite Laptop 1200.00 1000.0000000000000000 +Microsoft Lumia Smartphone 200.00 300.00000000000000000 HTC One Smartphone 400.00 366.66666666666666667 -Nexus Smartphone 500.00 600 -iPhone Smartphone 900.00 700 -Kindle Fire Tablet 150.00 175 -Samsung Tablet 200.00 350 -iPad Tablet 700.00 450 +Nexus Smartphone 500.00 600.00000000000000000 +iPhone Smartphone 900.00 700.00000000000000000 +Kindle Fire Tablet 150.00 175.00000000000000000 +Samsung Tablet 200.00 350.00000000000000000 +iPad Tablet 700.00 450.00000000000000000 query TTRR SELECT group_name, product_name, price, avg(price) OVER (PARTITION BY group_name ORDER BY group_id ROWS (SELECT count(*) FROM PRODUCTS WHERE price = 200) PRECEDING) AS running_avg_of_three FROM products ORDER BY group_id ---- -Smartphone Microsoft Lumia 200.00 200.00 -Smartphone HTC One 400.00 300.00 +Smartphone Microsoft Lumia 200.00 200.00000000000000000 +Smartphone HTC One 400.00 300.00000000000000000 Smartphone Nexus 500.00 366.66666666666666667 -Smartphone iPhone 900.00 600.00 -Laptop HP Elite 1200.00 1200.00 -Laptop Lenovo Thinkpad 700.00 950.00 +Smartphone iPhone 900.00 600.00000000000000000 +Laptop HP Elite 1200.00 1200.0000000000000000 +Laptop Lenovo Thinkpad 700.00 950.00000000000000000 Laptop Sony VAIO 700.00 866.66666666666666667 Laptop Dell 800.00 733.33333333333333333 -Tablet iPad 700.00 700.00 -Tablet Kindle Fire 150.00 425.00 -Tablet Samsung 200.00 350.00 +Tablet iPad 700.00 700.00000000000000000 +Tablet Kindle Fire 150.00 425.00000000000000000 +Tablet Samsung 200.00 350.00000000000000000 query TTRR SELECT group_name, product_name, price, sum(price) OVER (PARTITION BY group_name ORDER BY group_id ROWS 2 PRECEDING) AS running_sum FROM products ORDER BY group_id @@ -2233,17 +2233,17 @@ Tablet Samsung 200.00 {200.00,150.00,700.00} {200.00,15 query TTRR SELECT group_name, product_name, price, avg(price) OVER (PARTITION BY group_name RANGE UNBOUNDED PRECEDING) AS avg_price FROM products ORDER BY group_id ---- -Smartphone Microsoft Lumia 200.00 500.00 -Smartphone HTC One 400.00 500.00 -Smartphone Nexus 500.00 500.00 -Smartphone iPhone 900.00 500.00 -Laptop HP Elite 1200.00 850.00 -Laptop Lenovo Thinkpad 700.00 850.00 -Laptop Sony VAIO 700.00 850.00 -Laptop Dell 800.00 850.00 -Tablet iPad 700.00 350.00 -Tablet Kindle Fire 150.00 350.00 -Tablet Samsung 200.00 350.00 +Smartphone Microsoft Lumia 200.00 500.00000000000000000 +Smartphone HTC One 400.00 500.00000000000000000 +Smartphone Nexus 500.00 500.00000000000000000 +Smartphone iPhone 900.00 500.00000000000000000 +Laptop HP Elite 1200.00 850.00000000000000000 +Laptop Lenovo Thinkpad 700.00 850.00000000000000000 +Laptop Sony VAIO 700.00 850.00000000000000000 +Laptop Dell 800.00 850.00000000000000000 +Tablet iPad 700.00 350.00000000000000000 +Tablet Kindle Fire 150.00 350.00000000000000000 +Tablet Samsung 200.00 350.00000000000000000 query TTRT SELECT group_name, product_name, price, min(price) OVER (PARTITION BY group_name ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING) AS min_over_empty_frame FROM products ORDER BY group_id @@ -2293,47 +2293,47 @@ Tablet Samsung 200.00 200.00 query TTRR SELECT group_name, product_name, price, avg(price) OVER (PARTITION BY group_name ORDER BY group_id ROWS BETWEEN 1 FOLLOWING AND UNBOUNDED FOLLOWING) AS running_avg FROM products ORDER BY group_id ---- -Smartphone Microsoft Lumia 200.00 600.00 -Smartphone HTC One 400.00 700.00 -Smartphone Nexus 500.00 900.00 -Smartphone iPhone 900.00 NULL +Smartphone Microsoft Lumia 200.00 600.00000000000000000 +Smartphone HTC One 400.00 700.00000000000000000 +Smartphone Nexus 500.00 900.00000000000000000 +Smartphone iPhone 900.00 NULL Laptop HP Elite 1200.00 733.33333333333333333 -Laptop Lenovo Thinkpad 700.00 750.00 -Laptop Sony VAIO 700.00 800.00 -Laptop Dell 800.00 NULL -Tablet iPad 700.00 175.00 -Tablet Kindle Fire 150.00 200.00 -Tablet Samsung 200.00 NULL +Laptop Lenovo Thinkpad 700.00 750.00000000000000000 +Laptop Sony VAIO 700.00 800.00000000000000000 +Laptop Dell 800.00 NULL +Tablet iPad 700.00 175.00000000000000000 +Tablet Kindle Fire 150.00 200.00000000000000000 +Tablet Samsung 200.00 NULL query TRRRRR SELECT product_name, price, min(price) OVER (PARTITION BY group_name ORDER BY group_id ROWS UNBOUNDED PRECEDING), max(price) OVER (PARTITION BY group_name ORDER BY group_id ROWS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING), sum(price) OVER (PARTITION BY group_name ORDER BY group_id ROWS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING), avg(price) OVER (PARTITION BY group_name ROWS CURRENT ROW) FROM products ORDER BY group_id ---- -Microsoft Lumia 200.00 200.00 400.00 2000.00 200.00 -HTC One 400.00 200.00 500.00 2000.00 400.00 -Nexus 500.00 200.00 900.00 1800.00 500.00 -iPhone 900.00 200.00 900.00 1400.00 900.00 -HP Elite 1200.00 1200.00 1200.00 3400.00 1200.00 -Lenovo Thinkpad 700.00 700.00 1200.00 3400.00 700.00 -Sony VAIO 700.00 700.00 1200.00 2200.00 700.00 -Dell 800.00 700.00 1200.00 1500.00 800.00 -iPad 700.00 700.00 700.00 1050.00 700.00 -Kindle Fire 150.00 150.00 700.00 1050.00 150.00 -Samsung 200.00 150.00 700.00 350.00 200.00 +Microsoft Lumia 200.00 200.00 400.00 2000.00 200.00000000000000000 +HTC One 400.00 200.00 500.00 2000.00 400.00000000000000000 +Nexus 500.00 200.00 900.00 1800.00 500.00000000000000000 +iPhone 900.00 200.00 900.00 1400.00 900.00000000000000000 +HP Elite 1200.00 1200.00 1200.00 3400.00 1200.0000000000000000 +Lenovo Thinkpad 700.00 700.00 1200.00 3400.00 700.00000000000000000 +Sony VAIO 700.00 700.00 1200.00 2200.00 700.00000000000000000 +Dell 800.00 700.00 1200.00 1500.00 800.00000000000000000 +iPad 700.00 700.00 700.00 1050.00 700.00000000000000000 +Kindle Fire 150.00 150.00 700.00 1050.00 150.00000000000000000 +Samsung 200.00 150.00 700.00 350.00 200.00000000000000000 query RRR SELECT avg(price) OVER w1, avg(price) OVER w2, avg(price) OVER w1 FROM products WINDOW w1 AS (PARTITION BY group_name ORDER BY group_id ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING), w2 AS (ORDER BY group_id ROWS 1 PRECEDING) ORDER BY group_id ---- -300.00 200.00 300.00 -366.66666666666666667 300.00 366.66666666666666667 -600.00 450.00 600.00 -700.00 700.00 700.00 -950.00 1050.00 950.00 -866.66666666666666667 950.00 866.66666666666666667 -733.33333333333333333 700.00 733.33333333333333333 -750.00 750.00 750.00 -425.00 750.00 425.00 -350.00 425.00 350.00 -175.00 175.00 175.00 +300.00000000000000000 200.00000000000000000 300.00000000000000000 +366.66666666666666667 300.00000000000000000 366.66666666666666667 +600.00000000000000000 450.00000000000000000 600.00000000000000000 +700.00000000000000000 700.00000000000000000 700.00000000000000000 +950.00000000000000000 1050.0000000000000000 950.00000000000000000 +866.66666666666666667 950.00000000000000000 866.66666666666666667 +733.33333333333333333 700.00000000000000000 733.33333333333333333 +750.00000000000000000 750.00000000000000000 750.00000000000000000 +425.00000000000000000 750.00000000000000000 425.00000000000000000 +350.00000000000000000 425.00000000000000000 350.00000000000000000 +175.00000000000000000 175.00000000000000000 175.00000000000000000 # In the following 4 tests, since ORDER BY is omitted, all rows are peers, so frame includes all the rows for every row. query TTRR @@ -2426,17 +2426,17 @@ SELECT count(*) FILTER (WHERE true) OVER (), count(*) FILTER (WHERE false) OVER query RRRR SELECT avg(price) FILTER (WHERE price > 300) OVER w1, sum(price) FILTER (WHERE group_name = 'Smartphone') OVER w2, avg(price) FILTER (WHERE price = 200 OR price = 700) OVER w1, avg(price) FILTER (WHERE price < 900) OVER w2 FROM products WINDOW w1 AS (ORDER BY group_id), w2 AS (PARTITION BY group_name ORDER BY price, group_id) ORDER BY group_id ---- -NULL 200.00 200.00 200.00 -400.00 600.00 200.00 300.00 -450.00 1100.00 200.00 366.66666666666666667 -600.00 2000.00 200.00 366.66666666666666667 -750.00 NULL 200.00 733.33333333333333333 -740.00 NULL 450.00 700.00 -733.33333333333333333 NULL 533.33333333333333333 700.00 +NULL 200.00 200.00000000000000000 200.00000000000000000 +400.00000000000000000 600.00 200.00000000000000000 300.00000000000000000 +450.00000000000000000 1100.00 200.00000000000000000 366.66666666666666667 +600.00000000000000000 2000.00 200.00000000000000000 366.66666666666666667 +750.00000000000000000 NULL 200.00000000000000000 733.33333333333333333 +740.00000000000000000 NULL 450.00000000000000000 700.00000000000000000 +733.33333333333333333 NULL 533.33333333333333333 700.00000000000000000 742.85714285714285714 NULL 533.33333333333333333 733.33333333333333333 -737.50 NULL 575.00 350.00 -737.50 NULL 575.00 150.00 -737.50 NULL 500.00 175.00 +737.50000000000000000 NULL 575.00000000000000000 350.00000000000000000 +737.50000000000000000 NULL 575.00000000000000000 150.00000000000000000 +737.50000000000000000 NULL 500.00000000000000000 175.00000000000000000 statement error DISTINCT is not implemented for window functions SELECT count(DISTINCT group_name) OVER (), count(DISTINCT product_name) OVER () FROM products @@ -2621,11 +2621,11 @@ Tablet Kindle Fire 2018-07-31 00:00:00 +0000 +0000 150.00 6450.00 query TTRR SELECT product_name, ptime, price, avg(price) OVER (ORDER BY ptime RANGE BETWEEN '1 hours 15 minutes' PRECEDING AND '1 hours 15 minutes' FOLLOWING) FROM products ORDER BY ptime, group_id ---- -Microsoft Lumia 0000-01-01 01:23:45 +0000 UTC 200.00 700.00 -HP Elite 0000-01-01 01:23:45 +0000 UTC 1200.00 700.00 -iPad 0000-01-01 01:23:45 +0000 UTC 700.00 700.00 -iPhone 0000-01-01 07:34:56 +0000 UTC 900.00 850.00 -Dell 0000-01-01 07:34:56 +0000 UTC 800.00 850.00 +Microsoft Lumia 0000-01-01 01:23:45 +0000 UTC 200.00 700.00000000000000000 +HP Elite 0000-01-01 01:23:45 +0000 UTC 1200.00 700.00000000000000000 +iPad 0000-01-01 01:23:45 +0000 UTC 700.00 700.00000000000000000 +iPhone 0000-01-01 07:34:56 +0000 UTC 900.00 850.00000000000000000 +Dell 0000-01-01 07:34:56 +0000 UTC 800.00 850.00000000000000000 Nexus 0000-01-01 11:23:45 +0000 UTC 500.00 441.66666666666666667 Sony VAIO 0000-01-01 11:23:45 +0000 UTC 700.00 441.66666666666666667 Samsung 0000-01-01 11:23:45 +0000 UTC 200.00 441.66666666666666667 @@ -2666,17 +2666,17 @@ Tablet Kindle Fire 2018-07-31 12:34:56 +0000 +0000 150.00 150.00 query TTTRR SELECT group_name, product_name, ptimestamptz, price, avg(price) OVER (PARTITION BY group_name ORDER BY ptimestamptz RANGE BETWEEN '1 days 12 hours' PRECEDING AND CURRENT ROW) FROM products ORDER BY group_name, ptimestamptz ---- -Laptop HP Elite 2018-07-30 01:23:45 +0000 UTC 1200.00 1200.00 -Laptop Sony VAIO 2018-07-30 11:23:45 +0000 UTC 700.00 950.00 -Laptop Dell 2018-07-31 07:34:56 +0000 UTC 800.00 900.00 -Laptop Lenovo Thinkpad 2018-07-31 12:34:56 +0000 UTC 700.00 850.00 -Smartphone Microsoft Lumia 2018-07-30 01:23:45 +0000 UTC 200.00 200.00 -Smartphone Nexus 2018-07-30 11:23:45 +0000 UTC 500.00 350.00 +Laptop HP Elite 2018-07-30 01:23:45 +0000 UTC 1200.00 1200.0000000000000000 +Laptop Sony VAIO 2018-07-30 11:23:45 +0000 UTC 700.00 950.00000000000000000 +Laptop Dell 2018-07-31 07:34:56 +0000 UTC 800.00 900.00000000000000000 +Laptop Lenovo Thinkpad 2018-07-31 12:34:56 +0000 UTC 700.00 850.00000000000000000 +Smartphone Microsoft Lumia 2018-07-30 01:23:45 +0000 UTC 200.00 200.00000000000000000 +Smartphone Nexus 2018-07-30 11:23:45 +0000 UTC 500.00 350.00000000000000000 Smartphone iPhone 2018-07-31 07:34:56 +0000 UTC 900.00 533.33333333333333333 -Smartphone HTC One 2018-07-31 12:34:56 +0000 UTC 400.00 500.00 -Tablet iPad 2018-07-30 01:23:45 +0000 UTC 700.00 700.00 -Tablet Samsung 2018-07-30 11:23:45 +0000 UTC 200.00 450.00 -Tablet Kindle Fire 2018-07-31 12:34:56 +0000 UTC 150.00 350.00 +Smartphone HTC One 2018-07-31 12:34:56 +0000 UTC 400.00 500.00000000000000000 +Tablet iPad 2018-07-30 01:23:45 +0000 UTC 700.00 700.00000000000000000 +Tablet Samsung 2018-07-30 11:23:45 +0000 UTC 200.00 450.00000000000000000 +Tablet Kindle Fire 2018-07-31 12:34:56 +0000 UTC 150.00 350.00000000000000000 query TTRR SELECT product_name, pinterval, price, avg(price) OVER (ORDER BY pinterval RANGE BETWEEN '2 hours 34 minutes 56 seconds' PRECEDING AND '3 months' FOLLOWING) FROM products ORDER BY pinterval, group_id @@ -2689,9 +2689,9 @@ Samsung 01:02:03 200.00 586.36363636363636364 HTC One 1 day 02:03:04 400.00 558.33333333333333333 Lenovo Thinkpad 1 day 02:03:04 700.00 558.33333333333333333 Kindle Fire 1 day 02:03:04 150.00 558.33333333333333333 -Microsoft Lumia 1 mon 2 days 03:04:05 200.00 700.00 -HP Elite 1 mon 2 days 03:04:05 1200.00 700.00 -iPad 1 mon 2 days 03:04:05 700.00 700.00 +Microsoft Lumia 1 mon 2 days 03:04:05 200.00 700.00000000000000000 +HP Elite 1 mon 2 days 03:04:05 1200.00 700.00000000000000000 +iPad 1 mon 2 days 03:04:05 700.00 700.00000000000000000 query TTRR SELECT group_name, product_name, price, sum(priceint) OVER (PARTITION BY group_name ORDER BY priceint DESC RANGE 200 PRECEDING) FROM products ORDER BY group_name, priceint DESC, group_id @@ -2852,11 +2852,11 @@ Kindle Fire 0000-01-01 12:34:56 +0000 UTC 150.00 441.66666666666666667 Nexus 0000-01-01 11:23:45 +0000 UTC 500.00 441.66666666666666667 Sony VAIO 0000-01-01 11:23:45 +0000 UTC 700.00 441.66666666666666667 Samsung 0000-01-01 11:23:45 +0000 UTC 200.00 441.66666666666666667 -iPhone 0000-01-01 07:34:56 +0000 UTC 900.00 850.00 -Dell 0000-01-01 07:34:56 +0000 UTC 800.00 850.00 -Microsoft Lumia 0000-01-01 01:23:45 +0000 UTC 200.00 700.00 -HP Elite 0000-01-01 01:23:45 +0000 UTC 1200.00 700.00 -iPad 0000-01-01 01:23:45 +0000 UTC 700.00 700.00 +iPhone 0000-01-01 07:34:56 +0000 UTC 900.00 850.00000000000000000 +Dell 0000-01-01 07:34:56 +0000 UTC 800.00 850.00000000000000000 +Microsoft Lumia 0000-01-01 01:23:45 +0000 UTC 200.00 700.00000000000000000 +HP Elite 0000-01-01 01:23:45 +0000 UTC 1200.00 700.00000000000000000 +iPad 0000-01-01 01:23:45 +0000 UTC 700.00 700.00000000000000000 query TTTRR SELECT group_name, product_name, ptime, price, min(price) OVER (PARTITION BY group_name ORDER BY ptime DESC RANGE BETWEEN '1 hours' FOLLOWING AND UNBOUNDED FOLLOWING) FROM products ORDER BY group_name, ptime DESC @@ -2891,17 +2891,17 @@ Tablet iPad 2018-07-30 01:23:45 +0000 +0000 700.00 200.00 query TTTRR SELECT group_name, product_name, ptimestamptz, price, avg(price) OVER (PARTITION BY group_name ORDER BY ptimestamptz DESC RANGE BETWEEN '1 days 12 hours' PRECEDING AND CURRENT ROW) FROM products ORDER BY group_name, ptimestamptz DESC ---- -Laptop Lenovo Thinkpad 2018-07-31 12:34:56 +0000 UTC 700.00 700.00 -Laptop Dell 2018-07-31 07:34:56 +0000 UTC 800.00 750.00 +Laptop Lenovo Thinkpad 2018-07-31 12:34:56 +0000 UTC 700.00 700.00000000000000000 +Laptop Dell 2018-07-31 07:34:56 +0000 UTC 800.00 750.00000000000000000 Laptop Sony VAIO 2018-07-30 11:23:45 +0000 UTC 700.00 733.33333333333333333 -Laptop HP Elite 2018-07-30 01:23:45 +0000 UTC 1200.00 850.00 -Smartphone HTC One 2018-07-31 12:34:56 +0000 UTC 400.00 400.00 -Smartphone iPhone 2018-07-31 07:34:56 +0000 UTC 900.00 650.00 -Smartphone Nexus 2018-07-30 11:23:45 +0000 UTC 500.00 600.00 -Smartphone Microsoft Lumia 2018-07-30 01:23:45 +0000 UTC 200.00 500.00 -Tablet Kindle Fire 2018-07-31 12:34:56 +0000 UTC 150.00 150.00 -Tablet Samsung 2018-07-30 11:23:45 +0000 UTC 200.00 175.00 -Tablet iPad 2018-07-30 01:23:45 +0000 UTC 700.00 350.00 +Laptop HP Elite 2018-07-30 01:23:45 +0000 UTC 1200.00 850.00000000000000000 +Smartphone HTC One 2018-07-31 12:34:56 +0000 UTC 400.00 400.00000000000000000 +Smartphone iPhone 2018-07-31 07:34:56 +0000 UTC 900.00 650.00000000000000000 +Smartphone Nexus 2018-07-30 11:23:45 +0000 UTC 500.00 600.00000000000000000 +Smartphone Microsoft Lumia 2018-07-30 01:23:45 +0000 UTC 200.00 500.00000000000000000 +Tablet Kindle Fire 2018-07-31 12:34:56 +0000 UTC 150.00 150.00000000000000000 +Tablet Samsung 2018-07-30 11:23:45 +0000 UTC 200.00 175.00000000000000000 +Tablet iPad 2018-07-30 01:23:45 +0000 UTC 700.00 350.00000000000000000 query TTRR SELECT product_name, pinterval, price, avg(price) OVER (ORDER BY pinterval DESC RANGE BETWEEN '2 hours 34 minutes 56 seconds' PRECEDING AND '3 months' FOLLOWING) FROM products ORDER BY pinterval DESC, group_id @@ -2909,14 +2909,14 @@ SELECT product_name, pinterval, price, avg(price) OVER (ORDER BY pinterval DESC Microsoft Lumia 1 mon 2 days 03:04:05 200.00 586.36363636363636364 HP Elite 1 mon 2 days 03:04:05 1200.00 586.36363636363636364 iPad 1 mon 2 days 03:04:05 700.00 586.36363636363636364 -HTC One 1 day 02:03:04 400.00 543.75 -Lenovo Thinkpad 1 day 02:03:04 700.00 543.75 -Kindle Fire 1 day 02:03:04 150.00 543.75 -Nexus 01:02:03 500.00 620.00 -Sony VAIO 01:02:03 700.00 620.00 -Samsung 01:02:03 200.00 620.00 -iPhone 00:01:02 900.00 620.00 -Dell 00:01:02 800.00 620.00 +HTC One 1 day 02:03:04 400.00 543.75000000000000000 +Lenovo Thinkpad 1 day 02:03:04 700.00 543.75000000000000000 +Kindle Fire 1 day 02:03:04 150.00 543.75000000000000000 +Nexus 01:02:03 500.00 620.00000000000000000 +Sony VAIO 01:02:03 700.00 620.00000000000000000 +Samsung 01:02:03 200.00 620.00000000000000000 +iPhone 00:01:02 900.00 620.00000000000000000 +Dell 00:01:02 800.00 620.00000000000000000 query TRTT SELECT group_name, price, product_name, array_agg(product_name) OVER (PARTITION BY group_name ORDER BY price, group_id) FROM products ORDER BY group_id @@ -3014,92 +3014,92 @@ SELECT price, sum(price) OVER (ORDER BY price GROUPS UNBOUNDED PRECEDING), sum(p query RIRRRRRR SELECT price, dense_rank() OVER w, avg(price) OVER (w GROUPS BETWEEN UNBOUNDED PRECEDING AND 100 PRECEDING), avg(price) OVER (w GROUPS BETWEEN UNBOUNDED PRECEDING AND 2 PRECEDING), avg(price) OVER (w GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), avg(price) OVER (w GROUPS BETWEEN UNBOUNDED PRECEDING AND 2 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN UNBOUNDED PRECEDING AND 100 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM products WINDOW w AS (ORDER BY price) ORDER BY price ---- -150.00 1 NULL NULL 150.00 237.50 586.36363636363636364 586.36363636363636364 -200.00 2 NULL NULL 183.33333333333333333 290.00 586.36363636363636364 586.36363636363636364 -200.00 2 NULL NULL 183.33333333333333333 290.00 586.36363636363636364 586.36363636363636364 -400.00 3 NULL 150.00 237.50 443.75 586.36363636363636364 586.36363636363636364 -500.00 4 NULL 183.33333333333333333 290.00 483.33333333333333333 586.36363636363636364 586.36363636363636364 -700.00 5 NULL 237.50 443.75 525.00 586.36363636363636364 586.36363636363636364 -700.00 5 NULL 237.50 443.75 525.00 586.36363636363636364 586.36363636363636364 -700.00 5 NULL 237.50 443.75 525.00 586.36363636363636364 586.36363636363636364 -800.00 6 NULL 290.00 483.33333333333333333 586.36363636363636364 586.36363636363636364 586.36363636363636364 -900.00 7 NULL 443.75 525.00 586.36363636363636364 586.36363636363636364 586.36363636363636364 +150.00 1 NULL NULL 150.00000000000000000 237.50000000000000000 586.36363636363636364 586.36363636363636364 +200.00 2 NULL NULL 183.33333333333333333 290.00000000000000000 586.36363636363636364 586.36363636363636364 +200.00 2 NULL NULL 183.33333333333333333 290.00000000000000000 586.36363636363636364 586.36363636363636364 +400.00 3 NULL 150.00000000000000000 237.50000000000000000 443.75000000000000000 586.36363636363636364 586.36363636363636364 +500.00 4 NULL 183.33333333333333333 290.00000000000000000 483.33333333333333333 586.36363636363636364 586.36363636363636364 +700.00 5 NULL 237.50000000000000000 443.75000000000000000 525.00000000000000000 586.36363636363636364 586.36363636363636364 +700.00 5 NULL 237.50000000000000000 443.75000000000000000 525.00000000000000000 586.36363636363636364 586.36363636363636364 +700.00 5 NULL 237.50000000000000000 443.75000000000000000 525.00000000000000000 586.36363636363636364 586.36363636363636364 +800.00 6 NULL 290.00000000000000000 483.33333333333333333 586.36363636363636364 586.36363636363636364 586.36363636363636364 +900.00 7 NULL 443.75000000000000000 525.00000000000000000 586.36363636363636364 586.36363636363636364 586.36363636363636364 1200.00 8 NULL 483.33333333333333333 586.36363636363636364 586.36363636363636364 586.36363636363636364 586.36363636363636364 query RIRRRRRR SELECT price, dense_rank() OVER w, avg(price) OVER (w GROUPS BETWEEN 4 PRECEDING AND 100 PRECEDING), avg(price) OVER (w GROUPS BETWEEN 3 PRECEDING AND 2 PRECEDING), avg(price) OVER (w GROUPS BETWEEN 2 PRECEDING AND CURRENT ROW), avg(price) OVER (w GROUPS BETWEEN 1 PRECEDING AND 2 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 1 PRECEDING AND 100 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 1 PRECEDING AND UNBOUNDED FOLLOWING) FROM products WINDOW w AS (ORDER BY price) ORDER BY price ---- -150.00 1 NULL NULL 150.00 237.50 586.36363636363636364 586.36363636363636364 -200.00 2 NULL NULL 183.33333333333333333 290.00 586.36363636363636364 586.36363636363636364 -200.00 2 NULL NULL 183.33333333333333333 290.00 586.36363636363636364 586.36363636363636364 -400.00 3 NULL 150.00 237.50 485.71428571428571429 630.00 630.00 -500.00 4 NULL 183.33333333333333333 325.00 633.33333333333333333 737.50 737.50 -700.00 5 NULL 266.66666666666666667 600.00 716.66666666666666667 785.71428571428571429 785.71428571428571429 -700.00 5 NULL 266.66666666666666667 600.00 716.66666666666666667 785.71428571428571429 785.71428571428571429 -700.00 5 NULL 266.66666666666666667 600.00 716.66666666666666667 785.71428571428571429 785.71428571428571429 -800.00 6 NULL 450.00 680.00 833.33333333333333333 833.33333333333333333 833.33333333333333333 -900.00 7 NULL 650.00 760.00 966.66666666666666667 966.66666666666666667 966.66666666666666667 -1200.00 8 NULL 725.00 966.66666666666666667 1050.00 1050.00 1050.00 +150.00 1 NULL NULL 150.00000000000000000 237.50000000000000000 586.36363636363636364 586.36363636363636364 +200.00 2 NULL NULL 183.33333333333333333 290.00000000000000000 586.36363636363636364 586.36363636363636364 +200.00 2 NULL NULL 183.33333333333333333 290.00000000000000000 586.36363636363636364 586.36363636363636364 +400.00 3 NULL 150.00000000000000000 237.50000000000000000 485.71428571428571429 630.00000000000000000 630.00000000000000000 +500.00 4 NULL 183.33333333333333333 325.00000000000000000 633.33333333333333333 737.50000000000000000 737.50000000000000000 +700.00 5 NULL 266.66666666666666667 600.00000000000000000 716.66666666666666667 785.71428571428571429 785.71428571428571429 +700.00 5 NULL 266.66666666666666667 600.00000000000000000 716.66666666666666667 785.71428571428571429 785.71428571428571429 +700.00 5 NULL 266.66666666666666667 600.00000000000000000 716.66666666666666667 785.71428571428571429 785.71428571428571429 +800.00 6 NULL 450.00000000000000000 680.00000000000000000 833.33333333333333333 833.33333333333333333 833.33333333333333333 +900.00 7 NULL 650.00000000000000000 760.00000000000000000 966.66666666666666667 966.66666666666666667 966.66666666666666667 +1200.00 8 NULL 725.00000000000000000 966.66666666666666667 1050.0000000000000000 1050.0000000000000000 1050.0000000000000000 query RIRRRRRRR SELECT price, dense_rank() OVER w, avg(price) OVER (w GROUPS BETWEEN 0 PRECEDING AND 0 PRECEDING), avg(price) OVER (w GROUPS BETWEEN 0 PRECEDING AND CURRENT ROW), avg(price) OVER (w GROUPS BETWEEN 0 PRECEDING AND 0 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN CURRENT ROW AND CURRENT ROW), avg(price) OVER (w GROUPS BETWEEN CURRENT ROW AND 2 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN CURRENT ROW AND 100 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) FROM products WINDOW w AS (ORDER BY price) ORDER BY price ---- -150.00 1 150.00 150.00 150.00 150.00 237.50 586.36363636363636364 586.36363636363636364 -200.00 2 200.00 200.00 200.00 200.00 325.00 630.00 630.00 -200.00 2 200.00 200.00 200.00 200.00 325.00 630.00 630.00 -400.00 3 400.00 400.00 400.00 400.00 600.00 737.50 737.50 -500.00 4 500.00 500.00 500.00 500.00 680.00 785.71428571428571429 785.71428571428571429 -700.00 5 700.00 700.00 700.00 700.00 760.00 833.33333333333333333 833.33333333333333333 -700.00 5 700.00 700.00 700.00 700.00 760.00 833.33333333333333333 833.33333333333333333 -700.00 5 700.00 700.00 700.00 700.00 760.00 833.33333333333333333 833.33333333333333333 -800.00 6 800.00 800.00 800.00 800.00 966.66666666666666667 966.66666666666666667 966.66666666666666667 -900.00 7 900.00 900.00 900.00 900.00 1050.00 1050.00 1050.00 -1200.00 8 1200.00 1200.00 1200.00 1200.00 1200.00 1200.00 1200.00 +150.00 1 150.00000000000000000 150.00000000000000000 150.00000000000000000 150.00000000000000000 237.50000000000000000 586.36363636363636364 586.36363636363636364 +200.00 2 200.00000000000000000 200.00000000000000000 200.00000000000000000 200.00000000000000000 325.00000000000000000 630.00000000000000000 630.00000000000000000 +200.00 2 200.00000000000000000 200.00000000000000000 200.00000000000000000 200.00000000000000000 325.00000000000000000 630.00000000000000000 630.00000000000000000 +400.00 3 400.00000000000000000 400.00000000000000000 400.00000000000000000 400.00000000000000000 600.00000000000000000 737.50000000000000000 737.50000000000000000 +500.00 4 500.00000000000000000 500.00000000000000000 500.00000000000000000 500.00000000000000000 680.00000000000000000 785.71428571428571429 785.71428571428571429 +700.00 5 700.00000000000000000 700.00000000000000000 700.00000000000000000 700.00000000000000000 760.00000000000000000 833.33333333333333333 833.33333333333333333 +700.00 5 700.00000000000000000 700.00000000000000000 700.00000000000000000 700.00000000000000000 760.00000000000000000 833.33333333333333333 833.33333333333333333 +700.00 5 700.00000000000000000 700.00000000000000000 700.00000000000000000 700.00000000000000000 760.00000000000000000 833.33333333333333333 833.33333333333333333 +800.00 6 800.00000000000000000 800.00000000000000000 800.00000000000000000 800.00000000000000000 966.66666666666666667 966.66666666666666667 966.66666666666666667 +900.00 7 900.00000000000000000 900.00000000000000000 900.00000000000000000 900.00000000000000000 1050.0000000000000000 1050.0000000000000000 1050.0000000000000000 +1200.00 8 1200.0000000000000000 1200.0000000000000000 1200.0000000000000000 1200.0000000000000000 1200.0000000000000000 1200.0000000000000000 1200.0000000000000000 query RIRRRRRR SELECT price, dense_rank() OVER w, avg(price) OVER (w GROUPS BETWEEN 3 FOLLOWING AND 100 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 3 FOLLOWING AND 1 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 2 FOLLOWING AND 6 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 3 FOLLOWING AND 3 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 0 FOLLOWING AND 4 FOLLOWING), avg(price) OVER (w GROUPS BETWEEN 5 FOLLOWING AND UNBOUNDED FOLLOWING) FROM products WINDOW w AS (ORDER BY price) ORDER BY price ---- -150.00 1 785.71428571428571429 NULL 671.42857142857142857 500.00 443.75 966.66666666666666667 -200.00 2 833.33333333333333333 NULL 785.71428571428571429 700.00 525.00 1050.00 -200.00 2 833.33333333333333333 NULL 785.71428571428571429 700.00 525.00 1050.00 -400.00 3 966.66666666666666667 NULL 833.33333333333333333 800.00 671.42857142857142857 1200.00 -500.00 4 1050.00 NULL 966.66666666666666667 900.00 785.71428571428571429 NULL -700.00 5 1200.00 NULL 1050.00 1200.00 833.33333333333333333 NULL -700.00 5 1200.00 NULL 1050.00 1200.00 833.33333333333333333 NULL -700.00 5 1200.00 NULL 1050.00 1200.00 833.33333333333333333 NULL -800.00 6 NULL NULL 1200.00 NULL 966.66666666666666667 NULL -900.00 7 NULL NULL NULL NULL 1050.00 NULL -1200.00 8 NULL NULL NULL NULL 1200.00 NULL +150.00 1 785.71428571428571429 NULL 671.42857142857142857 500.00000000000000000 443.75000000000000000 966.66666666666666667 +200.00 2 833.33333333333333333 NULL 785.71428571428571429 700.00000000000000000 525.00000000000000000 1050.0000000000000000 +200.00 2 833.33333333333333333 NULL 785.71428571428571429 700.00000000000000000 525.00000000000000000 1050.0000000000000000 +400.00 3 966.66666666666666667 NULL 833.33333333333333333 800.00000000000000000 671.42857142857142857 1200.0000000000000000 +500.00 4 1050.0000000000000000 NULL 966.66666666666666667 900.00000000000000000 785.71428571428571429 NULL +700.00 5 1200.0000000000000000 NULL 1050.0000000000000000 1200.0000000000000000 833.33333333333333333 NULL +700.00 5 1200.0000000000000000 NULL 1050.0000000000000000 1200.0000000000000000 833.33333333333333333 NULL +700.00 5 1200.0000000000000000 NULL 1050.0000000000000000 1200.0000000000000000 833.33333333333333333 NULL +800.00 6 NULL NULL 1200.0000000000000000 NULL 966.66666666666666667 NULL +900.00 7 NULL NULL NULL NULL 1050.0000000000000000 NULL +1200.00 8 NULL NULL NULL NULL 1200.0000000000000000 NULL query TTRRR SELECT group_name, product_name, price, avg(price) OVER (PARTITION BY group_name ORDER BY price GROUPS BETWEEN CURRENT ROW AND 3 FOLLOWING), avg(price) OVER (ORDER BY price GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM products ORDER BY group_id ---- -Smartphone Microsoft Lumia 200.00 500.00 586.36363636363636364 -Smartphone HTC One 400.00 600.00 586.36363636363636364 -Smartphone Nexus 500.00 700.00 586.36363636363636364 -Smartphone iPhone 900.00 900.00 586.36363636363636364 -Laptop HP Elite 1200.00 1200.00 586.36363636363636364 -Laptop Lenovo Thinkpad 700.00 850.00 586.36363636363636364 -Laptop Sony VAIO 700.00 850.00 586.36363636363636364 -Laptop Dell 800.00 1000.00 586.36363636363636364 -Tablet iPad 700.00 700.00 586.36363636363636364 -Tablet Kindle Fire 150.00 350.00 586.36363636363636364 -Tablet Samsung 200.00 450.00 586.36363636363636364 +Smartphone Microsoft Lumia 200.00 500.00000000000000000 586.36363636363636364 +Smartphone HTC One 400.00 600.00000000000000000 586.36363636363636364 +Smartphone Nexus 500.00 700.00000000000000000 586.36363636363636364 +Smartphone iPhone 900.00 900.00000000000000000 586.36363636363636364 +Laptop HP Elite 1200.00 1200.0000000000000000 586.36363636363636364 +Laptop Lenovo Thinkpad 700.00 850.00000000000000000 586.36363636363636364 +Laptop Sony VAIO 700.00 850.00000000000000000 586.36363636363636364 +Laptop Dell 800.00 1000.0000000000000000 586.36363636363636364 +Tablet iPad 700.00 700.00000000000000000 586.36363636363636364 +Tablet Kindle Fire 150.00 350.00000000000000000 586.36363636363636364 +Tablet Samsung 200.00 450.00000000000000000 586.36363636363636364 query TTRRR SELECT group_name, product_name, price, avg(price) OVER (ORDER BY group_id GROUPS BETWEEN 1 PRECEDING AND 2 PRECEDING), avg(price) OVER (ORDER BY price GROUPS BETWEEN CURRENT ROW AND CURRENT ROW) FROM products ORDER BY group_id ---- -Smartphone Microsoft Lumia 200.00 NULL 200.00 -Smartphone HTC One 400.00 NULL 400.00 -Smartphone Nexus 500.00 NULL 500.00 -Smartphone iPhone 900.00 NULL 900.00 -Laptop HP Elite 1200.00 NULL 1200.00 -Laptop Lenovo Thinkpad 700.00 NULL 700.00 -Laptop Sony VAIO 700.00 NULL 700.00 -Laptop Dell 800.00 NULL 800.00 -Tablet iPad 700.00 NULL 700.00 -Tablet Kindle Fire 150.00 NULL 150.00 -Tablet Samsung 200.00 NULL 200.00 +Smartphone Microsoft Lumia 200.00 NULL 200.00000000000000000 +Smartphone HTC One 400.00 NULL 400.00000000000000000 +Smartphone Nexus 500.00 NULL 500.00000000000000000 +Smartphone iPhone 900.00 NULL 900.00000000000000000 +Laptop HP Elite 1200.00 NULL 1200.0000000000000000 +Laptop Lenovo Thinkpad 700.00 NULL 700.00000000000000000 +Laptop Sony VAIO 700.00 NULL 700.00000000000000000 +Laptop Dell 800.00 NULL 800.00000000000000000 +Tablet iPad 700.00 NULL 700.00000000000000000 +Tablet Kindle Fire 150.00 NULL 150.00000000000000000 +Tablet Samsung 200.00 NULL 200.00000000000000000 query RTR SELECT @@ -3170,16 +3170,16 @@ WINDOW ORDER BY price ---- -150.00 {150.00} 150.00 -200.00 {150.00,200.00} 175.00 -200.00 {150.00,200.00} 175.00 -400.00 {150.00,200.00,200.00,400.00} 237.50 -500.00 {150.00,200.00,200.00,400.00,500.00} 290.00 +150.00 {150.00} 150.00000000000000000 +200.00 {150.00,200.00} 175.00000000000000000 +200.00 {150.00,200.00} 175.00000000000000000 +400.00 {150.00,200.00,200.00,400.00} 237.50000000000000000 +500.00 {150.00,200.00,200.00,400.00,500.00} 290.00000000000000000 700.00 {150.00,200.00,200.00,400.00,500.00,700.00} 358.33333333333333333 700.00 {150.00,200.00,200.00,400.00,500.00,700.00} 358.33333333333333333 700.00 {150.00,200.00,200.00,400.00,500.00,700.00} 358.33333333333333333 800.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00} 483.33333333333333333 -900.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00,900.00} 525.00 +900.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00,900.00} 525.00000000000000000 1200.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00,900.00,1200.00} 586.36363636363636364 query RTR @@ -3197,16 +3197,16 @@ WINDOW ORDER BY price ---- -150.00 {150.00} 150.00 +150.00 {150.00} 150.00000000000000000 200.00 {150.00,200.00,200.00} 183.33333333333333333 200.00 {150.00,200.00,200.00} 183.33333333333333333 -400.00 {150.00,200.00,200.00,400.00} 237.50 -500.00 {150.00,200.00,200.00,400.00,500.00} 290.00 -700.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00} 443.75 -700.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00} 443.75 -700.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00} 443.75 +400.00 {150.00,200.00,200.00,400.00} 237.50000000000000000 +500.00 {150.00,200.00,200.00,400.00,500.00} 290.00000000000000000 +700.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00} 443.75000000000000000 +700.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00} 443.75000000000000000 +700.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00} 443.75000000000000000 800.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00} 483.33333333333333333 -900.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00,900.00} 525.00 +900.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00,900.00} 525.00000000000000000 1200.00 {150.00,200.00,200.00,400.00,500.00,700.00,700.00,700.00,800.00,900.00,1200.00} 586.36363636363636364 query TTTT @@ -3421,12 +3421,12 @@ SELECT avg(c) OVER (ORDER BY c) FROM abc ---- -3.5 1 3.5 2 10 10 10 10 25 20 25 20 -3.5 1.5 3.5 2 10 10 10 10 25 20 25 20 -3.5 2 3.5 2 10 10 10 10 25 20 25 20 -3.5 2.5 3.5 3.5 10 10 10 10 25 22.5 25 25 -3.5 3 3.5 3.5 10 10 10 10 25 24 25 25 -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 +3.5000000000000000000 1.0000000000000000000 3.5000000000000000000 2.0000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 20.000000000000000000 25.000000000000000000 20.000000000000000000 +3.5000000000000000000 1.5000000000000000000 3.5000000000000000000 2.0000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 20.000000000000000000 25.000000000000000000 20.000000000000000000 +3.5000000000000000000 2.0000000000000000000 3.5000000000000000000 2.0000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 20.000000000000000000 25.000000000000000000 20.000000000000000000 +3.5000000000000000000 2.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 22.500000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.0000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 24.000000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 query TTTTTTTTTTTT rowsort SELECT @@ -3444,12 +3444,12 @@ SELECT avg(c) OVER (ORDER BY c RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM abc ---- -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 -3.5 3.5 3.5 3.5 10 10 10 10 25 25 25 25 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 +3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 3.5000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 10.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 25.000000000000000000 query T SELECT array_agg(a) OVER (w RANGE 1 PRECEDING) FROM x WINDOW w AS (ORDER BY a DESC) ORDER BY a @@ -3495,16 +3495,16 @@ SELECT a, b, sum(b) OVER (ROWS 0 PRECEDING) FROM t ORDER BY a query IIR SELECT a, b, avg(b) OVER () FROM t ORDER BY a ---- -1 1 2 -2 NULL 2 -3 3 2 +1 1 2.0000000000000000000 +2 NULL 2.0000000000000000000 +3 3 2.0000000000000000000 query IIR SELECT a, b, avg(b) OVER (ROWS 0 PRECEDING) FROM t ORDER BY a ---- -1 1 1 +1 1 1.0000000000000000000 2 NULL NULL -3 3 3 +3 3 3.0000000000000000000 statement ok CREATE TABLE wxyz (w INT PRIMARY KEY, x INT, y INT, z INT) @@ -3534,8 +3534,8 @@ SELECT *, dense_rank() OVER (PARTITION BY z ORDER BY y) FROM wxyz ORDER BY y LIM query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY z ORDER BY y) FROM wxyz ORDER BY y LIMIT 2 ---- -3 10 1 1 2 -1 10 1 1 2 +1 10 1 1 2.0000000000000000000 +3 10 1 1 2.0000000000000000000 query IIIII rowsort SELECT *, rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY y LIMIT 2 @@ -3552,8 +3552,8 @@ SELECT *, dense_rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY y LIM query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY y LIMIT 2 ---- -3 10 1 1 3 -1 10 1 1 1 +1 10 1 1 1.0000000000000000000 +3 10 1 1 3.0000000000000000000 query IIIII rowsort SELECT *, rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY w, y LIMIT 2 @@ -3570,8 +3570,8 @@ SELECT *, dense_rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY w, y query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY w, y LIMIT 2 ---- -1 10 1 1 1 -2 10 2 0 2 +1 10 1 1 1.0000000000000000000 +2 10 2 0 2.0000000000000000000 query IIIII rowsort SELECT *, rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY w LIMIT 2 @@ -3588,8 +3588,8 @@ SELECT *, dense_rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY w LIM query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY w LIMIT 2 ---- -1 10 1 1 1 -2 10 2 0 2 +1 10 1 1 1.0000000000000000000 +2 10 2 0 2.0000000000000000000 query IIIII rowsort SELECT *, rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY y, w LIMIT 2 @@ -3606,8 +3606,8 @@ SELECT *, dense_rank() OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY y, w query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY w ORDER BY y) FROM wxyz ORDER BY y, w LIMIT 2 ---- -1 10 1 1 1 -3 10 1 1 3 +1 10 1 1 1.0000000000000000000 +3 10 1 1 3.0000000000000000000 query IIIII rowsort SELECT *, rank() OVER (PARTITION BY w, z ORDER BY y) FROM wxyz ORDER BY w, z, y LIMIT 2 @@ -3624,8 +3624,8 @@ SELECT *, dense_rank() OVER (PARTITION BY w, z ORDER BY y) FROM wxyz ORDER BY w, query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY w, z ORDER BY y) FROM wxyz ORDER BY w, z, y LIMIT 2 ---- -1 10 1 1 1 -2 10 2 0 2 +1 10 1 1 1.0000000000000000000 +2 10 2 0 2.0000000000000000000 query IIIII rowsort SELECT *, rank() OVER (PARTITION BY w, z ORDER BY y) FROM wxyz ORDER BY z, w, y LIMIT 2 @@ -3642,8 +3642,8 @@ SELECT *, dense_rank() OVER (PARTITION BY w, z ORDER BY y) FROM wxyz ORDER BY z, query IIIIR rowsort SELECT *, avg(w) OVER (PARTITION BY w, z ORDER BY y) FROM wxyz ORDER BY z, w, y LIMIT 2 ---- -2 10 2 0 2 -4 10 2 0 4 +2 10 2 0 2.0000000000000000000 +4 10 2 0 4.0000000000000000000 statement OK CREATE TABLE string_agg_test ( diff --git a/pkg/sql/opt/norm/testdata/rules/fold_constants b/pkg/sql/opt/norm/testdata/rules/fold_constants index 798461e150d6..5cc07396eec9 100644 --- a/pkg/sql/opt/norm/testdata/rules/fold_constants +++ b/pkg/sql/opt/norm/testdata/rules/fold_constants @@ -778,7 +778,7 @@ values ├── cardinality: [1 - 1] ├── key: () ├── fd: ()-->(1) - └── (1,) + └── (1.0000000000000000000,) norm no-stable-folds expect-not=FoldCast SELECT '2020-01-01'::TIMESTAMPTZ diff --git a/pkg/sql/sem/tree/testdata/eval/arithmetic_operators b/pkg/sql/sem/tree/testdata/eval/arithmetic_operators index 29ea5898725a..ca0b9632b3e8 100644 --- a/pkg/sql/sem/tree/testdata/eval/arithmetic_operators +++ b/pkg/sql/sem/tree/testdata/eval/arithmetic_operators @@ -256,7 +256,7 @@ eval eval 2:::decimal ^ -3:::decimal ---- -0.125 +0.12500000000000000000 eval -2:::decimal ^ 3:::decimal @@ -266,7 +266,7 @@ eval eval -2:::decimal ^ -3:::decimal ---- --0.125 +-0.12500000000000000000 eval 3:::decimal ^ 2:::decimal diff --git a/pkg/sql/sem/tree/testdata/eval/builtins b/pkg/sql/sem/tree/testdata/eval/builtins index 6ceb5177472b..266a3e6d2228 100644 --- a/pkg/sql/sem/tree/testdata/eval/builtins +++ b/pkg/sql/sem/tree/testdata/eval/builtins @@ -1,7 +1,7 @@ eval sqrt(4.0) ---- -2 +2.0000000000000000000 eval sqrt(1 * -0:::float) diff --git a/pkg/sql/sem/tree/testdata/eval/float_decimal_div b/pkg/sql/sem/tree/testdata/eval/float_decimal_div index f764bffb62f8..d9f8a15b6955 100644 --- a/pkg/sql/sem/tree/testdata/eval/float_decimal_div +++ b/pkg/sql/sem/tree/testdata/eval/float_decimal_div @@ -3,7 +3,7 @@ eval 4 / 5 ---- -0.8 +0.80000000000000000000 eval 1 / 3 @@ -28,7 +28,7 @@ eval eval 1.1:::decimal / 2.2:::decimal ---- -0.5 +0.50000000000000000000 eval 1:::int / 2.2:::decimal @@ -38,4 +38,4 @@ eval eval 1.1:::decimal / 2:::int ---- -0.55 +0.55000000000000000000 diff --git a/pkg/sql/sem/tree/testdata/eval/int_arith b/pkg/sql/sem/tree/testdata/eval/int_arith index d4abf790ee31..d0214a6793ac 100644 --- a/pkg/sql/sem/tree/testdata/eval/int_arith +++ b/pkg/sql/sem/tree/testdata/eval/int_arith @@ -185,7 +185,7 @@ eval eval -32767:::int2 / -1:::int2 ---- -32767 +32767.000000000000000 eval -32768:::int2 / -1:::int2 @@ -195,7 +195,7 @@ integer out of range for type int2 eval -2147483647:::int4 / -1:::int4 ---- -2147483647 +2147483647.0000000000 eval -2147483648:::int4 / -1:::int4 @@ -205,7 +205,7 @@ integer out of range for type int4 eval (-9223372036854775807:::int8 - 1) / -1:::int8 ---- -9223372036854775808 +9223372036854775808.0 eval 10:::int2 / 0:::int2 @@ -225,17 +225,17 @@ division by zero eval 32767:::int2 / -1:::int2 ---- --32767 +-32767.000000000000000 eval 2147483647:::int4 / -1:::int4 ---- --2147483647 +-2147483647.0000000000 eval 9223372036854775807:::int8 / -1:::int8 ---- --9223372036854775807 +-9223372036854775807.0 ################################## # Mixed-type integer arithmetic. # @@ -304,19 +304,19 @@ eval eval 4:::int2 / 2:::int4 ---- -2 +2.0000000000000000000 eval 6:::int2 / 2:::int8 ---- -3 +3.0000000000000000000 eval 12:::int8 / 3:::int4 ---- -4 +4.0000000000000000000 eval 20:::int8 / 4:::int4 ---- -5 +5.0000000000000000000 diff --git a/pkg/sql/sem/tree/testdata/eval/unary b/pkg/sql/sem/tree/testdata/eval/unary index 98567f4fed5e..d397a2c81ee9 100644 --- a/pkg/sql/sem/tree/testdata/eval/unary +++ b/pkg/sql/sem/tree/testdata/eval/unary @@ -43,7 +43,7 @@ eval eval |/ 9.0::decimal ---- -3 +3.0000000000000000000 eval |/ NULL diff --git a/vendor b/vendor index 89cd2428fc46..ea9f08e05956 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 89cd2428fc462261a2990fe6a02860efca4c82a4 +Subproject commit ea9f08e05956d83617c39d9421128b5c3a3221a7