You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by sm...@apache.org on 2015/06/18 22:13:01 UTC

[2/2] drill git commit: DRILL-3268: queries with empty OVER() clause return empty result set

DRILL-3268: queries with empty OVER() clause return empty result set


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/a027f692
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/a027f692
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/a027f692

Branch: refs/heads/master
Commit: a027f692b3002e2956be2801447cdc3b148f2de1
Parents: 437706f
Author: adeneche <ad...@gmail.com>
Authored: Wed Jun 10 08:21:44 2015 -0700
Committer: Steven Phillips <sm...@apache.org>
Committed: Thu Jun 18 12:50:04 2015 -0700

----------------------------------------------------------------------
 .../impl/window/WindowFrameRecordBatch.java     |  12 +-
 .../physical/impl/window/GenerateTestData.java  | 286 -------------------
 .../physical/impl/window/TestWindowFrame.java   |  82 ++----
 .../src/test/resources/window/b1.p1.oby.tsv     |  20 ++
 .../src/test/resources/window/b1.p1.pby.oby.tsv |  20 ++
 .../src/test/resources/window/b1.p1.pby.tsv     |  20 ++
 .../src/test/resources/window/b1.p1.subs.tsv    |  20 --
 .../src/test/resources/window/b1.p1/0.data.json |  26 +-
 .../src/test/resources/window/b1.p2.oby.tsv     |  20 ++
 .../src/test/resources/window/b1.p2.pby.oby.tsv |  20 ++
 .../src/test/resources/window/b1.p2.pby.tsv     |  20 ++
 .../src/test/resources/window/b1.p2.subs.tsv    |  20 --
 .../src/test/resources/window/b1.p2.tsv         |  40 +--
 .../src/test/resources/window/b1.p2/0.data.json |  34 +--
 .../src/test/resources/window/b2.p2.oby.tsv     |  40 +++
 .../src/test/resources/window/b2.p2.pby.oby.tsv |  40 +++
 .../src/test/resources/window/b2.p2.pby.tsv     |  40 +++
 .../src/test/resources/window/b2.p2.subs.tsv    |  40 ---
 .../src/test/resources/window/b2.p2.tsv         |  80 +++---
 .../src/test/resources/window/b2.p2/0.data.json |  34 +--
 .../src/test/resources/window/b2.p2/1.data.json |  34 +--
 .../src/test/resources/window/b2.p4.oby.tsv     |  40 +++
 .../src/test/resources/window/b2.p4.pby.oby.tsv |  40 +++
 .../src/test/resources/window/b2.p4.pby.tsv     |  40 +++
 .../src/test/resources/window/b2.p4.subs.tsv    |  40 ---
 .../src/test/resources/window/b2.p4.tsv         |  80 +++---
 .../src/test/resources/window/b2.p4/0.data.json |  42 +--
 .../src/test/resources/window/b2.p4/1.data.json |  36 +--
 .../src/test/resources/window/b3.p2.oby.tsv     |  60 ++++
 .../src/test/resources/window/b3.p2.pby.oby.tsv |  60 ++++
 .../src/test/resources/window/b3.p2.pby.tsv     |  60 ++++
 .../src/test/resources/window/b3.p2.subs.tsv    |  60 ----
 .../src/test/resources/window/b3.p2.tsv         | 120 ++++----
 .../src/test/resources/window/b3.p2/0.data.json |  38 +--
 .../src/test/resources/window/b3.p2/1.data.json |  34 +--
 .../src/test/resources/window/b3.p2/2.data.json |  34 +--
 .../src/test/resources/window/b4.p4.oby.tsv     |  80 ++++++
 .../src/test/resources/window/b4.p4.pby.oby.tsv |  80 ++++++
 .../src/test/resources/window/b4.p4.pby.tsv     |  80 ++++++
 .../src/test/resources/window/b4.p4.subs.tsv    |  80 ------
 .../src/test/resources/window/b4.p4.tsv         | 160 +++++------
 .../src/test/resources/window/b4.p4/0.data.json |  42 +--
 .../src/test/resources/window/b4.p4/1.data.json |  36 +--
 .../src/test/resources/window/b4.p4/2.data.json |  38 +--
 .../src/test/resources/window/b4.p4/3.data.json |  36 +--
 exec/java-exec/src/test/resources/window/q1.sql |   2 +-
 exec/java-exec/src/test/resources/window/q2.sql |   2 +-
 47 files changed, 1286 insertions(+), 1082 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/WindowFrameRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/WindowFrameRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/WindowFrameRecordBatch.java
index da189eb..9c8cfc0 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/WindowFrameRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/WindowFrameRecordBatch.java
@@ -190,10 +190,14 @@ public class WindowFrameRecordBatch extends AbstractRecordBatch<WindowPOP> {
             this.schema = incoming.getSchema();
           }
         case OK:
-          batches.add(new WindowDataBatch(incoming, context));
+          if (incoming.getRecordCount() > 0) {
+            batches.add(new WindowDataBatch(incoming, context));
+          } else {
+            logger.trace("incoming has 0 records, it won't be added to batches");
+          }
           break;
         default:
-          throw new UnsupportedOperationException("Unsupported upstrean state " + upstream);
+          throw new UnsupportedOperationException("Unsupported upstream state " + upstream);
       }
     }
 
@@ -241,6 +245,10 @@ public class WindowFrameRecordBatch extends AbstractRecordBatch<WindowPOP> {
     } catch (IOException | ClassTransformationException e) {
       throw new SchemaChangeException("Exception when creating the schema", e);
     }
