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

Simple query failed: When alias used as column name and used in ORDER BY #796

Closed
anitajjx opened this issue Sep 22, 2021 · 4 comments
Closed
Assignees
Labels
kind/bug Something isn't working needs-triage priority/p1 Medium priority feature that should be implemented in this version severity/s1 High impact: Logical errors or data errors that must occur
Milestone

Comments

@anitajjx
Copy link
Contributor

Can be reproduced ?

Yes

Steps:

CREATE TABLE t1 (spID int,userID int,score smallint);
INSERT INTO t1 VALUES (1,1,1);
INSERT INTO t1 VALUES (2,2,2);
INSERT INTO t1 VALUES (2,1,4);
INSERT INTO t1 VALUES (3,3,3);
INSERT INTO t1 VALUES (1,1,5);
INSERT INTO t1 VALUES (4,6,10);
INSERT INTO t1 VALUES (5,11,99);

select userID as user_id, spID sp_id from t1 order by user_id, sp_id;

Expected behavior:

mysql> select userID as user_id, spID sp_id from t1 order by user_id, sp_id;
+---------+-------+
| user_id | sp_id |
+---------+-------+
| 1 | 1 |
| 1 | 1 |
| 1 | 2 |
| 2 | 2 |
| 3 | 3 |
| 6 | 4 |
| 11 | 5 |
+---------+-------+
7 rows in set (0.00 sec)

Actual behavior:

mysql> select userID as user_id, spID sp_id from t1 order by user_id, sp_id;
ERROR 1105 (HY000): unknown error:[42000]unknown column 'user_id' in expr

Environment:

  • Version or commit-id (e.g. v0.1.0 or 8b23a93):commit 758c531
  • Hardware parameters:
  • OS type:
  • Others:

Configuration file:

Additional context:

  • Error message from client:
  • Server log:
  • Other information:
@anitajjx anitajjx added kind/bug Something isn't working priority/p1 Medium priority feature that should be implemented in this version needs-triage severity/s1 High impact: Logical errors or data errors that must occur labels Sep 22, 2021
@anitajjx anitajjx added this to the v0.1.0 milestone Sep 22, 2021
@nnsgmsone
Copy link
Contributor

This writing method sql is not currently supported.

@anitajjx
Copy link
Contributor Author

Could you please specify what exactly isn't supported? If it relates to the alias used for a column name, why the following SQL can run successfully?
mysql> select distinct sum(spID) as sum from t1 where score>1 group by userID order by sum asc;
+------+
| sum |
+------+
| 2 |
| 3 |
| 4 |
| 5 |
+------+
4 rows in set (0.02 sec)

@nnsgmsone
Copy link
Contributor

Currently, attributes of order by only aliases of aggregated results are supported, aliases of common projections are not supported, and support will be added later。

@lignay lignay modified the milestones: v0.1.0, v0.2.0 Sep 22, 2021
@JinHai-CN JinHai-CN assigned m-schen and unassigned nnsgmsone Dec 15, 2021
@m-schen
Copy link
Contributor

m-schen commented Dec 15, 2021

this issue is same to #1109

@m-schen m-schen closed this as completed Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working needs-triage priority/p1 Medium priority feature that should be implemented in this version severity/s1 High impact: Logical errors or data errors that must occur
Projects
None yet
Development

No branches or pull requests

4 participants