BETWEEN CURRENT ROW AND CURRENT ROW

This commit is contained in:
Alexander Kuzmenkov 2021-02-03 17:55:40 +03:00
parent 35754abb4a
commit ec382d8812
3 changed files with 20 additions and 0 deletions

View File

@ -101,6 +101,14 @@ void WindowFrame::checkValid() const
return;
}
if (end_type == BoundaryType::Current
&& begin_type == BoundaryType::Current)
{
// BETWEEN CURRENT ROW AND CURRENT ROW makes some sense for RANGE or
// GROUP frames, and is technically valid for ROWS frame.
return;
}
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Window frame '{}' is invalid",
toString());

View File

@ -607,3 +607,10 @@ settings max_block_size = 2;
26 5 2 2
29 5 2 2
30 6 0 1
select
count(*) over (rows between current row and current row),
count(*) over (range between current row and current row)
from numbers(3);
1 3
1 3
1 3

View File

@ -191,3 +191,8 @@ from (select number, intDiv(number, 5) p, mod(number, 3) o
from numbers(31))
order by p, o, number
settings max_block_size = 2;
select
count(*) over (rows between current row and current row),
count(*) over (range between current row and current row)
from numbers(3);