[ https://issues.apache.org/jira/browse/DERBY-2998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572498#action_12572498 ]
Thomas Nielsen commented on DERBY-2998: --------------------------------------- The resultset number problem is a little strange. The following query runs fine: select * from (select row_number() over (), t.a from t) as tr; but flip the column order, and it fails: select * from (select t.a, row_number() over () from t) as tr; With both queries we run fine until we eventually end up in ResultColumnList.generateCore() in a call from ProjectRestrictNode.generateMinion() for the PRN that once was the FromSubquery (mentioned earlier). At this stage the RCL for *both* queries look like: RC (resultset# = 3) | .expression= VCN | .sourceColumn = RC (resultset# = -1) | CR | ... (into base table) However - in the working query, the correlate flag is false for the base table columns - in the failing query, the correlate flag is true for the base table columns This was the only obvious difference I could see, and the correlate flag is what causes the logic in RCL.generateCore() to stray off on its "wild path". Looks like I need to investigate why the correlation flag differs between the two. > 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-12.diff, d2998-12.stat, d2998-13.diff, d2998-13.stat, d2998-14.diff, > d2998-14.stat, d2998-15.diff, d2998-15.stat, d2998-16.diff, d2998-16.stat, > 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, d2998-test4.diff, > d2998-test4.stat, d2998-test6.diff, d2998-test7.diff > > > 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.