pingcap/tidb

select var_pop(distinct xxx) could successfully execute in TiDB but failed in MySQL

Open

#19,499 opened on 2020年8月26日

GitHub で見る
 (9 comments) (0 reactions) (0 assignees)Go (6,186 forks)batch import
challenge-programgood first issuesig/executiontype/compatibility

Repository metrics

Stars
 (40,090 stars)
PR merge metrics
 (平均マージ 14d 4h) (30d で 346 merged PRs)

説明

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  • TiDB
mysql> create table t1 (grp int, a bigint unsigned, c char(10) not null);
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1,1,"a");
Query OK, 1 row affected (0.01 sec)

mysql> select var_pop(distinct grp) from t1;
+-----------------------+
| var_pop(distinct grp) |
+-----------------------+
|                     0 |
+-----------------------+
1 row in set (0.00 sec)
  • MySQL -8.0.19
root@127.0.0.1 : gangshen 02:25:53> create table t1 (grp int, a bigint unsigned, c char(10) not null);
Query OK, 0 rows affected (0.02 sec)

root@127.0.0.1 : gangshen 02:25:57>  insert into t1 values (1,1,"a");
Query OK, 1 row affected (0.00 sec)

root@127.0.0.1 : gangshen 02:26:01> select var_pop(distinct grp) from t1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct grp) from t1' at line 1
  • MySQL 5.7.31:
mysql [localhost:5731] {msandbox} ((none)) > select var_pop(distinct grp) from t1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct grp) from t1' at line 1

2. What did you expect to see? (Required)

select var_pop(distinct xxx) failed. I‘ve refered MySQL docs: link It seems var_pop/stdev func couldn't contains distinct in it.

3. What did you see instead (Required)

It could execute successfully.

4. What is your TiDB version? (Required)

  • nightly

SIG slack channel

#sig-exec

Score

  • 300

Mentor

  • @qw4990

コントリビューターガイド