+
+    if (incoming.getRecordCount() > 0) {
+      batches.add(new WindowDataBatch(incoming, getContext()));
+    }
   }
 
   private WindowFramer createFramer(VectorAccessible batch) throws SchemaChangeException, IOException, ClassTransformationException {

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/GenerateTestData.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/GenerateTestData.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/GenerateTestData.java
deleted file mode 100644
index 623c1e2..0000000
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/GenerateTestData.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.exec.physical.impl.window;
-
-import org.apache.drill.common.util.TestTools;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-public class GenerateTestData {
-  private static final int SUB_MUL = 1;
-  private static final int BATCH_SIZE = 20;
-
-  private static class Partition {
-    Partition previous;
-    final int length;
-    final int[] subs;
-
-    public Partition(int length, int[] subs) {
-      this.length = length;
-      this.subs = subs;
-    }
-
-    /**
-     * @return total number of rows since first partition, this partition included
-     */
-    public int cumulLength() {
-      int prevLength = previous != null ? previous.cumulLength() : 0;
-      return length + prevLength;
-    }
-
-    public boolean isPartOf(int rowNumber) {
-      int prevLength = previous != null ? previous.cumulLength() : 0;
-      return rowNumber >= prevLength && rowNumber < cumulLength();
-    }
-
-    public int getSubIndex(final int sub) {
-      return Arrays.binarySearch(subs, sub);
-    }
-
-    public int getSubSize(int sub) {
-      if (sub != subs[subs.length-1]) {
-        return sub * SUB_MUL;
-      } else {
-        //last sub has enough rows to reach partition length
-        int size = length;
-        for (int i = 0; i < subs.length-1; i++) {
-          size -= subs[i] * SUB_MUL;
-        }
-        return size;
-      }
-    }
-
-    /**
-     * @return sub id of the sub that contains rowNumber
-     */
-    public int getSubId(int rowNumber) {
-      assert isPartOf(rowNumber) : "row "+rowNumber+" isn't part of this partition";
-
-      int prevLength = previous != null ? previous.cumulLength() : 0;
-      rowNumber -= prevLength; // row num from start of this partition
-
-      for (int s : subs) {
-        if (rowNumber < subRunningCount(s)) {
-          return s;
-        }
-      }
-
-      throw new RuntimeException("should never happen!");
-    }
-
-    /**
-     * @return running count of rows from first row of the partition to current sub, this sub included
-     */
-    public int subRunningCount(int sub) {
-      int count = 0;
-      for (int s : subs) {
-        count += getSubSize(s);
-        if (s == sub) {
-          break;
-        }
-      }
-      return count;
-    }
-
-    /**
-     * @return running sum of salaries from first row of the partition to current sub, this sub included
-     */
-    public int subRunningSum(int sub) {
-      int sum = 0;
-      for (int s : subs) {
-        sum += (s+10) * getSubSize(s);
-        if (s == sub) {
-          break;
-        }
-      }
-      return sum;
-    }
-
-    /**
-     * @return sum of salaries for all rows of the partition
-     */
-    public int totalSalary() {
-      return subRunningSum(subs[subs.length-1]);
-    }
-
-  }
-
-  private static Partition[] dataB1P1() {
-    // partition rows 20, subs [1, 2, 3, 4, 5, 6]
-    return new Partition[] {
-      new Partition(20, new int[]{1, 2, 3, 4, 5, 6})
-    };
-  }
-
-  private static Partition[] dataB1P2() {
-    // partition rows 10, subs [1, 2, 3, 4]
-    // partition rows 10, subs [4, 5, 6]
-    return new Partition[] {
-      new Partition(10, new int[]{1, 2, 3, 4}),
-      new Partition(10, new int[]{4, 5, 6}),
-    };
-  }
-
-  private static Partition[] dataB2P2() {
-    // partition rows 20, subs [3, 5, 9]
-    // partition rows 20, subs [9, 10]
-    return new Partition[] {
-      new Partition(20, new int[]{3, 5, 9}),
-      new Partition(20, new int[]{9, 10}),
-    };
-  }
-
-  private static Partition[] dataB2P4() {
-    // partition rows 5, subs [1, 2, 3]
-    // partition rows 10, subs [3, 4, 5]
-    // partition rows 15, subs [5, 6, 7]
-    // partition rows 10, subs [7, 8]
-    return new Partition[] {
-      new Partition(5, new int[]{1, 2, 3}),
-      new Partition(10, new int[]{3, 4, 5}),
-      new Partition(15, new int[]{5, 6, 7}),
-      new Partition(10, new int[]{7, 8}),
-    };
-  }
-
-  private static Partition[] dataB3P2() {
-    // partition rows 5, subs [1, 2, 3]
-    // partition rows 55, subs [4, 5, 7, 8, 9, 10, 11, 12]
-    return new Partition[] {
-      new Partition(5, new int[]{1, 2, 3}),
-      new Partition(55, new int[]{4, 5, 7, 8, 9, 10, 11, 12}),
-    };
-  }
-
-  private static Partition[] dataB4P4() {
-    // partition rows 10, subs [1, 2, 3]
-    // partition rows 30, subs [3, 4, 5, 6, 7, 8]
-    // partition rows 20, subs [8, 9, 10]
-    // partition rows 20, subs [10, 11]
-    return new Partition[] {
-      new Partition(10, new int[]{1, 2, 3}),
-      new Partition(30, new int[]{3, 4, 5, 6, 7, 8}),
-      new Partition(20, new int[]{8, 9, 10}),
-      new Partition(20, new int[]{10, 11}),
-    };
-  }
-
-  private static void generateData(final String tableName, final Partition[] partitions) throws FileNotFoundException {
-    final String WORKING_PATH = TestTools.getWorkingPath();
-    final String TEST_RES_PATH = WORKING_PATH + "/src/test/resources";
-    //TODO command line arguments contain file name
-    final String path = TEST_RES_PATH+"/window/" + tableName;
-
-    final File pathFolder = new File(path);
-    if (!pathFolder.exists()) {
-      if (!pathFolder.mkdirs()) {
-        System.err.printf("Couldn't create folder %s, exiting%n", path);
-      }
-    }
-
-    // expected results for query without order by clause
-    final PrintStream resultStream = new PrintStream(path + ".tsv");
-    // expected results for query with order by clause
-    final PrintStream resultOrderStream = new PrintStream(path + ".subs.tsv");
-
-    // data file(s)
-    int fileId = 0;
-    PrintStream dataStream = new PrintStream(path + "/" + fileId + ".data.json");
-
-    for (Partition p : partitions) {
-      dataStream.printf("// partition rows %d, subs %s%n", p.length, Arrays.toString(p.subs));
-    }
-
-    // set previous partitions
-    for (int i = 1; i < partitions.length; i++) {
-      partitions[i].previous = partitions[i - 1];
-    }
-
-    // total number of rows
-    int total = partitions[partitions.length - 1].cumulLength();
-
-    // create data rows in randome order
-    List<Integer> emp_ids = new ArrayList<>(total);
-    for (int i = 0; i < total; i++) {
-      emp_ids.add(i);
-    }
-    Collections.shuffle(emp_ids);
-
-    int emp_idx = 0;
-    for (int id : emp_ids) {
-      int p = 0;
-      while (!partitions[p].isPartOf(id)) { // emp x is @ row x-1
-        p++;
-      }
-
-      int sub = partitions[p].getSubId(id);
-      int salary = 10 + sub;
-
-      dataStream.printf("{ \"employee_id\":%d, \"position_id\":%d, \"sub\":%d, \"salary\":%d }%n", id, p + 1, sub, salary);
-      emp_idx++;
-      if ((emp_idx % BATCH_SIZE)==0 && emp_idx < total) {
-        System.out.printf("total: %d, emp_idx: %d, fileID: %d%n", total, emp_idx, fileId);
-        dataStream.close();
-        fileId++;
-        dataStream = new PrintStream(path + "/" + fileId + ".data.json");
-      }
-    }
-
-    dataStream.close();
-
-    for (int p = 0, idx = 0; p < partitions.length; p++) {
-      for (int i = 0; i < partitions[p].length; i++, idx++) {
-        final Partition partition = partitions[p]; //TODO change for p loop to for over partitions
-
-        final int sub = partition.getSubId(idx);
-        final int rowNumber = i + 1;
-        final int rank = 1 + partition.subRunningCount(sub) - partition.getSubSize(sub);
-        final int denseRank = partition.getSubIndex(sub) + 1;
-        final double cumeDist = (double) partition.subRunningCount(sub) / partition.length;
-        final double percentRank = partition.length == 1 ? 0 : (double)(rank - 1)/(partition.length - 1);
-
-        // each line has: count(*)  sum(salary)  row_number()  rank()  dense_rank()  cume_dist()  percent_rank()
-        resultOrderStream.printf("%d\t%d\t%d\t%d\t%d\t%s\t%s%n",
-          partition.subRunningCount(sub), partition.subRunningSum(sub),
-          rowNumber, rank, denseRank, Double.toString(cumeDist), Double.toString(percentRank));
-
-        // each line has: count(*)  sum(salary)
-        resultStream.printf("%d\t%d%n", partition.length, partition.totalSalary());
-      }
-    }
-
-    resultStream.close();
-    resultOrderStream.close();
-  }
-
-  public static void main(String[] args) throws FileNotFoundException {
-    generateData("b1.p1", dataB1P1());
-    generateData("b1.p2", dataB1P2());
-    generateData("b2.p2", dataB2P2());
-    generateData("b2.p4", dataB2P4());
-    generateData("b3.p2", dataB3P2());
-    generateData("b4.p4", dataB4P4());
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
index aefe77d..1d6c517 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/window/TestWindowFrame.java
@@ -40,45 +40,44 @@ public class TestWindowFrame extends BaseTestQuery {
     updateTestCluster(1, DrillConfig.create(props));
   }
 
-  private DrillTestWrapper buildWindowQuery(final String tableName) throws Exception {
+  private DrillTestWrapper buildWindowQuery(final String tableName, final boolean withPartitionBy) throws Exception {
     return testBuilder()
-      .sqlQuery(String.format(getFile("window/q1.sql"), TEST_RES_PATH, tableName))
+      .sqlQuery(String.format(getFile("window/q1.sql"), TEST_RES_PATH, tableName, withPartitionBy ? "(partition by position_id)":"()"))
       .ordered()
-      .csvBaselineFile("window/" + tableName + ".tsv")
+      .csvBaselineFile("window/" + tableName + (withPartitionBy ? ".pby" : "") + ".tsv")
       .baselineColumns("count", "sum")
       .build();
   }
 
-  private DrillTestWrapper buildWindowWithOrderByQuery(final String tableName) throws Exception {
+  private DrillTestWrapper buildWindowWithOrderByQuery(final String tableName, final boolean withPartitionBy) throws Exception {
     return testBuilder()
-      .sqlQuery(String.format(getFile("window/q2.sql"), TEST_RES_PATH, tableName))
+      .sqlQuery(String.format(getFile("window/q2.sql"), TEST_RES_PATH, tableName, withPartitionBy ? "(partition by position_id order by sub)":"(order by sub)"))
       .ordered()
-      .csvBaselineFile("window/" + tableName + ".subs.tsv")
+      .csvBaselineFile("window/" + tableName + (withPartitionBy ? ".pby" : "") + ".oby.tsv")
       .baselineColumns("count", "sum", "row_number", "rank", "dense_rank", "cume_dist", "percent_rank")
       .build();
   }
 
-  private void runTest(final String tableName, final boolean withOrderBy) throws Exception {
+  private void runTest(final String tableName, final boolean withPartitionBy, final boolean withOrderBy) throws Exception {
 
     DrillTestWrapper testWrapper = withOrderBy ?
-      buildWindowWithOrderByQuery(tableName) : buildWindowQuery(tableName);
+      buildWindowWithOrderByQuery(tableName, withPartitionBy) : buildWindowQuery(tableName, withPartitionBy);
     testWrapper.run();
   }
 
-  /**
-   * Single batch with a single partition (position_id column)
-   */
-  @Test
-  public void testB1P1() throws Exception {
-    runTest("b1.p1", false);
+  private void runTest(final String tableName) throws Exception {
+    runTest(tableName, true, true);
+    runTest(tableName, true, false);
+    runTest(tableName, false, true);
+    runTest(tableName, false, false);
   }
 
   /**
-   * Single batch with a single partition (position_id column) and multiple sub-partitions (sub column)
+   * Single batch with a single partition (position_id column)
    */
   @Test
-  public void testB1P1OrderBy() throws Exception {
-    runTest("b1.p1", true);
+  public void testB1P1() throws Exception {
+    runTest("b1.p1");
   }
 
   /**
@@ -86,16 +85,7 @@ public class TestWindowFrame extends BaseTestQuery {
    */
   @Test
   public void testB1P2() throws Exception {
-    runTest("b1.p2", false);
-  }
-
-  /**
-   * Single batch with 2 partitions (position_id column)
-   * with order by clause
-   */
-  @Test
-  public void testB1P2OrderBy() throws Exception {
-    runTest("b1.p2", true);
+    runTest("b1.p2");
   }
 
   /**
@@ -103,12 +93,7 @@ public class TestWindowFrame extends BaseTestQuery {
    */
   @Test
   public void testB2P2() throws Exception {
-    runTest("b2.p2", false);
-  }
-
-  @Test
-  public void testB2P2OrderBy() throws Exception {
-    runTest("b2.p2", true);
+    runTest("b2.p2");
   }
 
   /**
@@ -116,16 +101,7 @@ public class TestWindowFrame extends BaseTestQuery {
    */
   @Test
   public void testB2P4() throws Exception {
-    runTest("b2.p4", false);
-  }
-
-  /**
-   * 2 batches with 4 partitions, one partition has rows in both batches
-   * no sub partition has rows in both batches
-   */
-  @Test
-  public void testB2P4OrderBy() throws Exception {
-    runTest("b2.p4", true);
+    runTest("b2.p4");
   }
 
   /**
@@ -133,16 +109,7 @@ public class TestWindowFrame extends BaseTestQuery {
    */
   @Test
   public void testB3P2() throws Exception {
-    runTest("b3.p2", false);
-  }
-
-  /**
-   * 3 batches with 2 partitions, one partition has rows in all 3 batches
-   * 2 subs have rows in 2 batches
-   */
-  @Test
-  public void testB3P2OrderBy() throws Exception {
-    runTest("b3.p2", true);
+    runTest("b3.p2");
   }
 
   /**
@@ -150,13 +117,8 @@ public class TestWindowFrame extends BaseTestQuery {
    * current batch without the need to call next(incoming).
    */
   @Test
-  public void testb4P4() throws Exception {
-    runTest("b4.p4", false);
-  }
-
-  @Test
-  public void testb4P4OrderBy() throws Exception {
-    runTest("b4.p4", true);
+  public void testB4P4() throws Exception {
+    runTest("b4.p4");
   }
 
   @Test // DRILL-1862

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p1.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p1.oby.tsv b/exec/java-exec/src/test/resources/window/b1.p1.oby.tsv
new file mode 100644
index 0000000..8368d4a
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b1.p1.oby.tsv
@@ -0,0 +1,20 @@
+1	11	1	1	1	0.05	0.0
+3	35	2	2	2	0.15	0.05263157894736842
+3	35	3	2	2	0.15	0.05263157894736842
+6	74	4	4	3	0.3	0.15789473684210525
+6	74	5	4	3	0.3	0.15789473684210525
+6	74	6	4	3	0.3	0.15789473684210525
+10	130	7	7	4	0.5	0.3157894736842105
+10	130	8	7	4	0.5	0.3157894736842105
+10	130	9	7	4	0.5	0.3157894736842105
+10	130	10	7	4	0.5	0.3157894736842105
+15	205	11	11	5	0.75	0.5263157894736842
+15	205	12	11	5	0.75	0.5263157894736842
+15	205	13	11	5	0.75	0.5263157894736842
+15	205	14	11	5	0.75	0.5263157894736842
+15	205	15	11	5	0.75	0.5263157894736842
+20	285	16	16	6	1.0	0.7894736842105263
+20	285	17	16	6	1.0	0.7894736842105263
+20	285	18	16	6	1.0	0.7894736842105263
+20	285	19	16	6	1.0	0.7894736842105263
+20	285	20	16	6	1.0	0.7894736842105263

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p1.pby.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p1.pby.oby.tsv b/exec/java-exec/src/test/resources/window/b1.p1.pby.oby.tsv
new file mode 100644
index 0000000..8368d4a
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b1.p1.pby.oby.tsv
@@ -0,0 +1,20 @@
+1	11	1	1	1	0.05	0.0
+3	35	2	2	2	0.15	0.05263157894736842
+3	35	3	2	2	0.15	0.05263157894736842
+6	74	4	4	3	0.3	0.15789473684210525
+6	74	5	4	3	0.3	0.15789473684210525
+6	74	6	4	3	0.3	0.15789473684210525
+10	130	7	7	4	0.5	0.3157894736842105
+10	130	8	7	4	0.5	0.3157894736842105
+10	130	9	7	4	0.5	0.3157894736842105
+10	130	10	7	4	0.5	0.3157894736842105
+15	205	11	11	5	0.75	0.5263157894736842
+15	205	12	11	5	0.75	0.5263157894736842
+15	205	13	11	5	0.75	0.5263157894736842
+15	205	14	11	5	0.75	0.5263157894736842
+15	205	15	11	5	0.75	0.5263157894736842
+20	285	16	16	6	1.0	0.7894736842105263
+20	285	17	16	6	1.0	0.7894736842105263
+20	285	18	16	6	1.0	0.7894736842105263
+20	285	19	16	6	1.0	0.7894736842105263
+20	285	20	16	6	1.0	0.7894736842105263

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p1.pby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p1.pby.tsv b/exec/java-exec/src/test/resources/window/b1.p1.pby.tsv
new file mode 100644
index 0000000..32f6ab7
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b1.p1.pby.tsv
@@ -0,0 +1,20 @@
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p1.subs.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p1.subs.tsv b/exec/java-exec/src/test/resources/window/b1.p1.subs.tsv
deleted file mode 100644
index 8368d4a..0000000
--- a/exec/java-exec/src/test/resources/window/b1.p1.subs.tsv
+++ /dev/null
@@ -1,20 +0,0 @@
-1	11	1	1	1	0.05	0.0
-3	35	2	2	2	0.15	0.05263157894736842
-3	35	3	2	2	0.15	0.05263157894736842
-6	74	4	4	3	0.3	0.15789473684210525
-6	74	5	4	3	0.3	0.15789473684210525
-6	74	6	4	3	0.3	0.15789473684210525
-10	130	7	7	4	0.5	0.3157894736842105
-10	130	8	7	4	0.5	0.3157894736842105
-10	130	9	7	4	0.5	0.3157894736842105
-10	130	10	7	4	0.5	0.3157894736842105
-15	205	11	11	5	0.75	0.5263157894736842
-15	205	12	11	5	0.75	0.5263157894736842
-15	205	13	11	5	0.75	0.5263157894736842
-15	205	14	11	5	0.75	0.5263157894736842
-15	205	15	11	5	0.75	0.5263157894736842
-20	285	16	16	6	1.0	0.7894736842105263
-20	285	17	16	6	1.0	0.7894736842105263
-20	285	18	16	6	1.0	0.7894736842105263
-20	285	19	16	6	1.0	0.7894736842105263
-20	285	20	16	6	1.0	0.7894736842105263

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p1/0.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p1/0.data.json b/exec/java-exec/src/test/resources/window/b1.p1/0.data.json
index cd34641..c6e6761 100644
--- a/exec/java-exec/src/test/resources/window/b1.p1/0.data.json
+++ b/exec/java-exec/src/test/resources/window/b1.p1/0.data.json
@@ -1,21 +1,21 @@
 // partition rows 20, subs [1, 2, 3, 4, 5, 6]
+{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
 { "employee_id":8, "position_id":1, "sub":4, "salary":14 }
-{ "employee_id":7, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":15, "position_id":1, "sub":6, "salary":16 }
 { "employee_id":14, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":16, "position_id":1, "sub":6, "salary":16 }
+{ "employee_id":9, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":6, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":12, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":11, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":1, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":7, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":10, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":19, "position_id":1, "sub":6, "salary":16 }
 { "employee_id":18, "position_id":1, "sub":6, "salary":16 }
 { "employee_id":4, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":17, "position_id":1, "sub":6, "salary":16 }
 { "employee_id":5, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":16, "position_id":1, "sub":6, "salary":16 }
-{ "employee_id":19, "position_id":1, "sub":6, "salary":16 }
 { "employee_id":0, "position_id":1, "sub":1, "salary":11 }
-{ "employee_id":17, "position_id":1, "sub":6, "salary":16 }
-{ "employee_id":12, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
-{ "employee_id":11, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":6, "position_id":1, "sub":4, "salary":14 }
 { "employee_id":13, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":9, "position_id":1, "sub":4, "salary":14 }
-{ "employee_id":15, "position_id":1, "sub":6, "salary":16 }
-{ "employee_id":10, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":1, "position_id":1, "sub":2, "salary":12 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p2.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p2.oby.tsv b/exec/java-exec/src/test/resources/window/b1.p2.oby.tsv
new file mode 100644
index 0000000..8368d4a
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b1.p2.oby.tsv
@@ -0,0 +1,20 @@
+1	11	1	1	1	0.05	0.0
+3	35	2	2	2	0.15	0.05263157894736842
+3	35	3	2	2	0.15	0.05263157894736842
+6	74	4	4	3	0.3	0.15789473684210525
+6	74	5	4	3	0.3	0.15789473684210525
+6	74	6	4	3	0.3	0.15789473684210525
+10	130	7	7	4	0.5	0.3157894736842105
+10	130	8	7	4	0.5	0.3157894736842105
+10	130	9	7	4	0.5	0.3157894736842105
+10	130	10	7	4	0.5	0.3157894736842105
+15	205	11	11	5	0.75	0.5263157894736842
+15	205	12	11	5	0.75	0.5263157894736842
+15	205	13	11	5	0.75	0.5263157894736842
+15	205	14	11	5	0.75	0.5263157894736842
+15	205	15	11	5	0.75	0.5263157894736842
+20	285	16	16	6	1.0	0.7894736842105263
+20	285	17	16	6	1.0	0.7894736842105263
+20	285	18	16	6	1.0	0.7894736842105263
+20	285	19	16	6	1.0	0.7894736842105263
+20	285	20	16	6	1.0	0.7894736842105263

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p2.pby.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p2.pby.oby.tsv b/exec/java-exec/src/test/resources/window/b1.p2.pby.oby.tsv
new file mode 100644
index 0000000..0bf49a7
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b1.p2.pby.oby.tsv
@@ -0,0 +1,20 @@
+1	11	1	1	1	0.1	0.0
+3	35	2	2	2	0.3	0.1111111111111111
+3	35	3	2	2	0.3	0.1111111111111111
+6	74	4	4	3	0.6	0.3333333333333333
+6	74	5	4	3	0.6	0.3333333333333333
+6	74	6	4	3	0.6	0.3333333333333333
+10	130	7	7	4	1.0	0.6666666666666666
+10	130	8	7	4	1.0	0.6666666666666666
+10	130	9	7	4	1.0	0.6666666666666666
+10	130	10	7	4	1.0	0.6666666666666666
+5	75	1	1	1	0.5	0.0
+5	75	2	1	1	0.5	0.0
+5	75	3	1	1	0.5	0.0
+5	75	4	1	1	0.5	0.0
+5	75	5	1	1	0.5	0.0
+10	155	6	6	2	1.0	0.5555555555555556
+10	155	7	6	2	1.0	0.5555555555555556
+10	155	8	6	2	1.0	0.5555555555555556
+10	155	9	6	2	1.0	0.5555555555555556
+10	155	10	6	2	1.0	0.5555555555555556

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p2.pby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p2.pby.tsv b/exec/java-exec/src/test/resources/window/b1.p2.pby.tsv
new file mode 100644
index 0000000..e08355e
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b1.p2.pby.tsv
@@ -0,0 +1,20 @@
+10	130
+10	130
+10	130
+10	130
+10	130
+10	130
+10	130
+10	130
+10	130
+10	130
+10	155
+10	155
+10	155
+10	155
+10	155
+10	155
+10	155
+10	155
+10	155
+10	155

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p2.subs.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p2.subs.tsv b/exec/java-exec/src/test/resources/window/b1.p2.subs.tsv
deleted file mode 100644
index edc4b6a..0000000
--- a/exec/java-exec/src/test/resources/window/b1.p2.subs.tsv
+++ /dev/null
@@ -1,20 +0,0 @@
-1	11	1	1	1	0.1	0.0
-3	35	2	2	2	0.3	0.1111111111111111
-3	35	3	2	2	0.3	0.1111111111111111
-6	74	4	4	3	0.6	0.3333333333333333
-6	74	5	4	3	0.6	0.3333333333333333
-6	74	6	4	3	0.6	0.3333333333333333
-10	130	7	7	4	1.0	0.6666666666666666
-10	130	8	7	4	1.0	0.6666666666666666
-10	130	9	7	4	1.0	0.6666666666666666
-10	130	10	7	4	1.0	0.6666666666666666
-4	56	1	1	1	0.4	0.0
-4	56	2	1	1	0.4	0.0
-4	56	3	1	1	0.4	0.0
-4	56	4	1	1	0.4	0.0
-9	131	5	5	2	0.9	0.4444444444444444
-9	131	6	5	2	0.9	0.4444444444444444
-9	131	7	5	2	0.9	0.4444444444444444
-9	131	8	5	2	0.9	0.4444444444444444
-9	131	9	5	2	0.9	0.4444444444444444
-10	147	10	10	3	1.0	1.0

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p2.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p2.tsv b/exec/java-exec/src/test/resources/window/b1.p2.tsv
index 2bd0010..32f6ab7 100644
--- a/exec/java-exec/src/test/resources/window/b1.p2.tsv
+++ b/exec/java-exec/src/test/resources/window/b1.p2.tsv
@@ -1,20 +1,20 @@
-10	130
-10	130
-10	130
-10	130
-10	130
-10	130
-10	130
-10	130
-10	130
-10	130
-10	147
-10	147
-10	147
-10	147
-10	147
-10	147
-10	147
-10	147
-10	147
-10	147
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285
+20	285

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b1.p2/0.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b1.p2/0.data.json b/exec/java-exec/src/test/resources/window/b1.p2/0.data.json
index b70cf91..dae4015 100644
--- a/exec/java-exec/src/test/resources/window/b1.p2/0.data.json
+++ b/exec/java-exec/src/test/resources/window/b1.p2/0.data.json
@@ -1,22 +1,22 @@
 // partition rows 10, subs [1, 2, 3, 4]
-// partition rows 10, subs [4, 5, 6]
-{ "employee_id":19, "position_id":2, "sub":6, "salary":16 }
-{ "employee_id":7, "position_id":1, "sub":4, "salary":14 }
-{ "employee_id":17, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":9, "position_id":1, "sub":4, "salary":14 }
-{ "employee_id":16, "position_id":2, "sub":5, "salary":15 }
+// partition rows 10, subs [5, 6]
+{ "employee_id":11, "position_id":2, "sub":5, "salary":15 }
 { "employee_id":0, "position_id":1, "sub":1, "salary":11 }
-{ "employee_id":13, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":18, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":10, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
-{ "employee_id":11, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":15, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":4, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":12, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":9, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":7, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":19, "position_id":2, "sub":6, "salary":16 }
 { "employee_id":14, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":6, "position_id":1, "sub":4, "salary":14 }
-{ "employee_id":8, "position_id":1, "sub":4, "salary":14 }
 { "employee_id":1, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":13, "position_id":2, "sub":5, "salary":15 }
 { "employee_id":5, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":6, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":18, "position_id":2, "sub":6, "salary":16 }
+{ "employee_id":15, "position_id":2, "sub":6, "salary":16 }
+{ "employee_id":4, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":16, "position_id":2, "sub":6, "salary":16 }
+{ "employee_id":8, "position_id":1, "sub":4, "salary":14 }
+{ "employee_id":17, "position_id":2, "sub":6, "salary":16 }
+{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":12, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":10, "position_id":2, "sub":5, "salary":15 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2.oby.tsv b/exec/java-exec/src/test/resources/window/b2.p2.oby.tsv
new file mode 100644
index 0000000..43f1201
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b2.p2.oby.tsv
@@ -0,0 +1,40 @@
+3	39	1	1	1	0.075	0.0
+3	39	2	1	1	0.075	0.0
+3	39	3	1	1	0.075	0.0
+8	114	4	4	2	0.2	0.07692307692307693
+8	114	5	4	2	0.2	0.07692307692307693
+8	114	6	4	2	0.2	0.07692307692307693
+8	114	7	4	2	0.2	0.07692307692307693
+8	114	8	4	2	0.2	0.07692307692307693
+20	330	9	9	3	0.5	0.20512820512820512
+20	330	10	9	3	0.5	0.20512820512820512
+20	330	11	9	3	0.5	0.20512820512820512
+20	330	12	9	3	0.5	0.20512820512820512
+20	330	13	9	3	0.5	0.20512820512820512
+20	330	14	9	3	0.5	0.20512820512820512
+20	330	15	9	3	0.5	0.20512820512820512
+20	330	16	9	3	0.5	0.20512820512820512
+20	330	17	9	3	0.5	0.20512820512820512
+20	330	18	9	3	0.5	0.20512820512820512
+20	330	19	9	3	0.5	0.20512820512820512
+20	330	20	9	3	0.5	0.20512820512820512
+29	501	21	21	4	0.725	0.5128205128205128
+29	501	22	21	4	0.725	0.5128205128205128
+29	501	23	21	4	0.725	0.5128205128205128
+29	501	24	21	4	0.725	0.5128205128205128
+29	501	25	21	4	0.725	0.5128205128205128
+29	501	26	21	4	0.725	0.5128205128205128
+29	501	27	21	4	0.725	0.5128205128205128
+29	501	28	21	4	0.725	0.5128205128205128
+29	501	29	21	4	0.725	0.5128205128205128
+40	721	30	30	5	1.0	0.7435897435897436
+40	721	31	30	5	1.0	0.7435897435897436
+40	721	32	30	5	1.0	0.7435897435897436
+40	721	33	30	5	1.0	0.7435897435897436
+40	721	34	30	5	1.0	0.7435897435897436
+40	721	35	30	5	1.0	0.7435897435897436
+40	721	36	30	5	1.0	0.7435897435897436
+40	721	37	30	5	1.0	0.7435897435897436
+40	721	38	30	5	1.0	0.7435897435897436
+40	721	39	30	5	1.0	0.7435897435897436
+40	721	40	30	5	1.0	0.7435897435897436

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2.pby.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2.pby.oby.tsv b/exec/java-exec/src/test/resources/window/b2.p2.pby.oby.tsv
new file mode 100644
index 0000000..dd40f56
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b2.p2.pby.oby.tsv
@@ -0,0 +1,40 @@
+3	39	1	1	1	0.15	0.0
+3	39	2	1	1	0.15	0.0
+3	39	3	1	1	0.15	0.0
+8	114	4	4	2	0.4	0.15789473684210525
+8	114	5	4	2	0.4	0.15789473684210525
+8	114	6	4	2	0.4	0.15789473684210525
+8	114	7	4	2	0.4	0.15789473684210525
+8	114	8	4	2	0.4	0.15789473684210525
+20	330	9	9	3	1.0	0.42105263157894735
+20	330	10	9	3	1.0	0.42105263157894735
+20	330	11	9	3	1.0	0.42105263157894735
+20	330	12	9	3	1.0	0.42105263157894735
+20	330	13	9	3	1.0	0.42105263157894735
+20	330	14	9	3	1.0	0.42105263157894735
+20	330	15	9	3	1.0	0.42105263157894735
+20	330	16	9	3	1.0	0.42105263157894735
+20	330	17	9	3	1.0	0.42105263157894735
+20	330	18	9	3	1.0	0.42105263157894735
+20	330	19	9	3	1.0	0.42105263157894735
+20	330	20	9	3	1.0	0.42105263157894735
+9	171	1	1	1	0.45	0.0
+9	171	2	1	1	0.45	0.0
+9	171	3	1	1	0.45	0.0
+9	171	4	1	1	0.45	0.0
+9	171	5	1	1	0.45	0.0
+9	171	6	1	1	0.45	0.0
+9	171	7	1	1	0.45	0.0
+9	171	8	1	1	0.45	0.0
+9	171	9	1	1	0.45	0.0
+20	391	10	10	2	1.0	0.47368421052631576
+20	391	11	10	2	1.0	0.47368421052631576
+20	391	12	10	2	1.0	0.47368421052631576
+20	391	13	10	2	1.0	0.47368421052631576
+20	391	14	10	2	1.0	0.47368421052631576
+20	391	15	10	2	1.0	0.47368421052631576
+20	391	16	10	2	1.0	0.47368421052631576
+20	391	17	10	2	1.0	0.47368421052631576
+20	391	18	10	2	1.0	0.47368421052631576
+20	391	19	10	2	1.0	0.47368421052631576
+20	391	20	10	2	1.0	0.47368421052631576

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2.pby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2.pby.tsv b/exec/java-exec/src/test/resources/window/b2.p2.pby.tsv
new file mode 100644
index 0000000..7811c85
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b2.p2.pby.tsv
@@ -0,0 +1,40 @@
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	330
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391
+20	391

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2.subs.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2.subs.tsv b/exec/java-exec/src/test/resources/window/b2.p2.subs.tsv
deleted file mode 100644
index 153efaf..0000000
--- a/exec/java-exec/src/test/resources/window/b2.p2.subs.tsv
+++ /dev/null
@@ -1,40 +0,0 @@
-3	39	1	1	1	0.15	0.0
-3	39	2	1	1	0.15	0.0
-3	39	3	1	1	0.15	0.0
-8	114	4	4	2	0.4	0.15789473684210525
-8	114	5	4	2	0.4	0.15789473684210525
-8	114	6	4	2	0.4	0.15789473684210525
-8	114	7	4	2	0.4	0.15789473684210525
-8	114	8	4	2	0.4	0.15789473684210525
-20	342	9	9	3	1.0	0.42105263157894735
-20	342	10	9	3	1.0	0.42105263157894735
-20	342	11	9	3	1.0	0.42105263157894735
-20	342	12	9	3	1.0	0.42105263157894735
-20	342	13	9	3	1.0	0.42105263157894735
-20	342	14	9	3	1.0	0.42105263157894735
-20	342	15	9	3	1.0	0.42105263157894735
-20	342	16	9	3	1.0	0.42105263157894735
-20	342	17	9	3	1.0	0.42105263157894735
-20	342	18	9	3	1.0	0.42105263157894735
-20	342	19	9	3	1.0	0.42105263157894735
-20	342	20	9	3	1.0	0.42105263157894735
-9	171	1	1	1	0.45	0.0
-9	171	2	1	1	0.45	0.0
-9	171	3	1	1	0.45	0.0
-9	171	4	1	1	0.45	0.0
-9	171	5	1	1	0.45	0.0
-9	171	6	1	1	0.45	0.0
-9	171	7	1	1	0.45	0.0
-9	171	8	1	1	0.45	0.0
-9	171	9	1	1	0.45	0.0
-20	391	10	10	2	1.0	0.47368421052631576
-20	391	11	10	2	1.0	0.47368421052631576
-20	391	12	10	2	1.0	0.47368421052631576
-20	391	13	10	2	1.0	0.47368421052631576
-20	391	14	10	2	1.0	0.47368421052631576
-20	391	15	10	2	1.0	0.47368421052631576
-20	391	16	10	2	1.0	0.47368421052631576
-20	391	17	10	2	1.0	0.47368421052631576
-20	391	18	10	2	1.0	0.47368421052631576
-20	391	19	10	2	1.0	0.47368421052631576
-20	391	20	10	2	1.0	0.47368421052631576

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2.tsv b/exec/java-exec/src/test/resources/window/b2.p2.tsv
index 9e62ba7..1f9aae1 100644
--- a/exec/java-exec/src/test/resources/window/b2.p2.tsv
+++ b/exec/java-exec/src/test/resources/window/b2.p2.tsv
@@ -1,40 +1,40 @@
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	342
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
-20	391
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721
+40	721

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2/0.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2/0.data.json b/exec/java-exec/src/test/resources/window/b2.p2/0.data.json
index 3e7efda..7550e15 100644
--- a/exec/java-exec/src/test/resources/window/b2.p2/0.data.json
+++ b/exec/java-exec/src/test/resources/window/b2.p2/0.data.json
@@ -1,22 +1,22 @@
-// partition rows 20, subs [3, 5, 9]
+// partition rows 20, subs [3, 5, 8]
 // partition rows 20, subs [9, 10]
-{ "employee_id":18, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":31, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":39, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":32, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":8, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":34, "position_id":2, "sub":10, "salary":20 }
 { "employee_id":24, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":1, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":10, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":22, "position_id":2, "sub":9, "salary":19 }
 { "employee_id":36, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":15, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":4, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":2, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":11, "position_id":1, "sub":9, "salary":19 }
+{ "employee_id":11, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":27, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":23, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":25, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":8, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":12, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":29, "position_id":2, "sub":10, "salary":20 }
 { "employee_id":33, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":37, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":9, "position_id":1, "sub":9, "salary":19 }
+{ "employee_id":19, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":22, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":31, "position_id":2, "sub":10, "salary":20 }
 { "employee_id":30, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":23, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":35, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":5, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":4, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":16, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":13, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":9, "position_id":1, "sub":8, "salary":18 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p2/1.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p2/1.data.json b/exec/java-exec/src/test/resources/window/b2.p2/1.data.json
index acdd419..a983338 100644
--- a/exec/java-exec/src/test/resources/window/b2.p2/1.data.json
+++ b/exec/java-exec/src/test/resources/window/b2.p2/1.data.json
@@ -1,20 +1,20 @@
-{ "employee_id":27, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":13, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":21, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":0, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":25, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":3, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":5, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":17, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":12, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":29, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":6, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":20, "position_id":2, "sub":9, "salary":19 }
 { "employee_id":7, "position_id":1, "sub":5, "salary":15 }
-{ "employee_id":16, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":35, "position_id":2, "sub":10, "salary":20 }
 { "employee_id":38, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":20, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":19, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":14, "position_id":1, "sub":9, "salary":19 }
-{ "employee_id":28, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":3, "position_id":1, "sub":5, "salary":15 }
+{ "employee_id":15, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":2, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":39, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":37, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":10, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":18, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":17, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":32, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":34, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":1, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":21, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":14, "position_id":1, "sub":8, "salary":18 }
+{ "employee_id":6, "position_id":1, "sub":5, "salary":15 }
 { "employee_id":26, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":0, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":28, "position_id":2, "sub":9, "salary":19 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4.oby.tsv b/exec/java-exec/src/test/resources/window/b2.p4.oby.tsv
new file mode 100644
index 0000000..a18f9d2
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b2.p4.oby.tsv
@@ -0,0 +1,40 @@
+1	11	1	1	1	0.025	0.0
+3	35	2	2	2	0.075	0.02564102564102564
+3	35	3	2	2	0.075	0.02564102564102564
+5	61	4	4	3	0.125	0.07692307692307693
+5	61	5	4	3	0.125	0.07692307692307693
+9	117	6	6	4	0.225	0.1282051282051282
+9	117	7	6	4	0.225	0.1282051282051282
+9	117	8	6	4	0.225	0.1282051282051282
+9	117	9	6	4	0.225	0.1282051282051282
+15	207	10	10	5	0.375	0.23076923076923078
+15	207	11	10	5	0.375	0.23076923076923078
+15	207	12	10	5	0.375	0.23076923076923078
+15	207	13	10	5	0.375	0.23076923076923078
+15	207	14	10	5	0.375	0.23076923076923078
+15	207	15	10	5	0.375	0.23076923076923078
+21	303	16	16	6	0.525	0.38461538461538464
+21	303	17	16	6	0.525	0.38461538461538464
+21	303	18	16	6	0.525	0.38461538461538464
+21	303	19	16	6	0.525	0.38461538461538464
+21	303	20	16	6	0.525	0.38461538461538464
+21	303	21	16	6	0.525	0.38461538461538464
+30	456	22	22	7	0.75	0.5384615384615384
+30	456	23	22	7	0.75	0.5384615384615384
+30	456	24	22	7	0.75	0.5384615384615384
+30	456	25	22	7	0.75	0.5384615384615384
+30	456	26	22	7	0.75	0.5384615384615384
+30	456	27	22	7	0.75	0.5384615384615384
+30	456	28	22	7	0.75	0.5384615384615384
+30	456	29	22	7	0.75	0.5384615384615384
+30	456	30	22	7	0.75	0.5384615384615384
+38	600	31	31	8	0.95	0.7692307692307693
+38	600	32	31	8	0.95	0.7692307692307693
+38	600	33	31	8	0.95	0.7692307692307693
+38	600	34	31	8	0.95	0.7692307692307693
+38	600	35	31	8	0.95	0.7692307692307693
+38	600	36	31	8	0.95	0.7692307692307693
+38	600	37	31	8	0.95	0.7692307692307693
+38	600	38	31	8	0.95	0.7692307692307693
+40	638	39	39	9	1.0	0.9743589743589743
+40	638	40	39	9	1.0	0.9743589743589743

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4.pby.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4.pby.oby.tsv b/exec/java-exec/src/test/resources/window/b2.p4.pby.oby.tsv
new file mode 100644
index 0000000..4b40362
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b2.p4.pby.oby.tsv
@@ -0,0 +1,40 @@
+1	11	1	1	1	0.2	0.0
+3	35	2	2	2	0.6	0.25
+3	35	3	2	2	0.6	0.25
+5	61	4	4	3	1.0	0.75
+5	61	5	4	3	1.0	0.75
+4	56	1	1	1	0.4	0.0
+4	56	2	1	1	0.4	0.0
+4	56	3	1	1	0.4	0.0
+4	56	4	1	1	0.4	0.0
+10	146	5	5	2	1.0	0.4444444444444444
+10	146	6	5	2	1.0	0.4444444444444444
+10	146	7	5	2	1.0	0.4444444444444444
+10	146	8	5	2	1.0	0.4444444444444444
+10	146	9	5	2	1.0	0.4444444444444444
+10	146	10	5	2	1.0	0.4444444444444444
+6	96	1	1	1	0.4	0.0
+6	96	2	1	1	0.4	0.0
+6	96	3	1	1	0.4	0.0
+6	96	4	1	1	0.4	0.0
+6	96	5	1	1	0.4	0.0
+6	96	6	1	1	0.4	0.0
+15	249	7	7	2	1.0	0.42857142857142855
+15	249	8	7	2	1.0	0.42857142857142855
+15	249	9	7	2	1.0	0.42857142857142855
+15	249	10	7	2	1.0	0.42857142857142855
+15	249	11	7	2	1.0	0.42857142857142855
+15	249	12	7	2	1.0	0.42857142857142855
+15	249	13	7	2	1.0	0.42857142857142855
+15	249	14	7	2	1.0	0.42857142857142855
+15	249	15	7	2	1.0	0.42857142857142855
+8	144	1	1	1	0.8	0.0
+8	144	2	1	1	0.8	0.0
+8	144	3	1	1	0.8	0.0
+8	144	4	1	1	0.8	0.0
+8	144	5	1	1	0.8	0.0
+8	144	6	1	1	0.8	0.0
+8	144	7	1	1	0.8	0.0
+8	144	8	1	1	0.8	0.0
+10	182	9	9	2	1.0	0.8888888888888888
+10	182	10	9	2	1.0	0.8888888888888888

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4.pby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4.pby.tsv b/exec/java-exec/src/test/resources/window/b2.p4.pby.tsv
new file mode 100644
index 0000000..f56c256
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b2.p4.pby.tsv
@@ -0,0 +1,40 @@
+5	61
+5	61
+5	61
+5	61
+5	61
+10	146
+10	146
+10	146
+10	146
+10	146
+10	146
+10	146
+10	146
+10	146
+10	146
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+15	249
+10	182
+10	182
+10	182
+10	182
+10	182
+10	182
+10	182
+10	182
+10	182
+10	182

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4.subs.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4.subs.tsv b/exec/java-exec/src/test/resources/window/b2.p4.subs.tsv
deleted file mode 100644
index 62def92..0000000
--- a/exec/java-exec/src/test/resources/window/b2.p4.subs.tsv
+++ /dev/null
@@ -1,40 +0,0 @@
-1	11	1	1	1	0.2	0.0
-3	35	2	2	2	0.6	0.25
-3	35	3	2	2	0.6	0.25
-5	61	4	4	3	1.0	0.75
-5	61	5	4	3	1.0	0.75
-3	39	1	1	1	0.3	0.0
-3	39	2	1	1	0.3	0.0
-3	39	3	1	1	0.3	0.0
-7	95	4	4	2	0.7	0.3333333333333333
-7	95	5	4	2	0.7	0.3333333333333333
-7	95	6	4	2	0.7	0.3333333333333333
-7	95	7	4	2	0.7	0.3333333333333333
-10	140	8	8	3	1.0	0.7777777777777778
-10	140	9	8	3	1.0	0.7777777777777778
-10	140	10	8	3	1.0	0.7777777777777778
-5	75	1	1	1	0.3333333333333333	0.0
-5	75	2	1	1	0.3333333333333333	0.0
-5	75	3	1	1	0.3333333333333333	0.0
-5	75	4	1	1	0.3333333333333333	0.0
-5	75	5	1	1	0.3333333333333333	0.0
-11	171	6	6	2	0.7333333333333333	0.35714285714285715
-11	171	7	6	2	0.7333333333333333	0.35714285714285715
-11	171	8	6	2	0.7333333333333333	0.35714285714285715
-11	171	9	6	2	0.7333333333333333	0.35714285714285715
-11	171	10	6	2	0.7333333333333333	0.35714285714285715
-11	171	11	6	2	0.7333333333333333	0.35714285714285715
-15	239	12	12	3	1.0	0.7857142857142857
-15	239	13	12	3	1.0	0.7857142857142857
-15	239	14	12	3	1.0	0.7857142857142857
-15	239	15	12	3	1.0	0.7857142857142857
-7	119	1	1	1	0.7	0.0
-7	119	2	1	1	0.7	0.0
-7	119	3	1	1	0.7	0.0
-7	119	4	1	1	0.7	0.0
-7	119	5	1	1	0.7	0.0
-7	119	6	1	1	0.7	0.0
-7	119	7	1	1	0.7	0.0
-10	173	8	8	2	1.0	0.7777777777777778
-10	173	9	8	2	1.0	0.7777777777777778
-10	173	10	8	2	1.0	0.7777777777777778

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4.tsv b/exec/java-exec/src/test/resources/window/b2.p4.tsv
index a9302c6..768e7bc 100644
--- a/exec/java-exec/src/test/resources/window/b2.p4.tsv
+++ b/exec/java-exec/src/test/resources/window/b2.p4.tsv
@@ -1,40 +1,40 @@
-5	61
-5	61
-5	61
-5	61
-5	61
-10	140
-10	140
-10	140
-10	140
-10	140
-10	140
-10	140
-10	140
-10	140
-10	140
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-15	239
-10	173
-10	173
-10	173
-10	173
-10	173
-10	173
-10	173
-10	173
-10	173
-10	173
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638
+40	638

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4/0.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4/0.data.json b/exec/java-exec/src/test/resources/window/b2.p4/0.data.json
index 02da7b8..4f083ca 100644
--- a/exec/java-exec/src/test/resources/window/b2.p4/0.data.json
+++ b/exec/java-exec/src/test/resources/window/b2.p4/0.data.json
@@ -1,24 +1,24 @@
 // partition rows 5, subs [1, 2, 3]
-// partition rows 10, subs [3, 4, 5]
-// partition rows 15, subs [5, 6, 7]
-// partition rows 10, subs [7, 8]
-{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":31, "position_id":4, "sub":7, "salary":17 }
-{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
-{ "employee_id":37, "position_id":4, "sub":8, "salary":18 }
-{ "employee_id":13, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":15, "position_id":3, "sub":5, "salary":15 }
-{ "employee_id":26, "position_id":3, "sub":7, "salary":17 }
-{ "employee_id":38, "position_id":4, "sub":8, "salary":18 }
-{ "employee_id":4, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":16, "position_id":3, "sub":5, "salary":15 }
-{ "employee_id":21, "position_id":3, "sub":6, "salary":16 }
-{ "employee_id":12, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":29, "position_id":3, "sub":7, "salary":17 }
-{ "employee_id":5, "position_id":2, "sub":3, "salary":13 }
+// partition rows 10, subs [4, 5]
+// partition rows 15, subs [6, 7]
+// partition rows 10, subs [8, 9]
+{ "employee_id":5, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":17, "position_id":3, "sub":6, "salary":16 }
+{ "employee_id":38, "position_id":4, "sub":9, "salary":19 }
+{ "employee_id":1, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":35, "position_id":4, "sub":8, "salary":18 }
+{ "employee_id":15, "position_id":3, "sub":6, "salary":16 }
+{ "employee_id":30, "position_id":4, "sub":8, "salary":18 }
+{ "employee_id":0, "position_id":1, "sub":1, "salary":11 }
+{ "employee_id":34, "position_id":4, "sub":8, "salary":18 }
+{ "employee_id":36, "position_id":4, "sub":8, "salary":18 }
 { "employee_id":14, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":30, "position_id":4, "sub":7, "salary":17 }
+{ "employee_id":16, "position_id":3, "sub":6, "salary":16 }
+{ "employee_id":9, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":23, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":32, "position_id":4, "sub":8, "salary":18 }
+{ "employee_id":11, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":33, "position_id":4, "sub":8, "salary":18 }
+{ "employee_id":25, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":7, "position_id":2, "sub":4, "salary":14 }
 { "employee_id":27, "position_id":3, "sub":7, "salary":17 }
-{ "employee_id":10, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":33, "position_id":4, "sub":7, "salary":17 }
-{ "employee_id":6, "position_id":2, "sub":3, "salary":13 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b2.p4/1.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b2.p4/1.data.json b/exec/java-exec/src/test/resources/window/b2.p4/1.data.json
index 3ed76af..9326d00 100644
--- a/exec/java-exec/src/test/resources/window/b2.p4/1.data.json
+++ b/exec/java-exec/src/test/resources/window/b2.p4/1.data.json
@@ -1,20 +1,20 @@
-{ "employee_id":1, "position_id":1, "sub":2, "salary":12 }
-{ "employee_id":36, "position_id":4, "sub":7, "salary":17 }
-{ "employee_id":19, "position_id":3, "sub":5, "salary":15 }
-{ "employee_id":22, "position_id":3, "sub":6, "salary":16 }
-{ "employee_id":34, "position_id":4, "sub":7, "salary":17 }
-{ "employee_id":11, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":23, "position_id":3, "sub":6, "salary":16 }
-{ "employee_id":9, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":22, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":19, "position_id":3, "sub":6, "salary":16 }
+{ "employee_id":39, "position_id":4, "sub":9, "salary":19 }
+{ "employee_id":21, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":10, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":20, "position_id":3, "sub":6, "salary":16 }
+{ "employee_id":13, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":18, "position_id":3, "sub":6, "salary":16 }
+{ "employee_id":31, "position_id":4, "sub":8, "salary":18 }
 { "employee_id":28, "position_id":3, "sub":7, "salary":17 }
-{ "employee_id":18, "position_id":3, "sub":5, "salary":15 }
-{ "employee_id":32, "position_id":4, "sub":7, "salary":17 }
+{ "employee_id":37, "position_id":4, "sub":8, "salary":18 }
 { "employee_id":8, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":17, "position_id":3, "sub":5, "salary":15 }
-{ "employee_id":0, "position_id":1, "sub":1, "salary":11 }
-{ "employee_id":39, "position_id":4, "sub":8, "salary":18 }
-{ "employee_id":20, "position_id":3, "sub":6, "salary":16 }
-{ "employee_id":25, "position_id":3, "sub":6, "salary":16 }
-{ "employee_id":24, "position_id":3, "sub":6, "salary":16 }
-{ "employee_id":35, "position_id":4, "sub":7, "salary":17 }
-{ "employee_id":7, "position_id":2, "sub":3, "salary":13 }
+{ "employee_id":6, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":12, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":29, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":4, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":24, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":26, "position_id":3, "sub":7, "salary":17 }
+{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2.oby.tsv b/exec/java-exec/src/test/resources/window/b3.p2.oby.tsv
new file mode 100644
index 0000000..2008962
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b3.p2.oby.tsv
@@ -0,0 +1,60 @@
+1	11	1	1	1	0.016666666666666666	0.0
+3	35	2	2	2	0.05	0.01694915254237288
+3	35	3	2	2	0.05	0.01694915254237288
+5	61	4	4	3	0.08333333333333333	0.05084745762711865
+5	61	5	4	3	0.08333333333333333	0.05084745762711865
+9	117	6	6	4	0.15	0.0847457627118644
+9	117	7	6	4	0.15	0.0847457627118644
+9	117	8	6	4	0.15	0.0847457627118644
+9	117	9	6	4	0.15	0.0847457627118644
+14	192	10	10	5	0.23333333333333334	0.15254237288135594
+14	192	11	10	5	0.23333333333333334	0.15254237288135594
+14	192	12	10	5	0.23333333333333334	0.15254237288135594
+14	192	13	10	5	0.23333333333333334	0.15254237288135594
+14	192	14	10	5	0.23333333333333334	0.15254237288135594
+21	311	15	15	6	0.35	0.23728813559322035
+21	311	16	15	6	0.35	0.23728813559322035
+21	311	17	15	6	0.35	0.23728813559322035
+21	311	18	15	6	0.35	0.23728813559322035
+21	311	19	15	6	0.35	0.23728813559322035
+21	311	20	15	6	0.35	0.23728813559322035
+21	311	21	15	6	0.35	0.23728813559322035
+29	455	22	22	7	0.48333333333333334	0.3559322033898305
+29	455	23	22	7	0.48333333333333334	0.3559322033898305
+29	455	24	22	7	0.48333333333333334	0.3559322033898305
+29	455	25	22	7	0.48333333333333334	0.3559322033898305
+29	455	26	22	7	0.48333333333333334	0.3559322033898305
+29	455	27	22	7	0.48333333333333334	0.3559322033898305
+29	455	28	22	7	0.48333333333333334	0.3559322033898305
+29	455	29	22	7	0.48333333333333334	0.3559322033898305
+38	626	30	30	8	0.6333333333333333	0.4915254237288136
+38	626	31	30	8	0.6333333333333333	0.4915254237288136
+38	626	32	30	8	0.6333333333333333	0.4915254237288136
+38	626	33	30	8	0.6333333333333333	0.4915254237288136
+38	626	34	30	8	0.6333333333333333	0.4915254237288136
+38	626	35	30	8	0.6333333333333333	0.4915254237288136
+38	626	36	30	8	0.6333333333333333	0.4915254237288136
+38	626	37	30	8	0.6333333333333333	0.4915254237288136
+38	626	38	30	8	0.6333333333333333	0.4915254237288136
+48	826	39	39	9	0.8	0.6440677966101694
+48	826	40	39	9	0.8	0.6440677966101694
+48	826	41	39	9	0.8	0.6440677966101694
+48	826	42	39	9	0.8	0.6440677966101694
+48	826	43	39	9	0.8	0.6440677966101694
+48	826	44	39	9	0.8	0.6440677966101694
+48	826	45	39	9	0.8	0.6440677966101694
+48	826	46	39	9	0.8	0.6440677966101694
+48	826	47	39	9	0.8	0.6440677966101694
+48	826	48	39	9	0.8	0.6440677966101694
+59	1057	49	49	10	0.9833333333333333	0.8135593220338984
+59	1057	50	49	10	0.9833333333333333	0.8135593220338984
+59	1057	51	49	10	0.9833333333333333	0.8135593220338984
+59	1057	52	49	10	0.9833333333333333	0.8135593220338984
+59	1057	53	49	10	0.9833333333333333	0.8135593220338984
+59	1057	54	49	10	0.9833333333333333	0.8135593220338984
+59	1057	55	49	10	0.9833333333333333	0.8135593220338984
+59	1057	56	49	10	0.9833333333333333	0.8135593220338984
+59	1057	57	49	10	0.9833333333333333	0.8135593220338984
+59	1057	58	49	10	0.9833333333333333	0.8135593220338984
+59	1057	59	49	10	0.9833333333333333	0.8135593220338984
+60	1079	60	60	11	1.0	1.0

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2.pby.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2.pby.oby.tsv b/exec/java-exec/src/test/resources/window/b3.p2.pby.oby.tsv
new file mode 100644
index 0000000..3e735aa
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b3.p2.pby.oby.tsv
@@ -0,0 +1,60 @@
+1	11	1	1	1	0.2	0.0
+3	35	2	2	2	0.6	0.25
+3	35	3	2	2	0.6	0.25
+5	61	4	4	3	1.0	0.75
+5	61	5	4	3	1.0	0.75
+4	56	1	1	1	0.07272727272727272	0.0
+4	56	2	1	1	0.07272727272727272	0.0
+4	56	3	1	1	0.07272727272727272	0.0
+4	56	4	1	1	0.07272727272727272	0.0
+9	131	5	5	2	0.16363636363636364	0.07407407407407407
+9	131	6	5	2	0.16363636363636364	0.07407407407407407
+9	131	7	5	2	0.16363636363636364	0.07407407407407407
+9	131	8	5	2	0.16363636363636364	0.07407407407407407
+9	131	9	5	2	0.16363636363636364	0.07407407407407407
+16	250	10	10	3	0.2909090909090909	0.16666666666666666
+16	250	11	10	3	0.2909090909090909	0.16666666666666666
+16	250	12	10	3	0.2909090909090909	0.16666666666666666
+16	250	13	10	3	0.2909090909090909	0.16666666666666666
+16	250	14	10	3	0.2909090909090909	0.16666666666666666
+16	250	15	10	3	0.2909090909090909	0.16666666666666666
+16	250	16	10	3	0.2909090909090909	0.16666666666666666
+24	394	17	17	4	0.43636363636363634	0.2962962962962963
+24	394	18	17	4	0.43636363636363634	0.2962962962962963
+24	394	19	17	4	0.43636363636363634	0.2962962962962963
+24	394	20	17	4	0.43636363636363634	0.2962962962962963
+24	394	21	17	4	0.43636363636363634	0.2962962962962963
+24	394	22	17	4	0.43636363636363634	0.2962962962962963
+24	394	23	17	4	0.43636363636363634	0.2962962962962963
+24	394	24	17	4	0.43636363636363634	0.2962962962962963
+33	565	25	25	5	0.6	0.4444444444444444
+33	565	26	25	5	0.6	0.4444444444444444
+33	565	27	25	5	0.6	0.4444444444444444
+33	565	28	25	5	0.6	0.4444444444444444
+33	565	29	25	5	0.6	0.4444444444444444
+33	565	30	25	5	0.6	0.4444444444444444
+33	565	31	25	5	0.6	0.4444444444444444
+33	565	32	25	5	0.6	0.4444444444444444
+33	565	33	25	5	0.6	0.4444444444444444
+43	765	34	34	6	0.7818181818181819	0.6111111111111112
+43	765	35	34	6	0.7818181818181819	0.6111111111111112
+43	765	36	34	6	0.7818181818181819	0.6111111111111112
+43	765	37	34	6	0.7818181818181819	0.6111111111111112
+43	765	38	34	6	0.7818181818181819	0.6111111111111112
+43	765	39	34	6	0.7818181818181819	0.6111111111111112
+43	765	40	34	6	0.7818181818181819	0.6111111111111112
+43	765	41	34	6	0.7818181818181819	0.6111111111111112
+43	765	42	34	6	0.7818181818181819	0.6111111111111112
+43	765	43	34	6	0.7818181818181819	0.6111111111111112
+54	996	44	44	7	0.9818181818181818	0.7962962962962963
+54	996	45	44	7	0.9818181818181818	0.7962962962962963
+54	996	46	44	7	0.9818181818181818	0.7962962962962963
+54	996	47	44	7	0.9818181818181818	0.7962962962962963
+54	996	48	44	7	0.9818181818181818	0.7962962962962963
+54	996	49	44	7	0.9818181818181818	0.7962962962962963
+54	996	50	44	7	0.9818181818181818	0.7962962962962963
+54	996	51	44	7	0.9818181818181818	0.7962962962962963
+54	996	52	44	7	0.9818181818181818	0.7962962962962963
+54	996	53	44	7	0.9818181818181818	0.7962962962962963
+54	996	54	44	7	0.9818181818181818	0.7962962962962963
+55	1018	55	55	8	1.0	1.0

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2.pby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2.pby.tsv b/exec/java-exec/src/test/resources/window/b3.p2.pby.tsv
new file mode 100644
index 0000000..ef32c2e
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b3.p2.pby.tsv
@@ -0,0 +1,60 @@
+5	61
+5	61
+5	61
+5	61
+5	61
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018
+55	1018

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2.subs.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2.subs.tsv b/exec/java-exec/src/test/resources/window/b3.p2.subs.tsv
deleted file mode 100644
index 3e735aa..0000000
--- a/exec/java-exec/src/test/resources/window/b3.p2.subs.tsv
+++ /dev/null
@@ -1,60 +0,0 @@
-1	11	1	1	1	0.2	0.0
-3	35	2	2	2	0.6	0.25
-3	35	3	2	2	0.6	0.25
-5	61	4	4	3	1.0	0.75
-5	61	5	4	3	1.0	0.75
-4	56	1	1	1	0.07272727272727272	0.0
-4	56	2	1	1	0.07272727272727272	0.0
-4	56	3	1	1	0.07272727272727272	0.0
-4	56	4	1	1	0.07272727272727272	0.0
-9	131	5	5	2	0.16363636363636364	0.07407407407407407
-9	131	6	5	2	0.16363636363636364	0.07407407407407407
-9	131	7	5	2	0.16363636363636364	0.07407407407407407
-9	131	8	5	2	0.16363636363636364	0.07407407407407407
-9	131	9	5	2	0.16363636363636364	0.07407407407407407
-16	250	10	10	3	0.2909090909090909	0.16666666666666666
-16	250	11	10	3	0.2909090909090909	0.16666666666666666
-16	250	12	10	3	0.2909090909090909	0.16666666666666666
-16	250	13	10	3	0.2909090909090909	0.16666666666666666
-16	250	14	10	3	0.2909090909090909	0.16666666666666666
-16	250	15	10	3	0.2909090909090909	0.16666666666666666
-16	250	16	10	3	0.2909090909090909	0.16666666666666666
-24	394	17	17	4	0.43636363636363634	0.2962962962962963
-24	394	18	17	4	0.43636363636363634	0.2962962962962963
-24	394	19	17	4	0.43636363636363634	0.2962962962962963
-24	394	20	17	4	0.43636363636363634	0.2962962962962963
-24	394	21	17	4	0.43636363636363634	0.2962962962962963
-24	394	22	17	4	0.43636363636363634	0.2962962962962963
-24	394	23	17	4	0.43636363636363634	0.2962962962962963
-24	394	24	17	4	0.43636363636363634	0.2962962962962963
-33	565	25	25	5	0.6	0.4444444444444444
-33	565	26	25	5	0.6	0.4444444444444444
-33	565	27	25	5	0.6	0.4444444444444444
-33	565	28	25	5	0.6	0.4444444444444444
-33	565	29	25	5	0.6	0.4444444444444444
-33	565	30	25	5	0.6	0.4444444444444444
-33	565	31	25	5	0.6	0.4444444444444444
-33	565	32	25	5	0.6	0.4444444444444444
-33	565	33	25	5	0.6	0.4444444444444444
-43	765	34	34	6	0.7818181818181819	0.6111111111111112
-43	765	35	34	6	0.7818181818181819	0.6111111111111112
-43	765	36	34	6	0.7818181818181819	0.6111111111111112
-43	765	37	34	6	0.7818181818181819	0.6111111111111112
-43	765	38	34	6	0.7818181818181819	0.6111111111111112
-43	765	39	34	6	0.7818181818181819	0.6111111111111112
-43	765	40	34	6	0.7818181818181819	0.6111111111111112
-43	765	41	34	6	0.7818181818181819	0.6111111111111112
-43	765	42	34	6	0.7818181818181819	0.6111111111111112
-43	765	43	34	6	0.7818181818181819	0.6111111111111112
-54	996	44	44	7	0.9818181818181818	0.7962962962962963
-54	996	45	44	7	0.9818181818181818	0.7962962962962963
-54	996	46	44	7	0.9818181818181818	0.7962962962962963
-54	996	47	44	7	0.9818181818181818	0.7962962962962963
-54	996	48	44	7	0.9818181818181818	0.7962962962962963
-54	996	49	44	7	0.9818181818181818	0.7962962962962963
-54	996	50	44	7	0.9818181818181818	0.7962962962962963
-54	996	51	44	7	0.9818181818181818	0.7962962962962963
-54	996	52	44	7	0.9818181818181818	0.7962962962962963
-54	996	53	44	7	0.9818181818181818	0.7962962962962963
-54	996	54	44	7	0.9818181818181818	0.7962962962962963
-55	1018	55	55	8	1.0	1.0

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2.tsv b/exec/java-exec/src/test/resources/window/b3.p2.tsv
index ef32c2e..ad58956 100644
--- a/exec/java-exec/src/test/resources/window/b3.p2.tsv
+++ b/exec/java-exec/src/test/resources/window/b3.p2.tsv
@@ -1,60 +1,60 @@
-5	61
-5	61
-5	61
-5	61
-5	61
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
-55	1018
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079
+60	1079

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2/0.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2/0.data.json b/exec/java-exec/src/test/resources/window/b3.p2/0.data.json
index 39e285f..912c203 100644
--- a/exec/java-exec/src/test/resources/window/b3.p2/0.data.json
+++ b/exec/java-exec/src/test/resources/window/b3.p2/0.data.json
@@ -1,22 +1,22 @@
 // partition rows 5, subs [1, 2, 3]
 // partition rows 55, subs [4, 5, 7, 8, 9, 10, 11, 12]
-{ "employee_id":56, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":42, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":53, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":28, "position_id":2, "sub":8, "salary":18 }
-{ "employee_id":33, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":25, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":58, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":0, "position_id":1, "sub":1, "salary":11 }
+{ "employee_id":29, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":36, "position_id":2, "sub":9, "salary":19 }
 { "employee_id":23, "position_id":2, "sub":8, "salary":18 }
-{ "employee_id":41, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":50, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":27, "position_id":2, "sub":8, "salary":18 }
-{ "employee_id":35, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":54, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":4, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":9, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":15, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":13, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":31, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":12, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":57, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":45, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":46, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":10, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":49, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":5, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":38, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":24, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":47, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":43, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":51, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":32, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":17, "position_id":2, "sub":7, "salary":17 }
+{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
+{ "employee_id":19, "position_id":2, "sub":7, "salary":17 }
+{ "employee_id":7, "position_id":2, "sub":4, "salary":14 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2/1.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2/1.data.json b/exec/java-exec/src/test/resources/window/b3.p2/1.data.json
index 1d92e1a..52a8daf 100644
--- a/exec/java-exec/src/test/resources/window/b3.p2/1.data.json
+++ b/exec/java-exec/src/test/resources/window/b3.p2/1.data.json
@@ -1,20 +1,20 @@
-{ "employee_id":26, "position_id":2, "sub":8, "salary":18 }
-{ "employee_id":6, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":19, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":7, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":51, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":47, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":13, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":20, "position_id":2, "sub":7, "salary":17 }
+{ "employee_id":42, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":59, "position_id":2, "sub":12, "salary":22 }
+{ "employee_id":35, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":4, "position_id":1, "sub":3, "salary":13 }
 { "employee_id":21, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":56, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":8, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":57, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":28, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":22, "position_id":2, "sub":8, "salary":18 }
 { "employee_id":44, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":46, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":59, "position_id":2, "sub":12, "salary":22 }
-{ "employee_id":36, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":30, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":1, "position_id":1, "sub":2, "salary":12 }
-{ "employee_id":5, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":52, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":41, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":27, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":6, "position_id":2, "sub":4, "salary":14 }
+{ "employee_id":14, "position_id":2, "sub":7, "salary":17 }
 { "employee_id":40, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":32, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":11, "position_id":2, "sub":5, "salary":15 }
-{ "employee_id":0, "position_id":1, "sub":1, "salary":11 }
-{ "employee_id":49, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":48, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":26, "position_id":2, "sub":8, "salary":18 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b3.p2/2.data.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b3.p2/2.data.json b/exec/java-exec/src/test/resources/window/b3.p2/2.data.json
index e0f5f3c..1ca3e1d 100644
--- a/exec/java-exec/src/test/resources/window/b3.p2/2.data.json
+++ b/exec/java-exec/src/test/resources/window/b3.p2/2.data.json
@@ -1,20 +1,20 @@
-{ "employee_id":43, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":18, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":52, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":29, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":8, "position_id":2, "sub":4, "salary":14 }
-{ "employee_id":58, "position_id":2, "sub":11, "salary":21 }
 { "employee_id":55, "position_id":2, "sub":11, "salary":21 }
-{ "employee_id":16, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":14, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":20, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":37, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":38, "position_id":2, "sub":10, "salary":20 }
-{ "employee_id":17, "position_id":2, "sub":7, "salary":17 }
-{ "employee_id":2, "position_id":1, "sub":2, "salary":12 }
-{ "employee_id":22, "position_id":2, "sub":8, "salary":18 }
-{ "employee_id":24, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":53, "position_id":2, "sub":11, "salary":21 }
 { "employee_id":39, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":12, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":50, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":30, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":15, "position_id":2, "sub":7, "salary":17 }
+{ "employee_id":31, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":45, "position_id":2, "sub":10, "salary":20 }
+{ "employee_id":54, "position_id":2, "sub":11, "salary":21 }
 { "employee_id":34, "position_id":2, "sub":9, "salary":19 }
-{ "employee_id":3, "position_id":1, "sub":3, "salary":13 }
-{ "employee_id":10, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":25, "position_id":2, "sub":8, "salary":18 }
+{ "employee_id":16, "position_id":2, "sub":7, "salary":17 }
+{ "employee_id":1, "position_id":1, "sub":2, "salary":12 }
+{ "employee_id":48, "position_id":2, "sub":11, "salary":21 }
+{ "employee_id":9, "position_id":2, "sub":5, "salary":15 }
+{ "employee_id":37, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":33, "position_id":2, "sub":9, "salary":19 }
+{ "employee_id":18, "position_id":2, "sub":7, "salary":17 }
+{ "employee_id":11, "position_id":2, "sub":5, "salary":15 }

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b4.p4.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b4.p4.oby.tsv b/exec/java-exec/src/test/resources/window/b4.p4.oby.tsv
new file mode 100644
index 0000000..528f2f3
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b4.p4.oby.tsv
@@ -0,0 +1,80 @@
+1	11	1	1	1	0.0125	0.0
+3	35	2	2	2	0.0375	0.012658227848101266
+3	35	3	2	2	0.0375	0.012658227848101266
+10	126	4	4	3	0.125	0.0379746835443038
+10	126	5	4	3	0.125	0.0379746835443038
+10	126	6	4	3	0.125	0.0379746835443038
+10	126	7	4	3	0.125	0.0379746835443038
+10	126	8	4	3	0.125	0.0379746835443038
+10	126	9	4	3	0.125	0.0379746835443038
+10	126	10	4	3	0.125	0.0379746835443038
+14	182	11	11	4	0.175	0.12658227848101267
+14	182	12	11	4	0.175	0.12658227848101267
+14	182	13	11	4	0.175	0.12658227848101267
+14	182	14	11	4	0.175	0.12658227848101267
+19	257	15	15	5	0.2375	0.17721518987341772
+19	257	16	15	5	0.2375	0.17721518987341772
+19	257	17	15	5	0.2375	0.17721518987341772
+19	257	18	15	5	0.2375	0.17721518987341772
+19	257	19	15	5	0.2375	0.17721518987341772
+25	353	20	20	6	0.3125	0.24050632911392406
+25	353	21	20	6	0.3125	0.24050632911392406
+25	353	22	20	6	0.3125	0.24050632911392406
+25	353	23	20	6	0.3125	0.24050632911392406
+25	353	24	20	6	0.3125	0.24050632911392406
+25	353	25	20	6	0.3125	0.24050632911392406
+32	472	26	26	7	0.4	0.31645569620253167
+32	472	27	26	7	0.4	0.31645569620253167
+32	472	28	26	7	0.4	0.31645569620253167
+32	472	29	26	7	0.4	0.31645569620253167
+32	472	30	26	7	0.4	0.31645569620253167
+32	472	31	26	7	0.4	0.31645569620253167
+32	472	32	26	7	0.4	0.31645569620253167
+40	616	33	33	8	0.5	0.4050632911392405
+40	616	34	33	8	0.5	0.4050632911392405
+40	616	35	33	8	0.5	0.4050632911392405
+40	616	36	33	8	0.5	0.4050632911392405
+40	616	37	33	8	0.5	0.4050632911392405
+40	616	38	33	8	0.5	0.4050632911392405
+40	616	39	33	8	0.5	0.4050632911392405
+40	616	40	33	8	0.5	0.4050632911392405
+49	787	41	41	9	0.6125	0.5063291139240507
+49	787	42	41	9	0.6125	0.5063291139240507
+49	787	43	41	9	0.6125	0.5063291139240507
+49	787	44	41	9	0.6125	0.5063291139240507
+49	787	45	41	9	0.6125	0.5063291139240507
+49	787	46	41	9	0.6125	0.5063291139240507
+49	787	47	41	9	0.6125	0.5063291139240507
+49	787	48	41	9	0.6125	0.5063291139240507
+49	787	49	41	9	0.6125	0.5063291139240507
+60	1007	50	50	10	0.75	0.620253164556962
+60	1007	51	50	10	0.75	0.620253164556962
+60	1007	52	50	10	0.75	0.620253164556962
+60	1007	53	50	10	0.75	0.620253164556962
+60	1007	54	50	10	0.75	0.620253164556962
+60	1007	55	50	10	0.75	0.620253164556962
+60	1007	56	50	10	0.75	0.620253164556962
+60	1007	57	50	10	0.75	0.620253164556962
+60	1007	58	50	10	0.75	0.620253164556962
+60	1007	59	50	10	0.75	0.620253164556962
+60	1007	60	50	10	0.75	0.620253164556962
+71	1238	61	61	11	0.8875	0.759493670886076
+71	1238	62	61	11	0.8875	0.759493670886076
+71	1238	63	61	11	0.8875	0.759493670886076
+71	1238	64	61	11	0.8875	0.759493670886076
+71	1238	65	61	11	0.8875	0.759493670886076
+71	1238	66	61	11	0.8875	0.759493670886076
+71	1238	67	61	11	0.8875	0.759493670886076
+71	1238	68	61	11	0.8875	0.759493670886076
+71	1238	69	61	11	0.8875	0.759493670886076
+71	1238	70	61	11	0.8875	0.759493670886076
+71	1238	71	61	11	0.8875	0.759493670886076
+80	1436	72	72	12	1.0	0.8987341772151899
+80	1436	73	72	12	1.0	0.8987341772151899
+80	1436	74	72	12	1.0	0.8987341772151899
+80	1436	75	72	12	1.0	0.8987341772151899
+80	1436	76	72	12	1.0	0.8987341772151899
+80	1436	77	72	12	1.0	0.8987341772151899
+80	1436	78	72	12	1.0	0.8987341772151899
+80	1436	79	72	12	1.0	0.8987341772151899
+80	1436	80	72	12	1.0	0.8987341772151899

http://git-wip-us.apache.org/repos/asf/drill/blob/a027f692/exec/java-exec/src/test/resources/window/b4.p4.pby.oby.tsv
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/window/b4.p4.pby.oby.tsv b/exec/java-exec/src/test/resources/window/b4.p4.pby.oby.tsv
new file mode 100644
index 0000000..a5d630b
--- /dev/null
+++ b/exec/java-exec/src/test/resources/window/b4.p4.pby.oby.tsv
@@ -0,0 +1,80 @@
+1	11	1	1	1	0.1	0.0
+3	35	2	2	2	0.3	0.1111111111111111
+3	35	3	2	2	0.3	0.1111111111111111
+10	126	4	4	3	1.0	0.3333333333333333
+10	126	5	4	3	1.0	0.3333333333333333
+10	126	6	4	3	1.0	0.3333333333333333
+10	126	7	4	3	1.0	0.3333333333333333
+10	126	8	4	3	1.0	0.3333333333333333
+10	126	9	4	3	1.0	0.3333333333333333
+10	126	10	4	3	1.0	0.3333333333333333
+4	56	1	1	1	0.13333333333333333	0.0
+4	56	2	1	1	0.13333333333333333	0.0
+4	56	3	1	1	0.13333333333333333	0.0
+4	56	4	1	1	0.13333333333333333	0.0
+9	131	5	5	2	0.3	0.13793103448275862
+9	131	6	5	2	0.3	0.13793103448275862
+9	131	7	5	2	0.3	0.13793103448275862
+9	131	8	5	2	0.3	0.13793103448275862
+9	131	9	5	2	0.3	0.13793103448275862
+15	227	10	10	3	0.5	0.3103448275862069
+15	227	11	10	3	0.5	0.3103448275862069
+15	227	12	10	3	0.5	0.3103448275862069
+15	227	13	10	3	0.5	0.3103448275862069
+15	227	14	10	3	0.5	0.3103448275862069
+15	227	15	10	3	0.5	0.3103448275862069
+22	346	16	16	4	0.7333333333333333	0.5172413793103449
+22	346	17	16	4	0.7333333333333333	0.5172413793103449
+22	346	18	16	4	0.7333333333333333	0.5172413793103449
+22	346	19	16	4	0.7333333333333333	0.5172413793103449
+22	346	20	16	4	0.7333333333333333	0.5172413793103449
+22	346	21	16	4	0.7333333333333333	0.5172413793103449
+22	346	22	16	4	0.7333333333333333	0.5172413793103449
+30	490	23	23	5	1.0	0.7586206896551724
+30	490	24	23	5	1.0	0.7586206896551724
+30	490	25	23	5	1.0	0.7586206896551724
+30	490	26	23	5	1.0	0.7586206896551724
+30	490	27	23	5	1.0	0.7586206896551724
+30	490	28	23	5	1.0	0.7586206896551724
+30	490	29	23	5	1.0	0.7586206896551724
+30	490	30	23	5	1.0	0.7586206896551724
+9	171	1	1	1	0.45	0.0
+9	171	2	1	1	0.45	0.0
+9	171	3	1	1	0.45	0.0
+9	171	4	1	1	0.45	0.0
+9	171	5	1	1	0.45	0.0
+9	171	6	1	1	0.45	0.0
+9	171	7	1	1	0.45	0.0
+9	171	8	1	1	0.45	0.0
+9	171	9	1	1	0.45	0.0
+20	391	10	10	2	1.0	0.47368421052631576
+20	391	11	10	2	1.0	0.47368421052631576
+20	391	12	10	2	1.0	0.47368421052631576
+20	391	13	10	2	1.0	0.47368421052631576
+20	391	14	10	2	1.0	0.47368421052631576
+20	391	15	10	2	1.0	0.47368421052631576
+20	391	16	10	2	1.0	0.47368421052631576
+20	391	17	10	2	1.0	0.47368421052631576
+20	391	18	10	2	1.0	0.47368421052631576
+20	391	19	10	2	1.0	0.47368421052631576
+20	391	20	10	2	1.0	0.47368421052631576
+11	231	1	1	1	0.55	0.0
+11	231	2	1	1	0.55	0.0
+11	231	3	1	1	0.55	0.0
+11	231	4	1	1	0.55	0.0
+11	231	5	1	1	0.55	0.0
+11	231	6	1	1	0.55	0.0
+11	231	7	1	1	0.55	0.0
+11	231	8	1	1	0.55	0.0
+11	231	9	1	1	0.55	0.0
+11	231	10	1	1	0.55	0.0
+11	231	11	1	1	0.55	0.0
+20	429	12	12	2	1.0	0.5789473684210527
+20	429	13	12	2	1.0	0.5789473684210527
+20	429	14	12	2	1.0	0.5789473684210527
+20	429	15	12	2	1.0	0.5789473684210527
+20	429	16	12	2	1.0	0.5789473684210527
+20	429	17	12	2	1.0	0.5789473684210527
+20	429	18	12	2	1.0	0.5789473684210527
+20	429	19	12	2	1.0	0.5789473684210527
+20	429	20	12	2	1.0	0.5789473684210527