You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/12/08 09:51:49 UTC

[GitHub] [arrow-datafusion] jackwener commented on issue #4556: `having` shouldn't include alias in projection

jackwener commented on issue #4556:
URL: https://github.com/apache/arrow-datafusion/issues/4556#issuecomment-1342399709

   `standard sql` disallow `groupby` or `having` use the alias in `select list`.
   
   But, pg allow `groupby` use alias in `select list` but disallow `having` use alias.
   
   so strange things.
   
   ```sql
   -- create
   CREATE TABLE EMPLOYEE (
     empId INTEGER PRIMARY KEY,
     age INTEGER NOT NULL,
     name TEXT NOT NULL
   );
   
   -- insert
   INSERT INTO EMPLOYEE VALUES (0001, 0020, 'Sales');
   
   --ok
   select max(empId), age as a from EMPLOYEE group by a;
   --failed
   select max(empId), age as a from EMPLOYEE group by a > 3;
   
   -- ok
   select max(empId), (age + empId) as a from EMPLOYEE group by a;
   -- failed
   select max(empId), (age as a + empId) as a from EMPLOYEE group by (a + empId);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org