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

unexpected unknown column #24324

Open
XuHuaiyu opened this issue Apr 27, 2021 · 4 comments
Open

unexpected unknown column #24324

XuHuaiyu opened this issue Apr 27, 2021 · 4 comments
Assignees
Labels
sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@XuHuaiyu
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t1 ( id INTEGER, sample_name1 VARCHAR(100), sample_name2 VARCHAR(100), PRIMARY KEY(id) );

INSERT INTO t1 ( id, sample_name1, sample_name2 ) VALUES ( 1, 'aaaa', 'bbbb' ), ( 2, 'cccc', 'dddd' );

(
	SELECT sample_name1 AS testname FROM t1
)
UNION
(
	SELECT sample_name2 AS testname FROM t1 C ORDER BY (SELECT T.sample_name1 FROM t1 T WHERE T.id = C.id)
)
;

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

mysql> (
    -> SELECT sample_name1 AS testname FROM t1
    -> )
    -> UNION
    -> (
    -> SELECT sample_name2 AS testname FROM t1 C ORDER BY (SELECT T.sample_name1 FROM t1 T WHERE T.id = C.id)
    -> )
    -> ;
+----------+
| testname |
+----------+
| aaaa     |
| cccc     |
| bbbb     |
| dddd     |
+----------+
4 rows in set (0.00 sec)

3. What did you see instead (Required)

tidb> (
    -> SELECT sample_name1 AS testname FROM t1
    -> )
    -> UNION
    -> (
    -> SELECT sample_name2 AS testname FROM t1 C ORDER BY (SELECT T.sample_name1 FROM t1 T WHERE T.id = C.id)
    -> )
    -> ;
ERROR 1054 (42S22): Unknown column 'c.id' in 'where clause'

4. What is your TiDB version? (Required)

7e15333 in master

@XuHuaiyu XuHuaiyu added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/major labels Apr 27, 2021
@time-and-fate
Copy link
Member

This issue is very similar to #24444.
From the viewpoint of our implementation, it's more like a feature than a bug fix.
We need to design a plan to support this kind of correlated subquery.
So I prefer to convert it to an enhancement.

@time-and-fate
Copy link
Member

/type enhancement

@ti-chi-bot ti-chi-bot added the type/enhancement The issue or PR belongs to an enhancement. label Aug 20, 2021
@time-and-fate
Copy link
Member

/remove-type bug

@ti-chi-bot ti-chi-bot removed the type/bug The issue is confirmed as a bug. label Aug 20, 2021
@time-and-fate
Copy link
Member

/remove-severity major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants