Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
58a6e435
Commit
58a6e435
authored
Sep 07, 2017
by
Varun Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests added for percentile and median functions
parent
b77105ca
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
383 additions
and
1 deletion
+383
-1
mysql-test/r/win_percentile.result
mysql-test/r/win_percentile.result
+305
-0
mysql-test/t/win_percentile.test
mysql-test/t/win_percentile.test
+77
-0
sql/item_windowfunc.cc
sql/item_windowfunc.cc
+1
-1
No files found.
mysql-test/r/win_percentile.result
0 → 100644
View file @
58a6e435
This diff is collapsed.
Click to expand it.
mysql-test/t/win_percentile.test
0 → 100644
View file @
58a6e435
CREATE
TABLE
t1
(
name
CHAR
(
10
),
test
double
,
score
DECIMAL
(
19
,
4
));
INSERT
INTO
t1
VALUES
(
'Chun'
,
0
,
3
),
(
'Chun'
,
0
,
7
),
(
'Kaolin'
,
0.5
,
3
),
(
'Kaolin'
,
0.6
,
7
),
(
'Kaolin'
,
0.5
,
4
),
(
'Tatiana'
,
0.8
,
4
),
(
'Tata'
,
0.8
,
4
);
select
name
,
percentile_cont
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
--
echo
no
partition
clause
select
name
,
percentile_disc
(
0.5
)
within
group
(
order
by
score
)
over
()
from
t1
;
select
name
,
percentile_cont
(
0.5
)
within
group
(
order
by
score
)
over
()
from
t1
;
--
echo
argument
set
to
null
--
error
ER_WRONG_TYPE_OF_ARGUMENT
select
name
,
percentile_cont
(
null
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
error
ER_WRONG_TYPE_OF_ARGUMENT
select
name
,
percentile_disc
(
null
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
echo
subqueries
having
percentile
functions
select
*
from
(
select
name
,
percentile_cont
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
)
as
t
;
select
*
from
(
select
name
,
percentile_disc
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
)
as
t
;
select
name
from
t1
a
where
(
select
percentile_disc
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
b
limit
1
)
>=
0.5
;
--
echo
disallowed
fields
in
order
by
--
error
ER_WRONG_TYPE_FOR_PERCENTILE_CONT
select
score
,
percentile_cont
(
0.5
)
within
group
(
order
by
name
)
over
(
partition
by
score
)
from
t1
;
select
score
,
percentile_disc
(
0.5
)
within
group
(
order
by
name
)
over
(
partition
by
score
)
from
t1
;
--
echo
order
by
clause
has
more
than
one
element
--
error
ER_PARSE_ERROR
select
percentile_disc
(
0.5
)
within
group
(
order
by
score
,
test
)
over
(
partition
by
name
)
from
t1
;
--
error
ER_PARSE_ERROR
select
percentile_cont
(
0.5
)
within
group
(
order
by
score
,
test
)
over
(
partition
by
name
)
from
t1
;
--
echo
parameter
value
should
be
in
the
range
of
[
0
,
1
]
--
error
ER_ARGUMENT_OUT_OF_RANGE
select
percentile_disc
(
1.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
error
ER_ARGUMENT_OUT_OF_RANGE
select
percentile_cont
(
1.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
error
ER_ARGUMENT_NOT_CONSTANT
select
name
,
percentile_cont
(
test
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
error
ER_ARGUMENT_NOT_CONSTANT
select
name
,
percentile_disc
(
test
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
echo
only
numerical
types
are
allowed
as
argument
to
percentile
functions
--
error
ER_WRONG_TYPE_OF_ARGUMENT
select
name
,
percentile_cont
(
name
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
from
t1
;
--
echo
complete
query
with
partition
column
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
),
percentile_disc
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
percentile_cont
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.1
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.2
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.3
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.4
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.6
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.7
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.8
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
0.9
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
name
,
cume_dist
()
over
(
partition
by
name
order
by
score
)
as
b
,
percentile_disc
(
1
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.1
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.2
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.3
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.4
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.5
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.6
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.7
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.8
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
0.9
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
select
median
(
score
)
over
(
partition
by
name
),
percentile_cont
(
1
)
within
group
(
order
by
score
)
over
(
partition
by
name
)
as
c
from
t1
;
drop
table
t1
;
sql/item_windowfunc.cc
View file @
58a6e435
...
...
@@ -176,7 +176,7 @@ bool Item_window_func::check_result_type_of_order_item()
Item_result
rtype
=
window_spec
->
order_list
->
first
->
item
[
0
]
->
cmp_type
();
// TODO (varun) : support date type in percentile_cont function
if
(
rtype
!=
REAL_RESULT
&&
rtype
!=
INT_RESULT
&&
rtype
!=
DECIMAL_RESULT
&&
rtype
!=
TIME_RESULT
rtype
!=
DECIMAL_RESULT
&&
rtype
!=
TIME_RESULT
&&
window_func
()
->
sum_func
()
==
Item_sum
::
PERCENTILE_CONT_FUNC
)
{
my_error
(
ER_WRONG_TYPE_FOR_PERCENTILE_CONT
,
MYF
(
0
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment