MDEV-17137: Syntax errors with VIEW using MEDIAN

The syntax error happened because we had not implemented a different print for
percentile functions. The syntax is a bit different when we use percentile functions
as window functions in comparision to normal window functions.
Implemented a seperate print function for percentile functions
This commit is contained in:
Varun Gupta 2018-10-15 09:35:19 -07:00
commit 97a37edc97
6 changed files with 66 additions and 3 deletions

View file

@ -545,6 +545,11 @@ void Item_sum_hybrid_simple::update_field()
void Item_window_func::print(String *str, enum_query_type query_type)
{
if (only_single_element_order_list())
{
print_for_percentile_functions(str, query_type);
return;
}
window_func()->print(str, query_type);
str->append(" over ");
#ifndef DBUG_OFF
@ -554,3 +559,15 @@ void Item_window_func::print(String *str, enum_query_type query_type)
#endif
window_spec->print(str, query_type);
}
void Item_window_func::print_for_percentile_functions(String *str, enum_query_type query_type)
{
window_func()->print(str, query_type);
str->append(" within group ");
str->append('(');
window_spec->print_order(str,query_type);
str->append(')');
str->append(" over ");
str->append('(');
window_spec->print_partition(str,query_type);
str->append(')');
}