-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](having-clause) having clause do not works correct with same alias name #15143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
TeamCity pipeline, clickbench performance test result: |
|
please add regression test |
4041398 to
9715015
Compare
done |
| // 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MySQL's behavior is very strange. according to sql standard,
havingshould filter the data afterAggregate. So the slot inhavingshould always bind on the output ofAggregate, 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.
- accord to SQL standard, having clause do not support alias name;
- Doris always say "compatible with MySQL protocol", lots of SQL keeps Mysql way;
- Before this pr, we already try to following MySQL way. But the old implement has two problem:
- one is, only consider has GROUP BY or NOT, not consider slots inside GROUP BY or not;
- the other is, try whole HAVING expr, do consider part slots have alias, part slots do not;
So if we want to follow SQL standard, we should better forbid alias name in HAVING clause.
But old users will confused, because the behavior changes too large.
yangzhg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
Proposed changes
Issue Number: close #15142
Problem summary
Describe your changes.
Checklist(Required)
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...