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

incorrect name resolution for window function in order by clause #8633

Closed
alivxxx opened this issue Dec 10, 2018 · 1 comment
Closed

incorrect name resolution for window function in order by clause #8633

alivxxx opened this issue Dec 10, 2018 · 1 comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@alivxxx
Copy link
Contributor

alivxxx commented Dec 10, 2018

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
create table t	(a int, b int);
explain select a, b as a from t order by (sum(a) over(partition by a));
  1. What did you expect to see?

ERROR 1052 (23000): Column 'a' in window partition by is ambiguous

  1. What did you see instead?

SQL complies successfully.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

#8630

@alivxxx alivxxx added the type/bug The issue is confirmed as a bug. label Dec 10, 2018
@alivxxx alivxxx self-assigned this Dec 10, 2018
@zz-jason zz-jason added the sig/planner SIG: Planner label Mar 6, 2020
@zz-jason
Copy link
Member

It has been fixed in release 4.0:

TiDB(root@127.0.0.1:test) > set @@tidb_enable_window_function = 1;
Query OK, 0 rows affected (0.00 sec)

TiDB(root@127.0.0.1:test) > explain select a, b as a from t order by (sum(a) over(partition by a));
+----------------------------------+----------+-----------+---------------------------------------------------------------------------------+
| id                               | estRows  | task      | operator info                                                                   |
+----------------------------------+----------+-----------+---------------------------------------------------------------------------------+
| Projection_8                     | 10000.00 | root      | test.t.a, test.t.b                                                              |
| └─Sort_9                         | 10000.00 | root      | Column#5:asc                                                                    |
|   └─Shuffle_15                   | 10000.00 | root      | execution info: concurrency:4, data source:TableReader_13                       |
|     └─Window_11                  | 10000.00 | root      | sum(cast(test.t.a, decimal(65,0) BINARY))->Column#5 over(partition by test.t.a) |
|       └─Sort_14                  | 10000.00 | root      | test.t.a:asc                                                                    |
|         └─TableReader_13         | 10000.00 | root      | data:TableFullScan_12                                                           |
|           └─TableFullScan_12     | 10000.00 | cop[tikv] | table:t, keep order:false, stats:pseudo                                         |
+----------------------------------+----------+-----------+---------------------------------------------------------------------------------+
7 rows in set (0.00 sec)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants