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

Expression inside window should not support legacy position indication #10521

Open
winoros opened this issue May 17, 2019 · 2 comments
Open

Expression inside window should not support legacy position indication #10521

winoros opened this issue May 17, 2019 · 2 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. Priority/P4 Minor issue, awaiting more evidence before prioritizing type/compatibility

Comments

@winoros
Copy link
Member

winoros commented May 17, 2019

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(i INT, j INT, k INT);
SELECT i/SUM(j) OVER (PARTITION BY kk) AS x FROM t;
  1. What did you expect to see?
ERROR HY000: Window '<unnamed window>': ORDER BY or PARTITION BY uses legacy position indication which is not supported, use expression.
  1. What did you see instead?
Unknown column 'i' in 'field list'
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
@winoros winoros added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility labels May 17, 2019
@wjhuang2016
Copy link
Member

mysql> CREATE TABLE t(i INT, j INT, k INT);
Query OK, 0 rows affected (0.06 sec)

mysql> SELECT i/SUM(j) OVER (PARTITION BY kk) AS x FROM t;
ERROR 1054 (42S22): Unknown column 'kk' in 'window partition by'
mysql> SELECT i/SUM(j) OVER (PARTITION BY 1) AS x FROM t;
ERROR 3592 (HY000): Window '<unnamed window>': ORDER BY or PARTITION BY uses legacy position indication which is not supported, use expression.
mysql> SELECT i/SUM(j) OVER (PARTITION BY 0) AS x FROM t;
ERROR 3592 (HY000): Window '<unnamed window>': ORDER BY or PARTITION BY uses legacy position indication which is not supported, use expression.
mysql> SELECT i/SUM(j) OVER (PARTITION BY -1) AS x FROM t;
Empty set (0.00 sec)

@ghost
Copy link

ghost commented Aug 5, 2020

Confirming against master with pasteable testcase:

DROP TABLE IF EXISTS t;
CREATE TABLE t(i INT, j INT, k INT);
SELECT i/SUM(j) OVER (PARTITION BY kk) AS x FROM t;
SELECT i/SUM(j) OVER (PARTITION BY 1) AS x FROM t;
SELECT i/SUM(j) OVER (PARTITION BY 0) AS x FROM t;
SELECT i/SUM(j) OVER (PARTITION BY -1) AS x FROM t;

MySQL 8.0.21:

..
mysql [localhost:8021] {msandbox} (test) > SELECT i/SUM(j) OVER (PARTITION BY kk) AS x FROM t;
ERROR 1054 (42S22): Unknown column 'kk' in 'window partition by'
mysql [localhost:8021] {msandbox} (test) > SELECT i/SUM(j) OVER (PARTITION BY 1) AS x FROM t;
ERROR 3592 (HY000): Window '<unnamed window>': ORDER BY or PARTITION BY uses legacy position indication which is not supported, use expression.
mysql [localhost:8021] {msandbox} (test) > SELECT i/SUM(j) OVER (PARTITION BY 0) AS x FROM t;
ERROR 3592 (HY000): Window '<unnamed window>': ORDER BY or PARTITION BY uses legacy position indication which is not supported, use expression.
mysql [localhost:8021] {msandbox} (test) > SELECT i/SUM(j) OVER (PARTITION BY -1) AS x FROM t;
Empty set (0.00 sec)

TiDB:

..
mysql> SELECT i/SUM(j) OVER (PARTITION BY kk) AS x FROM t;
ERROR 1054 (42S22): Unknown column 'kk' in 'field list'
mysql> SELECT i/SUM(j) OVER (PARTITION BY 1) AS x FROM t;
Empty set (0.01 sec)

mysql> SELECT i/SUM(j) OVER (PARTITION BY 0) AS x FROM t;
ERROR 1054 (42S22): Unknown column '0' in 'field list'
mysql> SELECT i/SUM(j) OVER (PARTITION BY -1) AS x FROM t;
Empty set (0.00 sec)

mysql> 
mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-893-g4e829aaee
Edition: Community
Git Commit Hash: 4e829aaee7b656aa807814708ae05af5233302af
Git Branch: master
UTC Build Time: 2020-08-04 12:40:52
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec)

@ghost ghost added this to Issue Backlog: Need Triage in SIG Runtime Kanban via automation Aug 5, 2020
@ghost ghost added the Priority/P4 Minor issue, awaiting more evidence before prioritizing label Aug 12, 2020
@ghost ghost moved this from Issue Backlog: Need Triage to Backlog: Low Priority in SIG Runtime Kanban Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. Priority/P4 Minor issue, awaiting more evidence before prioritizing type/compatibility
Projects
No open projects
SIG Runtime Kanban
  
Backlog: Low Priority
Development

No branches or pull requests

2 participants