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

Column alias might fail in the ORDER BY's subquery clause. #45004

Open
winoros opened this issue Jun 27, 2023 · 2 comments
Open

Column alias might fail in the ORDER BY's subquery clause. #45004

winoros opened this issue Jun 27, 2023 · 2 comments
Assignees
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@winoros
Copy link
Member

winoros commented Jun 27, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT, b INT);
INSERT INTO t1 VALUES (1, 1);
INSERT INTO t2 VALUES (1, 1);

SELECT one.a, one.b as b2 FROM t1 one ORDER BY (SELECT two.b FROM t2 two WHERE two.a = b2);

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

The query was executed successfully.

3. What did you see instead (Required)

Error reported that column b2 in the ORDER BY clause is not found.

4. What is your TiDB version? (Required)

current master

@winoros winoros added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner severity/moderate labels Jun 27, 2023
@winoros
Copy link
Member Author

winoros commented Jun 27, 2023

Note that SELECT one.a, one.b as b2 FROM t1 one ORDER BY (SELECT two.b FROM t2 two WHERE two.a = one.b2) is ok to report error the one.b2 is not found.

@winoros
Copy link
Member Author

winoros commented Jun 28, 2023

This problem will still exist after #45003 is merged.
It's in the same scope with #42732

@hawkingrei hawkingrei self-assigned this Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants