mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Missing tests in several tests in 24.10
Added corner cases for tests for: to_utc_timestamp and from_utc_timestamp (more timezones, spetial timezones, epoch corners does not look right, raising a bug over that) arrayUnion (empty and big arrays) quantilesExactWeightedInterpolated (more data types)
This commit is contained in:
parent
1f253c7b3a
commit
ead7630d04
@ -3,3 +3,8 @@
|
||||
3 2023-03-16 12:22:33 2023-03-16 10:22:33.000 2023-03-16 03:22:33 2023-03-16 19:22:33.123
|
||||
2024-02-24 10:22:33 2024-02-24 12:22:33
|
||||
2024-10-24 09:22:33 2024-10-24 13:22:33
|
||||
2024-10-24 16:22:33 2024-10-24 06:22:33
|
||||
leap year: 2024-02-29 16:22:33 2024-02-29 06:22:33
|
||||
non-leap year: 2023-03-01 16:22:33 2023-03-01 06:22:33
|
||||
timezone with half-hour offset: 2024-02-29 00:52:33 2024-02-29 21:52:33
|
||||
jump over a year: 2024-01-01 04:01:01 2023-12-31 20:01:01
|
||||
|
@ -15,4 +15,10 @@ $CLICKHOUSE_CLIENT -q "select x, to_utc_timestamp(toDateTime('2023-03-16 11:22:3
|
||||
# timestamp convert between DST timezone and UTC
|
||||
$CLICKHOUSE_CLIENT -q "select to_utc_timestamp(toDateTime('2024-02-24 11:22:33'), 'Europe/Madrid'), from_utc_timestamp(toDateTime('2024-02-24 11:22:33'), 'Europe/Madrid')"
|
||||
$CLICKHOUSE_CLIENT -q "select to_utc_timestamp(toDateTime('2024-10-24 11:22:33'), 'Europe/Madrid'), from_utc_timestamp(toDateTime('2024-10-24 11:22:33'), 'Europe/Madrid')"
|
||||
$CLICKHOUSE_CLIENT -q "drop table test_tbl"
|
||||
$CLICKHOUSE_CLIENT -q "select to_utc_timestamp(toDateTime('2024-10-24 11:22:33'), 'EST'), from_utc_timestamp(toDateTime('2024-10-24 11:22:33'), 'EST')"
|
||||
$CLICKHOUSE_CLIENT -q "select 'leap year:', to_utc_timestamp(toDateTime('2024-02-29 11:22:33'), 'EST'), from_utc_timestamp(toDateTime('2024-02-29 11:22:33'), 'EST')"
|
||||
$CLICKHOUSE_CLIENT -q "select 'non-leap year:', to_utc_timestamp(toDateTime('2023-02-29 11:22:33'), 'EST'), from_utc_timestamp(toDateTime('2023-02-29 11:22:33'), 'EST')"
|
||||
$CLICKHOUSE_CLIENT -q "select 'timezone with half-hour offset:', to_utc_timestamp(toDateTime('2024-02-29 11:22:33'), 'Australia/Adelaide'), from_utc_timestamp(toDateTime('2024-02-29 11:22:33'), 'Australia/Adelaide')"
|
||||
$CLICKHOUSE_CLIENT -q "select 'jump over a year:', to_utc_timestamp(toDateTime('2023-12-31 23:01:01'), 'EST'), from_utc_timestamp(toDateTime('2024-01-01 01:01:01'), 'EST')"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "drop table test_tbl"
|
||||
|
@ -41,3 +41,13 @@
|
||||
[1,2,3,4,5,10,20]
|
||||
-------
|
||||
[1,2,3]
|
||||
-------
|
||||
[10,-2,1] ['hello','hi'] [3,2,1,NULL]
|
||||
-------
|
||||
-------
|
||||
[1]
|
||||
-------
|
||||
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256]
|
||||
199999
|
||||
-------
|
||||
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]
|
||||
|
@ -35,4 +35,23 @@ SELECT arraySort(arrayUnion([NULL, NULL, NULL, 1], [1, NULL, NULL], [1, 2, 3, NU
|
||||
select '-------';
|
||||
SELECT arraySort(arrayUnion([1, 1, 1, 2, 3], [2, 2, 4], [5, 10, 20]));
|
||||
select '-------';
|
||||
SELECT arraySort(arrayUnion([1, 2], [1, 3], [])),
|
||||
SELECT arraySort(arrayUnion([1, 2], [1, 3], []));
|
||||
select '-------';
|
||||
-- example from docs
|
||||
SELECT
|
||||
arrayUnion([-2, 1], [10, 1], [-2], []) as num_example,
|
||||
arrayUnion(['hi'], [], ['hello', 'hi']) as str_example,
|
||||
arrayUnion([1, 3, NULL], [2, 3, NULL]) as null_example;
|
||||
select '-------';
|
||||
--mix of types
|
||||
SELECT arrayUnion([1], [-2], [1.1, 'hi'], [NULL, 'hello', []]); -- {serverError NO_COMMON_TYPE}
|
||||
select '-------';
|
||||
SELECT arrayUnion([1]);
|
||||
SELECT arrayUnion(); -- {serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH}
|
||||
select '-------';
|
||||
--bigger arrays
|
||||
SELECT arraySort(arrayUnion(range(1, 256), range(2, 257)));
|
||||
SELECT length(arrayUnion(range(1, 100000), range(9999, 200000)));
|
||||
select '-------';
|
||||
--bigger number of arguments
|
||||
SELECT arraySort(arrayUnion([1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19]));
|
||||
|
@ -1,6 +1,6 @@
|
||||
quantileExactWeightedInterpolated
|
||||
0 0 0 Decimal(38, 8)
|
||||
-25.5 -8.49999999 -5.1 Decimal(38, 8)
|
||||
0 0 0 25 2024-02-20 Decimal(38, 8)
|
||||
-25.5 -8.49999999 -5.1 12.25 2024-01-25 Decimal(38, 8)
|
||||
0 0 0
|
||||
10 3.33333333 2
|
||||
20 6.66666666 4
|
||||
@ -10,11 +10,14 @@ quantileExactWeightedInterpolated
|
||||
[-50,-40,-30,-20,-10,0,10,20,30,40,50]
|
||||
[-16.66666666,-13.33333333,-10,-6.66666666,-3.33333333,0,3.33333333,6.66666666,10,13.33333333,16.66666666]
|
||||
[-10,-8,-6,-4,-2,0,2,4,6,8,10]
|
||||
[0,5,10,15,20,25,30,35,40,45,50]
|
||||
['2024-01-01','2024-01-11','2024-01-21','2024-01-31','2024-02-10','2024-02-20','2024-03-01','2024-03-11','2024-03-21','2024-03-31','2024-04-10']
|
||||
quantileExactWeightedInterpolatedState
|
||||
[10000.6,20000.2,29999.8,39999.4]
|
||||
Test with filter that returns no rows
|
||||
0 0 0
|
||||
0 0 0 nan 1970-01-01
|
||||
0 0 0 nan 1970-01-01
|
||||
Test with dynamic weights
|
||||
21 7 4.2
|
||||
21 7 4.2 35.5 2024-03-12
|
||||
Test with all weights set to 0
|
||||
0 0 0
|
||||
0 0 0 nan 1970-01-01
|
||||
|
@ -5,16 +5,28 @@ CREATE TABLE decimal
|
||||
a Decimal32(4),
|
||||
b Decimal64(8),
|
||||
c Decimal128(8),
|
||||
f Float64,
|
||||
d Date,
|
||||
w UInt64
|
||||
) ENGINE = Memory;
|
||||
|
||||
INSERT INTO decimal (a, b, c, w)
|
||||
SELECT toDecimal32(number - 50, 4), toDecimal64(number - 50, 8) / 3, toDecimal128(number - 50, 8) / 5, number
|
||||
INSERT INTO decimal (a, b, c, f, d, w)
|
||||
SELECT toDecimal32(number - 50, 4), toDecimal64(number - 50, 8) / 3, toDecimal128(number - 50, 8) / 5, number/2, addDays(toDate('2024-01-01'), number), number
|
||||
FROM system.numbers LIMIT 101;
|
||||
|
||||
SELECT 'quantileExactWeightedInterpolated';
|
||||
SELECT medianExactWeightedInterpolated(a, 1), medianExactWeightedInterpolated(b, 2), medianExactWeightedInterpolated(c, 3) as x, toTypeName(x) FROM decimal;
|
||||
SELECT quantileExactWeightedInterpolated(a, 1), quantileExactWeightedInterpolated(b, 2), quantileExactWeightedInterpolated(c, 3) as x, toTypeName(x) FROM decimal WHERE a < 0;
|
||||
SELECT medianExactWeightedInterpolated(a, 1),
|
||||
medianExactWeightedInterpolated(b, 2),
|
||||
medianExactWeightedInterpolated(c, 3) as x,
|
||||
medianExactWeightedInterpolated(f, 4),
|
||||
medianExactWeightedInterpolated(d, 5),
|
||||
toTypeName(x) FROM decimal;
|
||||
SELECT quantileExactWeightedInterpolated(a, 1),
|
||||
quantileExactWeightedInterpolated(b, 2),
|
||||
quantileExactWeightedInterpolated(c, 3) as x,
|
||||
quantileExactWeightedInterpolated(f, 4),
|
||||
quantileExactWeightedInterpolated(d, 5),
|
||||
toTypeName(x) FROM decimal WHERE a < 0;
|
||||
SELECT quantileExactWeightedInterpolated(0.0)(a, 1), quantileExactWeightedInterpolated(0.0)(b, 2), quantileExactWeightedInterpolated(0.0)(c, 3) FROM decimal WHERE a >= 0;
|
||||
SELECT quantileExactWeightedInterpolated(0.2)(a, 1), quantileExactWeightedInterpolated(0.2)(b, 2), quantileExactWeightedInterpolated(0.2)(c, 3) FROM decimal WHERE a >= 0;
|
||||
SELECT quantileExactWeightedInterpolated(0.4)(a, 1), quantileExactWeightedInterpolated(0.4)(b, 2), quantileExactWeightedInterpolated(0.4)(c, 3) FROM decimal WHERE a >= 0;
|
||||
@ -24,6 +36,8 @@ SELECT quantileExactWeightedInterpolated(1.0)(a, 1), quantileExactWeightedInterp
|
||||
SELECT quantilesExactWeightedInterpolated(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)(a, 1) FROM decimal;
|
||||
SELECT quantilesExactWeightedInterpolated(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)(b, 2) FROM decimal;
|
||||
SELECT quantilesExactWeightedInterpolated(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)(c, 3) FROM decimal;
|
||||
SELECT quantilesExactWeightedInterpolated(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)(f, 4) FROM decimal;
|
||||
SELECT quantilesExactWeightedInterpolated(0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0)(d, 5) FROM decimal;
|
||||
|
||||
SELECT 'quantileExactWeightedInterpolatedState';
|
||||
SELECT quantilesExactWeightedInterpolatedMerge(0.2, 0.4, 0.6, 0.8)(x)
|
||||
@ -34,12 +48,29 @@ FROM
|
||||
);
|
||||
|
||||
SELECT 'Test with filter that returns no rows';
|
||||
SELECT medianExactWeightedInterpolated(a, 1), medianExactWeightedInterpolated(b, 2), medianExactWeightedInterpolated(c, 3) FROM decimal WHERE a > 1000;
|
||||
SELECT medianExactWeightedInterpolated(a, 1),
|
||||
medianExactWeightedInterpolated(b, 2),
|
||||
medianExactWeightedInterpolated(c, 3),
|
||||
medianExactWeightedInterpolated(f, 4),
|
||||
medianExactWeightedInterpolated(d, 5) FROM decimal WHERE a > 1000;
|
||||
SELECT quantileExactWeightedInterpolated(a, 1),
|
||||
quantileExactWeightedInterpolated(b, 2),
|
||||
quantileExactWeightedInterpolated(c, 3),
|
||||
quantileExactWeightedInterpolated(f, 4),
|
||||
quantileExactWeightedInterpolated(d, 5) FROM decimal WHERE d < toDate('2024-01-01');
|
||||
|
||||
SELECT 'Test with dynamic weights';
|
||||
SELECT medianExactWeightedInterpolated(a, w), medianExactWeightedInterpolated(b, w), medianExactWeightedInterpolated(c, w) FROM decimal;
|
||||
SELECT medianExactWeightedInterpolated(a, w),
|
||||
medianExactWeightedInterpolated(b, w),
|
||||
medianExactWeightedInterpolated(c, w),
|
||||
medianExactWeightedInterpolated(f, w),
|
||||
medianExactWeightedInterpolated(d, w) FROM decimal;
|
||||
|
||||
SELECT 'Test with all weights set to 0';
|
||||
SELECT medianExactWeightedInterpolated(a, 0), medianExactWeightedInterpolated(b, 0), medianExactWeightedInterpolated(c, 0) FROM decimal;
|
||||
SELECT medianExactWeightedInterpolated(a, 0),
|
||||
medianExactWeightedInterpolated(b, 0),
|
||||
medianExactWeightedInterpolated(c, 0),
|
||||
medianExactWeightedInterpolated(f, 0),
|
||||
medianExactWeightedInterpolated(d, 0) FROM decimal;
|
||||
|
||||
DROP TABLE IF EXISTS decimal;
|
||||
|
Loading…
Reference in New Issue
Block a user