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

[Bug] sql result error #46604

Open
3 tasks
luoyh opened this issue Jan 8, 2025 · 0 comments
Open
3 tasks

[Bug] sql result error #46604

luoyh opened this issue Jan 8, 2025 · 0 comments

Comments

@luoyh
Copy link

luoyh commented Jan 8, 2025

Search before asking

  • I had searched in the issues and found no similar issues.

Version

doris-2.1.6-rc04-653e315ba5

What's Wrong?

mysql> 
with test_with as (
  select 
  id,
  sum(id) over(
    order by id 
    rows between UNBOUNDED PRECEDING and current row
  ) calc,
  ROW_NUMBER() over(order by id desc ) rn
   from (
  select 1 id
  UNION ALL
  select 2 id
  UNION ALL
  select 3 id
  ) t
)
select * from test_with ;
+----+------+----+
| id | calc | rn |
+----+------+----+
|  3 |    6 |  1 |
|  2 |    3 |  2 |
|  1 |    1 |  3 |
+----+------+----+
3 rows in set (0.05 sec)

-- add where rn=1 

mysql> 
with test_with as (
  select 
  id,
  sum(id) over(
    order by id 
    rows between UNBOUNDED PRECEDING and current row
  ) calc,
  ROW_NUMBER() over(order by id desc ) rn
   from (
  select 1 id
  UNION ALL
  select 2 id
  UNION ALL
  select 3 id
  ) t
)
select * from test_with where rn=1;
+----+------+----+
| id | calc | rn |
+----+------+----+
|  3 |    3 |  1 |
+----+------+----+
1 row in set (0.05 sec)

add where rn=1, the result has error.

What You Expected?

the correct result should be:

+----+------+----+
| id | calc | rn |
+----+------+----+
|  3 |    6 |  1 |
+----+------+----+
1 row in set (0.05 sec)

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant