2023-03-07 10:27:02 +00:00
|
|
|
-- { echoOn }
|
2023-04-20 12:25:41 +00:00
|
|
|
with arrayJoin([0, 1, 2, 10]) as x select quantilesGK(100, 0.5, 0.4, 0.1)(x);
|
2023-02-15 10:06:09 +00:00
|
|
|
[1,1,0]
|
2023-04-20 12:25:41 +00:00
|
|
|
with arrayJoin([0, 6, 7, 9, 10]) as x select quantileGK(100, 0.5)(x);
|
2023-02-15 10:06:09 +00:00
|
|
|
7
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(10000, 0.25, 0.5, 0.75, 0.0, 1.0, 0, 1)(number + 1) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[250,500,750,1,1000,1,1000]
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(10000, 0.01, 0.1, 0.11)(number + 1) from numbers(10);
|
2023-02-15 10:06:09 +00:00
|
|
|
[1,1,2]
|
2023-04-20 12:25:41 +00:00
|
|
|
with number + 1 as col select quantilesGK(10000, 0.25, 0.5, 0.75)(col), count(col), quantilesGK(10000, 0.0, 1.0)(col), sum(col) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[250,500,750] 1000 [1,1000] 500500
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(1, 100/1000, 200/1000, 250/1000, 314/1000, 777/1000)(number + 1) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[1,1,1,1,1]
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(10, 100/1000, 200/1000, 250/1000, 314/1000, 777/1000)(number + 1) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[1,156,156,296,715]
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(100, 100/1000, 200/1000, 250/1000, 314/1000, 777/1000)(number + 1) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[93,192,251,306,770]
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(1000, 100/1000, 200/1000, 250/1000, 314/1000, 777/1000)(number + 1) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[99,199,249,313,776]
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(10000, 100/1000, 200/1000, 250/1000, 314/1000, 777/1000)(number + 1) from numbers(1000);
|
2023-02-15 10:06:09 +00:00
|
|
|
[100,200,250,314,777]
|
2024-01-30 11:46:23 +00:00
|
|
|
SELECT quantileGKMerge(100, 0.5)(x)
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT quantileGKState(100, 0.5)(number + 1) AS x
|
|
|
|
FROM numbers(49999)
|
|
|
|
);
|
|
|
|
24902
|
|
|
|
SELECT quantilesGKMerge(100, 0.5, 0.9, 0.99)(x)
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT quantilesGKState(100, 0.5, 0.9, 0.99)(number + 1) AS x
|
|
|
|
FROM numbers(49999)
|
|
|
|
);
|
|
|
|
[24902,44518,49999]
|
2024-07-12 12:49:26 +00:00
|
|
|
select medianGK()(number) from numbers(10) SETTINGS enable_analyzer = 0; -- { serverError BAD_ARGUMENTS }
|
|
|
|
select medianGK()(number) from numbers(10) SETTINGS enable_analyzer = 1; -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
select quantileGK()(number) from numbers(10) SETTINGS enable_analyzer = 0; -- { serverError BAD_ARGUMENTS }
|
|
|
|
select quantileGK()(number) from numbers(10) SETTINGS enable_analyzer = 1; -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
2023-04-20 12:25:41 +00:00
|
|
|
select medianGK(100)(number) from numbers(10);
|
2023-03-07 10:27:02 +00:00
|
|
|
4
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantileGK(100)(number) from numbers(10);
|
2023-03-07 10:27:02 +00:00
|
|
|
4
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantileGK(100, 0.5)(number) from numbers(10);
|
|
|
|
4
|
|
|
|
select quantileGK(100, 0.5, 0.75)(number) from numbers(10); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
select quantileGK('abc', 0.5)(number) from numbers(10); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
|
|
|
select quantileGK(1.23, 0.5)(number) from numbers(10); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
|
|
|
select quantileGK(-100, 0.5)(number) from numbers(10); -- { serverError BAD_ARGUMENTS }
|
2024-07-12 12:49:26 +00:00
|
|
|
select quantilesGK()(number) from numbers(10) SETTINGS enable_analyzer = 0; -- { serverError BAD_ARGUMENTS }
|
|
|
|
select quantilesGK()(number) from numbers(10) SETTINGS enable_analyzer = 1; -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK(100)(number) from numbers(10); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
|
|
|
select quantilesGK(100, 0.5)(number) from numbers(10);
|
2023-03-07 10:27:02 +00:00
|
|
|
[4]
|
2023-04-20 12:25:41 +00:00
|
|
|
select quantilesGK('abc', 0.5, 0.75)(number) from numbers(10); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
|
|
|
select quantilesGK(1.23, 0.5, 0.75)(number) from numbers(10); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
|
|
|
select quantilesGK(-100, 0.5, 0.75)(number) from numbers(10); -- { serverError BAD_ARGUMENTS }
|