ClickHouse/tests/queries/0_stateless/00957_neighbor.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
2.3 KiB
MySQL
Raw Normal View History

SET allow_deprecated_error_prone_window_functions = 1;
2019-08-23 02:53:09 +00:00
-- no arguments
select neighbor(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
2019-08-23 02:53:09 +00:00
-- single argument
select neighbor(1); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
2019-08-23 02:53:09 +00:00
-- greater than 3 arguments
select neighbor(1,2,3,4); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
2019-08-23 02:53:09 +00:00
-- bad default value
select neighbor(dummy, 1, 'hello'); -- { serverError NO_COMMON_TYPE }
2019-08-23 02:53:09 +00:00
-- types without common supertype (UInt64 and Int8)
select number, neighbor(number, 1, -10) from numbers(3); -- { serverError NO_COMMON_TYPE }
2019-08-23 02:53:09 +00:00
-- nullable offset is not allowed
select number, if(number > 1, number, null) as offset, neighbor(number, offset) from numbers(3); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
2019-08-23 02:53:09 +00:00
select 'Zero offset';
select number, neighbor(number, 0) from numbers(3);
select 'Nullable values';
select if(number > 1, number, null) as value, number as offset, neighbor(value, offset) as neighbor from numbers(3);
select 'Result with different type';
select toInt32(number) as n, neighbor(n, 1, -10) from numbers(3);
select 'Offset > block';
select number, neighbor(number, 10) from numbers(3);
select 'Abs(Offset) > block';
select number, neighbor(number, -10) from numbers(3);
select 'Positive offset';
select number, neighbor(number, 1) from numbers(3);
select 'Negative offset';
select number, neighbor(number, 1) from numbers(3);
select 'Positive offset with defaults';
select number, neighbor(number, 2, number + 10) from numbers(4);
select 'Negative offset with defaults';
select number, neighbor(number, -2, number + 10) from numbers(4);
select 'Positive offset with const defaults';
select number, neighbor(number, 1, 1000) from numbers(3);
select 'Negative offset with const defaults';
select number, neighbor(number, -1, 1000) from numbers(3);
select 'Dynamic column and offset, out of bounds';
select number, number * 2 as offset, neighbor(number, offset, number * 10) from numbers(4);
select 'Dynamic column and offset, negative';
select number, -number * 2 as offset, neighbor(number, offset, number * 10) from numbers(6);
select 'Dynamic column and offset, without defaults';
select number, -(number - 2) * 2 as offset, neighbor(number, offset) from numbers(6);
select 'Constant column';
2024-04-30 13:09:44 +00:00
select number, neighbor(1000, 10) from numbers(3);