ClickHouse/tests/queries/0_stateless/03036_clamp.sql

16 lines
755 B
MySQL
Raw Normal View History

2024-04-07 09:02:43 +00:00
SELECT clamp(1, 10, 20);
SELECT clamp(30, 10, 20);
SELECT clamp(15, 10, 20);
2024-04-08 06:44:11 +00:00
SELECT clamp('a', 'b', 'c');
2024-04-21 12:03:15 +00:00
SELECT clamp(today(), yesterday() - 10, yesterday() + 10) - today();
2024-04-08 06:44:11 +00:00
SELECT clamp([], ['hello'], ['world']);
SELECT clamp(-1., -1000., 18446744073709551615.);
SELECT clamp(toNullable(123), 234, 456);
2024-04-08 13:34:54 +00:00
select clamp(1, null, 5);
2024-04-21 12:03:15 +00:00
select clamp(1, 6, null);
select clamp(1, 5, nan);
select clamp(toInt64(number), toInt64(number-1), toInt64(number+1)) from numbers(3);
2024-04-26 09:06:17 +00:00
select clamp(number, number-1, number+1) from numbers(3); -- { serverError NO_COMMON_TYPE }
select clamp(1, 3, 2); -- { serverError BAD_ARGUMENTS }
2024-04-29 12:59:31 +00:00
select clamp(1, data[1], data[2])from (select arrayJoin([[1, 2], [2,3], [3,2], [4, 4]]) as data); -- { serverError BAD_ARGUMENTS }