Skip to content
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

SQL Parser Error: cannot resolve column reference with nested group_concat #18216

Closed
zhangysh1995 opened this issue Jun 25, 2020 · 2 comments · Fixed by #38380
Closed

SQL Parser Error: cannot resolve column reference with nested group_concat #18216

zhangysh1995 opened this issue Jun 25, 2020 · 2 comments · Fixed by #38380
Assignees
Labels
affects-5.3 This bug affects 5.3.x versions. affects-6.1 severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@zhangysh1995
Copy link

zhangysh1995 commented Jun 25, 2020

Bug Report

Preview:

mysql> select group_concat(c order by (select group_concat(c order by a) from t2  where a=t1.a)) from t1;
ERROR 1105 (HY000): Can't find column Column#7 in schema Column: [test.t1.c] Unique key: []

1. Minimal reproduce step (Required)

drop table if exists t1, t2;
create table t1 (a int, c int); 
insert into t1 values (1, 1), (1, 2), (2, 3), (2, 4); 
create table t2 (a int, c int); 
insert into t2 values (1, 1), (1, 2), (2, 3), (2, 4); 
select group_concat(c order by (select group_concat(c order by a) from t2 where a=t1.a)) from t1; 

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

It should execute without error and produce result similar to the following:

-- there are many possible orders regrading the final result
mysql> select group_concat(c order by (select group_concat(c order by a) from t2 where a=t1.a)) from t1;
+-----------------------------------------------------------------------------------+
| group_concat(c order by (select group_concat(c order by a) from t2 where a=t1.a)) |
+-----------------------------------------------------------------------------------+
| 2,1,4,3                                                                           |
+-----------------------------------------------------------------------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

The parser cannot resolve the column name and produces meaningless error message to the user.

4. Affected version (Required)

Master branch

commit 6fa2badf388445f8f91e72b0aad0c217b7fcfb83 (HEAD -> master, origin/master, origin/HEAD)
Author: cfzjywxk <lsswxr@163.com>
Date:   Wed Jun 24 17:43:10 2020 +0800

5. Root Cause Analysis

@zhangysh1995 zhangysh1995 added the type/bug The issue is confirmed as a bug. label Jun 25, 2020
@lhy1024
Copy link

lhy1024 commented Jun 25, 2020

/label component/parser

@yudongusa
Copy link

@fzhedu is there any update of this issue?

@chrysan chrysan assigned AilinKid and unassigned fzhedu Aug 23, 2022
ti-chi-bot pushed a commit that referenced this issue Oct 10, 2022
@VelocityLight VelocityLight added the affects-5.3 This bug affects 5.3.x versions. label Oct 26, 2022
ti-chi-bot pushed a commit that referenced this issue Nov 9, 2022
qw4990 added a commit to qw4990/tidb that referenced this issue Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.3 This bug affects 5.3.x versions. affects-6.1 severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants