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's output order is wrong #9806

Closed
winoros opened this issue Mar 19, 2019 · 4 comments
Closed

Window function's output order is wrong #9806

winoros opened this issue Mar 19, 2019 · 4 comments
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@winoros
Copy link
Member

winoros commented Mar 19, 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 `t1` (
  `id` int(11) DEFAULT NULL,
  `sex` char(1) DEFAULT NULL
);
insert into t1 values(1, 'F'), (2, 'M');
SELECT NTILE(2) OVER (ORDER BY sex) FROM t1 ORDER BY id+2 DESC;
  1. What did you expect to see?

execute successfully.

  1. What did you see instead?

panicked

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
@winoros winoros added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner labels Mar 19, 2019
@winoros
Copy link
Member Author

winoros commented Mar 19, 2019

After some investigation, when reading Int value, the column reached to places where stores Char.

@zz-jason
Copy link
Member

Please also post the panic stack in the What did you see instead section

@winoros
Copy link
Member Author

winoros commented Mar 25, 2019

@zz-jason

[2019/03/19 16:53:50.686 +08:00] [WARN] [builder.go:1095] ["build proj exec"] ["column indices"="[0 1 2]"] [columns="[test.t1.sex test.t1.id 5_window_3]"]
[2019/03/19 16:53:50.686 +08:00] [WARN] [builder.go:1095] ["build proj exec"] ["column indices"="[2]"] [columns="[ntile(2) over (order by sex)]"]
[2019/03/19 16:53:50.687 +08:00] [WARN] [row.go:58] ["column data"] ["bytes data"="[70 70 70 77 77]"] ["byte len"=5] ["self len"=7] ["row num"=7] ["all col byte len"="[56,5,56]"]

From the schema, the three column of the projection should be char, int, int. But from the actual data in chunk, the order is int, char, int.
The cause of panic is the output wrong order. So panic stack is useless.

@winoros
Copy link
Member Author

winoros commented Jun 10, 2019

After checking, fixed by #10452

@winoros winoros closed this as completed Jun 10, 2019
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