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

window function: should check fuction's arguments firstly. #11008

Closed
SunRunAway opened this issue Jul 1, 2019 · 6 comments · Fixed by #11613
Closed

window function: should check fuction's arguments firstly. #11008

SunRunAway opened this issue Jul 1, 2019 · 6 comments · Fixed by #11613
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/bug The issue is confirmed as a bug. type/compatibility

Comments

@SunRunAway
Copy link
Contributor

SunRunAway commented Jul 1, 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.
SELECT NTH_VALUE(fieldA, -1) OVER (w1 PARTITION BY fieldB ORDER BY fieldB , fieldA ) AS 'ntile', fieldA, fieldB FROM ( SELECT `pk` AS fieldA, `col_date_key` AS fieldB FROM `table70_int_autoinc` ) as t WINDOW w1 AS ( ORDER BY fieldB ASC, fieldA DESC );
  1. What did you expect to see?
ERROR 1210 (HY000): Incorrect arguments to nth_value
  1. What did you see instead?
ERROR 3581 (HY000): A window which depends on another cannot define partitioning.
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
@SunRunAway SunRunAway added type/bug The issue is confirmed as a bug. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. type/compatibility labels Jul 1, 2019
@gaoxingliang
Copy link
Contributor

I will look into this issue.

@gaoxingliang
Copy link
Contributor

@SunRunAway
Copy link
Contributor Author

Hi, @gaoxingliang
I think you've misunderstood this issue. nth_value is already implemented but what this issue describes is the error message problem.

@gaoxingliang
Copy link
Contributor

@SunRunAway I test with latest master branch, it shows the correct error message (if you mean the index should be > 0, that's NTH_VALUE(fieldA, -1) , -1 is illegal):
Example:

mysql> SELECT
    ->     employee_name,
    ->     salary,
    ->     NTH_VALUE(employee_name, -1) OVER  (
    ->         ORDER BY salary DESC
    ->     ) second_highest_salary
    -> FROM
    ->     basic_pays;
ERROR 1210 (HY000): Incorrect arguments to nth_value

@SunRunAway
Copy link
Contributor Author

Hi, your test case is different from what this issue describes which a window is depends on another.

@gaoxingliang
Copy link
Contributor

@SunRunAway Okay. now I can reproduce it and I will look more into this.

sre-bot pushed a commit to sre-bot/tidb that referenced this issue Aug 10, 2019
sre-bot pushed a commit to sre-bot/tidb that referenced this issue Aug 10, 2019
sre-bot pushed a commit to sre-bot/tidb that referenced this issue Aug 10, 2019
sre-bot pushed a commit to sre-bot/tidb that referenced this issue Aug 10, 2019
sre-bot pushed a commit to sre-bot/tidb that referenced this issue Aug 10, 2019
sre-bot pushed a commit to sre-bot/tidb that referenced this issue Aug 10, 2019
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. type/bug The issue is confirmed as a bug. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants