Skip to content

Commit

Permalink
TEIID-5477 correcting lead/lag over duplicate values
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 14, 2018
1 parent 8e9c726 commit 15fb88d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ public boolean isRowValueFunction() {
switch (aggregate) {
case NTILE:
case ROW_NUMBER:
case LEAD:
case LAG:
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1270,5 +1270,29 @@ metadata, new DefaultCapabilitiesFinder(caps),

helpProcess(plan, dataManager, expected);
}

@Test public void testLeadOverDuplicates() throws Exception {
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();

String sql = "select e1, lead(e1, 2) over (order by e1 nulls last) from pm1.g1";

ProcessorPlan plan = TestOptimizer.getPlan(helpGetCommand(sql, RealMetadataFactory.example1Cached()),
RealMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(bsc),
null, true, new CommandContext()); //$NON-NLS-1$

FakeDataManager dataManager = new FakeDataManager();
sampleData1(dataManager);

List<?>[] expected = new List<?>[] {
Arrays.asList("a", "a"),
Arrays.asList(null, null),
Arrays.asList("a", "b"),
Arrays.asList("c", null),
Arrays.asList("b", null),
Arrays.asList("a", "c"),
};

helpProcess(plan, dataManager, expected);
}

}

0 comments on commit 15fb88d

Please sign in to comment.