pingcap / pingcap/tidb

`JSON_ARRAYAGG` report Invalid use of group function

Open
#37,291 2 comments 0 reactions 1 assignee Assigned to @AilinKid View on GitHub
affects-5.4 affects-6.1 affects-6.5 affects-7.1 affects-7.5 affects-8.1 affects-8.5 severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```sql
CREATE TABLE t(a INT);
insert into t values (1);
EXPLAIN SELECT (SELECT 1 FROM t WHERE JSON_ARRAYAGG(1 IN (SELECT 1 FROM t)));
```

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

```
mysql> SELECT (SELECT 1 FROM t WHERE JSON_ARRAYAGG(1 IN (SELECT 1 FROM t)));
+---------------------------------------------------------------+
| (SELECT 1 FROM t WHERE JSON_ARRAYAGG(1 IN (SELECT 1 FROM t))) |
+---------------------------------------------------------------+
| 1 |
+---------------------------------------------------------------+
```

### 3. What did you see instead (Required)

```sql
mysql> SELECT (SELECT 1 FROM t WHERE JSON_ARRAYAGG(1 IN (SELECT 1 FROM t)));
ERROR 1111 (HY000): Invalid use of group function
```

### 4. What is your TiDB version? (Required)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.