morrySnow commented on code in PR #15143:
URL: https://github.com/apache/doris/pull/15143#discussion_r1056025197


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java:
##########
@@ -989,18 +989,36 @@ private void analyzeAggregation(Analyzer analyzer) throws 
AnalysisException {
              *                     (select min(k1) from table b where 
a.key=b.k2);
              * TODO: the a.key should be replaced by a.k1 instead of unknown 
column 'key' in 'a'
              */
+
+            // according to mysql
+            // having clause should use column name inside group by clause, 
prior to alias.
+            // case1: having clause use column name table.v1, because v1 
inside group by clause
+            //     select id, sum(v1) v1 from table group by id,v1 
having(v1>1);

Review Comment:
   MySQL's behavior is very strange. according to sql standard, `having` should 
filter the data after `Aggregate`. So the slot in `having` should always bind 
on the output of `Aggregate`, in other words, the alias name.
   Since doris has many different from the behavior of MySQL. Here we should 
follow the SQL standard instead of MySQL for a more understandable syntax.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to