[ 
https://issues.apache.org/jira/browse/CALCITE-4349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17257665#comment-17257665
 ] 

Zhen Wang edited comment on CALCITE-4349 at 1/3/21, 6:57 AM:
-------------------------------------------------------------

from my experiment, group_concat in mysql context does support multiple 
expressions 
[mysql example|https://www.db-fiddle.com/f/fouBy7MdxXzRmyzaWu8woB/2]


{code:sql}
CREATE TABLE test (
  x int,
  y char
);
INSERT INTO test (x, y) VALUES (1, 'a');
INSERT INTO test (x, y) VALUES (2, 'b');

select group_concat(x, y separator ';') from test;

--1a;2b

select
    group_concat(deptno, ename order by ename) as combined_name
from emp;

{code}

list_agg function also supports this, but the `group_concat` query is 
generating some incorrect code, which requires more time to fix. 

- not use mysqlfunc will report function not found. this is verified. but not 
sure where are such tests, I checked several mysql only function, didn't manage 
to find such tests.  guess the annotation is already quite intuitive itself. 

I think I've addressed most of the comments. 
as for many files are touched, it is really caused by the new syntax sugar 
which is not supported before.







was (Author: zhenw):
from my experiment, group_concat in mysql context does support multiple 
expressions 
[mysql example|https://www.db-fiddle.com/f/fouBy7MdxXzRmyzaWu8woB/2]


{code:sql}
CREATE TABLE test (
  x int,
  y char
);
INSERT INTO test (x, y) VALUES (1, 'a');
INSERT INTO test (x, y) VALUES (2, 'b');

select group_concat(x, y separator ';') from test;

--1a;2b

select
    group_concat(deptno, ename order by ename) as combined_name
from emp;

{code}

list_agg function also supports this, but the `group_concat` query is 
generating some errors.




> Support GROUP_CONCAT aggregate function for MySQL
> -------------------------------------------------
>
>                 Key: CALCITE-4349
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4349
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Zhen Wang
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Support the {{GROUP_CONCAT}} aggregate function for MySQL. Here is the 
> [syntax|https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat]:
> {noformat}
> GROUP_CONCAT([DISTINCT] expr [,expr ...]
>              [ORDER BY {unsigned_integer | col_name | expr}
>                  [ASC | DESC] [,col_name ...]]
>              [SEPARATOR str_val])
> {noformat}
>  
> {{GROUP_CONCAT}} is analogous to {{LISTAGG}} (see CALCITE-2754) (and also to 
> BigQuery and PostgreSQL's {{STRING_AGG}}, see CALCITE-4335). For example, the 
> query
> {code:java}
> SELECT deptno, GROUP_CONCAT(ename ORDER BY empno SEPARATOR ';')
> FROM Emp
> GROUP BY deptno
> {code}
> is equivalent to (and in Calcite's algebra would be desugared to)
> {code:java}
> SELECT deptno, LISTAGG(ename, ';') WITHIN GROUP (ORDER BY empno)
> FROM Emp
> GROUP BY deptno
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to