[ 
https://issues.apache.org/jira/browse/DERBY-2998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12568346#action_12568346
 ] 

A B commented on DERBY-2998:
----------------------------

> d2998-11.diff. The patch still needs some polishing, but it works for most 
> basic queries now.

For what it's worth, I applied the patch and played around with some queries 
that include multiple ROW_NUMBER() functions in the same RCL.  In doing so I 
noticed that the following queries all return incorrect results for the third 
column:

create table t1 (i int, j int);
insert into t1 values (1, 0), (1, -1), (2, -2), (3, -3), (4, -4);

select row_number() over(), row_number() over(), i from t1;
select row_number() over(), row_number() over(), 2*i from t1;
select row_number() over(), row_number() over(), j from t1;
select row_number() over(), row_number() over(), 'HMM' from t1;

In all cases the third column returns the same valus as the ROW_NUMBER() 
columns--i.e. the results are:

row_number()        |row_number()        |3
---------------------------------------------
1                   |1                   |1
2                   |2                   |2
3                   |3                   |3
4                   |4                   |4
5                   |5                   |5

5 rows selected

So it looks like the third column is being ignored and/or replaced by a 
row_number() column.

I also noticed that the following query fails with an 
ArrayIndexOutOfBoundsException:

 select row_number() over (), i from t1 order by j desc;

while this one passes (order by "i" instead of "j"):

 select row_number() over (), i from t1 order by i desc;

And the following fails with an ASSERT failure (this might just be DERBY-3310, 
but I thought I'd mention it):

  select * from
    (select row_number() over(), j from t1) x(a,b) where a > 2 order by a desc;

Are these kind of issues ones about which you already know?  If so, then I 
think I'll echo Rick's comment from a short while back: namely, what kind of 
feedback would you like on this patch?

> Add support for ROW_NUMBER() window function
> --------------------------------------------
>
>                 Key: DERBY-2998
>                 URL: https://issues.apache.org/jira/browse/DERBY-2998
>             Project: Derby
>          Issue Type: Sub-task
>          Components: SQL
>            Reporter: Thomas Nielsen
>            Assignee: Thomas Nielsen
>            Priority: Minor
>         Attachments: d2998-10.diff, d2998-10.stat, d2998-11.diff, 
> d2998-4.diff, d2998-4.stat, d2998-5.diff, d2998-5.stat, d2998-6.diff, 
> d2998-6.stat, d2998-7.diff, d2998-7.stat, d2998-8.diff, d2998-8.stat, 
> d2998-9-derby.log, d2998-9.diff, d2998-9.stat, d2998-doc-1.diff, 
> d2998-doc-1.stat, d2998-test.diff, d2998-test.stat, d2998-test2.diff, 
> d2998-test2.stat, d2998-test3.diff, d2998-test3.stat
>
>
> As part of implementing the overall OLAP Operations features of SQL 
> (DERBY-581), implement the ROW_NUMBER() window function.
> More information about this feature is available at 
> http://wiki.apache.org/db-derby/OLAPRowNumber

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to