Add missing test for depending window functions
In case when one of two adjacent window functions
depend on the output of another WindowNodes should not be merged.
This test covers issue
@@ -3715,6 +3715,24 @@ public abstract class AbstractTestQueries
assertEquals(actual, expected);
}
+ @Test
+ public void testDependentWindows()
+ throws Exception
+ {
+ // For such query as below generated plan has two adjacent window nodes where second depends on output of first.
+
+ String sql = "WITH " +
+ "t1 AS (" +
+ "SELECT extendedprice FROM lineitem ORDER BY orderkey, partkey LIMIT 2)," +
+ "t2 AS (" +
+ "SELECT extendedprice, sum(extendedprice) OVER() AS x FROM t1)," +
+ "t3 AS (" +
+ "SELECT max(x) OVER() FROM t2) " +
+ "SELECT * FROM t3";
+
+ assertQuery(sql, "VALUES 59645.36, 59645.36");
+ }
+
@Test
public void testHaving()
{
