2024-05-24 10:54:06 +00:00
|
|
|
SET allow_deprecated_error_prone_window_functions = 1;
|
2019-08-23 02:53:09 +00:00
|
|
|
-- no arguments
|
2024-05-30 12:27:25 +00:00
|
|
|
select neighbor(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
2019-08-23 02:53:09 +00:00
|
|
|
-- single argument
|
2024-05-30 12:27:25 +00:00
|
|
|
select neighbor(1); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
2019-08-23 02:53:09 +00:00
|
|
|
-- greater than 3 arguments
|
2024-05-30 12:27:25 +00:00
|
|
|
select neighbor(1,2,3,4); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
2019-08-23 02:53:09 +00:00
|
|
|
-- bad default value
|
2024-05-30 12:27:25 +00:00
|
|
|
select neighbor(dummy, 1, 'hello'); -- { serverError NO_COMMON_TYPE }
|
2019-08-23 02:53:09 +00:00
|
|
|
-- types without common supertype (UInt64 and Int8)
|
2024-05-30 12:27:25 +00:00
|
|
|
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
|
2024-05-30 12:27:25 +00:00
|
|
|
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);
|