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

Jin Xing commented on CALCITE-3589:
-----------------------------------

Run below SQL in MySQL and PostgreSQL;
{code:java}
CREATE TABLE test(a int, b int);
insert into test values (1,3), (3,1);

MySQL:
mysql> select a % 2 a from test group by a;
Returns:
+------+
| a    |
+------+
|    1 |
|    1 |
+------+
mysql> select a + b a from test group by a;
Returns:
+------+
| a    |
+------+
|    4 |
|    4 |
+------+

PostgreSQL:
psql> select a % 2 a from test group by a;
Returns:
 a 
---
 1
 1
psql> select a + b a from test group by a;
ERROR:  column "test.b" must appear in the GROUP BY clause or be used in an 
aggregate function
LINE 1: select a + b a from test group by a;

{code}
 

> SqlValidatorException when conformation is set to LENIENT
> ---------------------------------------------------------
>
>                 Key: CALCITE-3589
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3589
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: bingfeng.guo
>            Priority: Critical
>
> {color:#172b4d}When conformance is set to LENIENT, and the alias of the 
> select expression is the same as the table name in the expression, and the 
> expression appears in group by, a SqlValidatorException will occur。{color}
> {color:#172b4d}a simple example is as follows:{color}
> {color:#ff8b00}SELECT MY_ID + 1 AS MY_ID, sum(PRICE){color}
>  {color:#ff8b00}FROM tableA{color}
>  {color:#ff8b00}GROUP BY MY_ID + 1{color}



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

Reply via email to