-
Notifications
You must be signed in to change notification settings - Fork 489
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
parser: fix aggregate functions compatibility to MySQL8.0 #1116
Comments
DISTINCT
should raise an syntax error
@kennytm Shall we label it |
I don't see any point disabling support of DISTINCT. We provide the correct result with DISTINCT, compatible with PostgreSQL. create table a (a int);
insert into a values (1), (2), (2), (3), (3), (3);
select var_pop(all a), var_pop(distinct a), var_pop(a) from a;
-- both PostgreSQL and TiDB return 0.5555…, 0.6666…, 0.5555… The additional DISTINCT keyword, although prohibited by ISO 9075*, is well supported in PostgreSQL (and CockroachDB), BigQuery, Snowflake and Microsoft Transact-SQL and IBM DB2. Meanwhile, MySQL (and MariaDB),
Edit: Oracle's non-standard VARIANCE and STDDEV functions do allow DISTINCT, but the standard ones with _POP and _SAMP suffixes don't 🤷. |
@kennytm Yes, I have notice that TiDB provide the correct result with |
Bug Report
On MySQL 8, aggregate functions below do not support distinct options:
(ref https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html)
E.g:
Executed result of SQL
select std(distinct c) from t
in MySQL 8 would get error feedback like:but, it would execute successfully in TiDB.
The text was updated successfully, but these errors were encountered: