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

[CBRD-25617] Add sql testcase for When an analytic function is included in a view, the column order number inside the analytic function is incorrect #2008

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions sql/_13_issues/_24_2h/answers/cbrd_25617.answer
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
===================================================
0
===================================================
0
===================================================
4
===================================================
0
===================================================
0
===================================================
0
===================================================
0
===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
rn
1
2
1
2

===================================================
0
===================================================
0
27 changes: 27 additions & 0 deletions sql/_13_issues/_24_2h/cases/cbrd_25617.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-- Verified for CBRD-25617
-- Check whether the problem of column order numbers being incorrectly specified inside analytic functions when a view includes analytic functions has been resolved.

drop table if exists tbl;

create table tbl(cola int auto_increment, colb int, colc int, cold int);
insert into tbl (colb, colc, cold) values (1,1,1),(1,1,2),(1,2,2),(1,2,3);

create or replace view va as select row_number() over(partition by colc) as rn, cola, colb, colc, cold from tbl;
create or replace view vb as select cola, colb, colc, row_number() over(partition by colc) as rn, cold from tbl;
create or replace view vc as select row_number() over(partition by colc order by cold) as rn, cola, colb, colc, cold from tbl;
create or replace view vd as select cola, colb, colc, cold, row_number() over(partition by colc order by cold) as rn from tbl;

select /*+ recompile */ rn from (select row_number() over(partition by colc) as rn, cola, colb, colc, cold from tbl);
select /*+ recompile */ rn from va;

select /*+ recompile */ rn from (select cola, colb, colc, row_number() over(partition by colc) as rn, cold from tbl);
select /*+ recompile */ rn from vb;

select /*+ recompile */ rn from (select row_number() over(partition by colc order by cold) as rn, cola, colb, colc, cold from tbl);
select /*+ recompile */ rn from vc;

select /*+ recompile */ rn from (select cola, colb, colc, cold, row_number() over(partition by colc order by cold) as rn from tbl);
select /*+ recompile */ rn from vd;

drop view va, vb, vc, vd;
drop table tbl;