Github user jinfengni commented on a diff in the pull request:

    https://github.com/apache/drill/pull/152#discussion_r39189463
  
    --- Diff: 
exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java ---
    @@ -165,49 +258,182 @@ public void testWindowGroupByOnView() throws 
Exception {
     
       @Test // DRILL-3188
       public void testWindowFrameEquivalentToDefault() throws Exception {
    -    final String query1 = "explain plan for select sum(n_nationKey) 
over(partition by n_nationKey order by n_nationKey) \n" +
    +    final String query1 = "select sum(n_nationKey) over(partition by 
n_nationKey order by n_nationKey) as col\n" +
             "from cp.`tpch/nation.parquet` t \n" +
             "order by n_nationKey";
     
    -    final String query2 = "explain plan for select sum(n_nationKey) 
over(partition by n_nationKey order by n_nationKey \n" +
    -        "range between unbounded preceding and current row) \n" +
    +    final String query2 = "select sum(n_nationKey) over(partition by 
n_nationKey order by n_nationKey \n" +
    +        "range between unbounded preceding and current row) as col \n" +
             "from cp.`tpch/nation.parquet` t \n" +
             "order by n_nationKey";
     
    -    final String query3 = "explain plan for select sum(n_nationKey) 
over(partition by n_nationKey \n" +
    -        "rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)" +
    +    final String query3 = "select sum(n_nationKey) over(partition by 
n_nationKey \n" +
    +        "rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as col 
\n" +
             "from cp.`tpch/nation.parquet` t \n" +
             "order by n_nationKey";
     
    -    test(query1);
    -    test(query2);
    -    test(query3);
    +    // Validate the plan
    +    final String[] expectedPlan1 = {"Window.*partition \\{0\\} order by 
\\[0\\].*SUM\\(\\$0\\)",
    +        "Scan.*columns=\\[`n_nationKey`\\].*"};
    +    final String[] excludedPatterns1 = {"Scan.*columns=\\[`\\*`\\].*"};
    +    PlanTestBase.testPlanMatchingPatterns(query1, expectedPlan1, 
excludedPatterns1);
    +
    +    testBuilder()
    +        .sqlQuery(query1)
    +        .unOrdered()
    +        .baselineColumns("col")
    +        .baselineValues(0l)
    +        .baselineValues(1l)
    +        .baselineValues(2l)
    +        .baselineValues(3l)
    +        .baselineValues(4l)
    +        .baselineValues(5l)
    +        .baselineValues(6l)
    +        .baselineValues(7l)
    +        .baselineValues(8l)
    +        .baselineValues(9l)
    +        .baselineValues(10l)
    +        .baselineValues(11l)
    +        .baselineValues(12l)
    +        .baselineValues(13l)
    +        .baselineValues(14l)
    +        .baselineValues(15l)
    +        .baselineValues(16l)
    +        .baselineValues(17l)
    +        .baselineValues(18l)
    +        .baselineValues(19l)
    +        .baselineValues(20l)
    +        .baselineValues(21l)
    +        .baselineValues(22l)
    +        .baselineValues(23l)
    +        .baselineValues(24l)
    +        .build()
    +        .run();
    +
    +    final String[] expectedPlan2 = {"Window.*partition \\{0\\} order by 
\\[0\\].*SUM\\(\\$0\\)",
    +        "Scan.*columns=\\[`n_nationKey`\\].*"};
    +    final String[] excludedPatterns2 = {"Scan.*columns=\\[`\\*`\\].*"};
    +    PlanTestBase.testPlanMatchingPatterns(query2, expectedPlan2, 
excludedPatterns2);
    +
    +    testBuilder()
    +        .sqlQuery(query2)
    +        .unOrdered()
    +        .baselineColumns("col")
    +        .baselineValues(0l)
    +        .baselineValues(1l)
    +        .baselineValues(2l)
    +        .baselineValues(3l)
    +        .baselineValues(4l)
    +        .baselineValues(5l)
    +        .baselineValues(6l)
    +        .baselineValues(7l)
    +        .baselineValues(8l)
    +        .baselineValues(9l)
    +        .baselineValues(10l)
    +        .baselineValues(11l)
    +        .baselineValues(12l)
    +        .baselineValues(13l)
    +        .baselineValues(14l)
    +        .baselineValues(15l)
    +        .baselineValues(16l)
    +        .baselineValues(17l)
    +        .baselineValues(18l)
    +        .baselineValues(19l)
    +        .baselineValues(20l)
    +        .baselineValues(21l)
    +        .baselineValues(22l)
    +        .baselineValues(23l)
    +        .baselineValues(24l)
    +        .build()
    +        .run();
    +
    +    final String[] expectedPlan3 = {"Window.*partition 
\\{0\\}.*SUM\\(\\$0\\)",
    +        "Scan.*columns=\\[`n_nationKey`\\].*"};
    +    final String[] excludedPatterns3 = {"Scan.*columns=\\[`\\*`\\].*"};
    +    PlanTestBase.testPlanMatchingPatterns(query3, expectedPlan3, 
excludedPatterns3);
    +
    +    testBuilder()
    +        .sqlQuery(query3)
    +        .unOrdered()
    +        .baselineColumns("col")
    +        .baselineValues(0l)
    +        .baselineValues(1l)
    +        .baselineValues(2l)
    +        .baselineValues(3l)
    +        .baselineValues(4l)
    +        .baselineValues(5l)
    +        .baselineValues(6l)
    +        .baselineValues(7l)
    +        .baselineValues(8l)
    +        .baselineValues(9l)
    +        .baselineValues(10l)
    +        .baselineValues(11l)
    +        .baselineValues(12l)
    +        .baselineValues(13l)
    +        .baselineValues(14l)
    +        .baselineValues(15l)
    +        .baselineValues(16l)
    +        .baselineValues(17l)
    +        .baselineValues(18l)
    +        .baselineValues(19l)
    +        .baselineValues(20l)
    +        .baselineValues(21l)
    +        .baselineValues(22l)
    +        .baselineValues(23l)
    +        .baselineValues(24l)
    +        .build()
    +        .run();
       }
     
       @Test // DRILL-3204
       public void testWindowWithJoin() throws Exception {
    -    final String query = "select sum(t1.r_regionKey) over(partition by 
t1.r_regionKey)  \n" +
    +    final String query = "select sum(t1.r_regionKey) over(partition by 
t1.r_regionKey) as col \n" +
             "from cp.`tpch/region.parquet` t1, cp.`tpch/nation.parquet` t2 \n" 
+
             "where t1.r_regionKey = t2.n_nationKey \n" +
             "group by t1.r_regionKey";
     
    -    test(query);
    +    // Validate the plan
    +    final String[] expectedPlan = {"Window.*partition 
\\{0\\}.*SUM\\(\\$0\\)",
    +        "Scan.*columns=\\[`n_nationKey`\\].*",
    +        "Scan.*columns=\\[`n_nationKey`\\].*"};
    +    final String[] excludedPatterns = {"Scan.*columns=\\[`\\*`\\].*"};
    +    PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, 
excludedPatterns);
    +
    +    testBuilder()
    +        .sqlQuery(query)
    +        .unOrdered()
    +        .baselineColumns("col")
    +        .baselineValues(0l)
    +        .baselineValues(1l)
    +        .baselineValues(2l)
    +        .baselineValues(3l)
    +        .baselineValues(4l)
    +        .build()
    +        .run();
       }
     
       @Test // DRILL-3298
       public void testCountEmptyPartitionByWithExchange() throws Exception {
         String query = String.format("select count(*) over (order by 
o_orderpriority) as cnt from dfs.`%s/multilevel/parquet` where o_custkey < 
100", TEST_RES_PATH);
         try {
    +      // Validate the plan
    +      final String[] expectedPlan = {"Window.*partition \\{\\} order by 
\\[0\\].*COUNT\\(\\)",
    +          "Scan.*columns=\\[`o_custkey`, `o_orderpriority`\\]"};
    +      final String[] excludedPatterns = {"Scan.*columns=\\[`\\*`\\]"};
    +      test("alter session set `planner.slice_target` = 1");
    --- End diff --
    
    This line seems to be redundant, since line 430 set the same option, right?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to