You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/12/16 14:34:44 UTC

[GitHub] [doris] cambyzju opened a new issue, #15142: [Bug] having clause with same alias name do not work

cambyzju opened a new issue, #15142:
URL: https://github.com/apache/doris/issues/15142

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### Version
   
   latest
   
   ### What's Wrong?
   
   `> select id,sum(v1) v,sum(v2) v2 from test_d group by id having (v2>1);`
   `ERROR 1105 (HY000): errCode = 2, detailMessage = HAVING clause not produced by aggregation output (missing from GROUP BY clause?): (`v2` > 1)`
   
   
   ### What You Expected?
   
   fix
   
   ### How to Reproduce?
   
   1. create table 
   ```
   CREATE TABLE `test_d` (
     `id` int(11) NULL,
     `v1` bigint(20) NULL,
     `v2` bigint(20) NULL
   ) ENGINE=OLAP
   DUPLICATE KEY(`id`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`id`) BUCKETS 1
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1",
   "in_memory" = "false",
   "storage_format" = "V2",
   "disable_auto_compaction" = "false"
   );
   ```
   
   2. insert data
   `insert into test_d values(1,1,1),(2,2,2),(2,3,3);`
   
   3. wrong sql:
   ```
   > select id,sum(v1) v,sum(v2) v2 from test_d group by id having (v2>4);
   ERROR 1105 (HY000): errCode = 2, detailMessage = HAVING clause not produced by aggregation output (missing from GROUP BY clause?): (`v2` > 4)
   ```
   
   4. correct sql:
   ```
   > select id,sum(v1) v,sum(v2) v2 from test_d group by id having (v2>4 AND v>0);
   +------+------+------+
   | id   | v    | v2   |
   +------+------+------+
   |    2 |    5 |    5 |
   +------+------+------+
   ```
   
   ### Anything Else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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: commits-unsubscribe@doris.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] cambyzju closed issue #15142: [Bug] having clause with same alias name do not work

Posted by GitBox <gi...@apache.org>.
cambyzju closed issue #15142: [Bug] having clause with same alias name do not work
URL: https://github.com/apache/doris/issues/15142


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org