mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-19052 Range-type window frame supports only numeric datatype
When there is no bounds on the upper or lower part of the window, it doesn't matter if the type is numeric. It also doesn't matter how many ORDER BY items there are in the query. Reviewers: Sergei Petrunia and Oleg Smirnov
This commit is contained in:
@ -1253,15 +1253,10 @@ insert into t1 values (1,1,'foo');
|
||||
insert into t1 values (2,2,'bar');
|
||||
select
|
||||
count(*) over (order by a,b
|
||||
range between unbounded preceding and current row) as count
|
||||
range between 1 preceding and current row) as count
|
||||
from t1;
|
||||
ERROR HY000: RANGE-type frame requires ORDER BY clause with single sort key
|
||||
select
|
||||
count(*) over (order by c
|
||||
range between unbounded preceding and current row) as count
|
||||
from t1;
|
||||
ERROR HY000: Numeric datatype is required for RANGE-type frame
|
||||
select
|
||||
count(*) over (order by a
|
||||
range between 'abcd' preceding and current row) as count
|
||||
from t1;
|
||||
@ -1283,6 +1278,59 @@ rows between current row and 3.14 following) as count
|
||||
from t1;
|
||||
ERROR HY000: Integer is required for ROWS-type frame
|
||||
#
|
||||
# MDEV-19052 Range-type window frame supports only numeric datatype
|
||||
#
|
||||
select
|
||||
count(*) over (order by c
|
||||
range between unbounded preceding and current row)
|
||||
from t1;
|
||||
count(*) over (order by c
|
||||
range between unbounded preceding and current row)
|
||||
1
|
||||
2
|
||||
select
|
||||
count(*) over (order by c
|
||||
range between current row and unbounded following)
|
||||
from t1;
|
||||
count(*) over (order by c
|
||||
range between current row and unbounded following)
|
||||
2
|
||||
1
|
||||
select
|
||||
count(*) over (order by c
|
||||
range between unbounded preceding and unbounded following)
|
||||
from t1;
|
||||
count(*) over (order by c
|
||||
range between unbounded preceding and unbounded following)
|
||||
2
|
||||
2
|
||||
create table t2 (a int, b varchar(5));
|
||||
insert into t2 values (1,'a'), (2, 'b'), (3, 'c');
|
||||
select sum(a) over (order by b range between unbounded preceding and current row) from t2;
|
||||
sum(a) over (order by b range between unbounded preceding and current row)
|
||||
1
|
||||
3
|
||||
6
|
||||
insert into t1 values (3,3,'goo');
|
||||
insert into t1 values (3,1,'har');
|
||||
insert into t1 values (1,4,'har');
|
||||
select a, b, sum(b) over (order by a, b desc range between unbounded preceding and current row) from t1;
|
||||
a b sum(b) over (order by a, b desc range between unbounded preceding and current row)
|
||||
1 4 4
|
||||
1 1 5
|
||||
2 2 7
|
||||
3 3 10
|
||||
3 1 11
|
||||
select a, b, sum(b) over (order by a desc, b range between unbounded preceding and current row) from t1;
|
||||
a b sum(b) over (order by a desc, b range between unbounded preceding and current row)
|
||||
3 1 1
|
||||
3 3 4
|
||||
2 2 6
|
||||
1 1 7
|
||||
1 4 11
|
||||
drop table t2;
|
||||
delete from t1 where a >= 3 or b = 4;
|
||||
#
|
||||
# EXCLUDE clause is parsed but not supported
|
||||
#
|
||||
select
|
||||
|
Reference in New Issue
Block a user