@Test
public void testRankWithMultiKey() throws Exception {

    Over func = new Over();
    DataBag inbag = BagFactory.getInstance().newDefaultBag();
    Random r = new Random();
    Tuple t = TupleFactory.getInstance().newTuple(3);
    t.set(0, null);
    t.set(1, r.nextInt(100));
    t.set(2, "a");
    inbag.add(t);
    t = TupleFactory.getInstance().newTuple(3);
    t.set(0, null);
    t.set(1, r.nextInt(100));
    t.set(2, "b");
    inbag.add(t);
    t = TupleFactory.getInstance().newTuple(3);
    t.set(0, 2);
    t.set(1, r.nextInt(100));
    t.set(2, "b");
    inbag.add(t);
    t = TupleFactory.getInstance().newTuple(3);
    t.set(0, 5);
    t.set(1, r.nextInt(100));
    inbag.add(t);
    t.set(2, "b");
    t = TupleFactory.getInstance().newTuple(3);
    t.set(0, 5);
    t.set(1, r.nextInt(100));
    t.set(2, "c");
    inbag.add(t);
    t = TupleFactory.getInstance().newTuple(3);
    t.set(0, 5);
    t.set(1, r.nextInt(100));
    t.set(2, "c");
    inbag.add(t);
    t = TupleFactory.getInstance().newTuple(3);
    t.set(0, 7);
    t.set(1, r.nextInt(100));
    t.set(2, "z");
    inbag.add(t);
    t = TupleFactory.getInstance().newTuple(6);
    t.set(0, inbag);
    t.set(1, "rank");
    t.set(2, -1);
    t.set(3, -1);
    t.set(4, 0);
    t.set(5, 2);
    DataBag outbag = func.exec(t);
    assertEquals(7, outbag.size());
    Iterator<Tuple> iter = outbag.iterator();
    t = iter.next();
    assertEquals(1, t.get(0));
    t = iter.next();
    assertEquals(2, t.get(0));
    t = iter.next();
    assertEquals(3, t.get(0));
    t = iter.next();
    assertEquals(4, t.get(0));
    t = iter.next();
    assertEquals(5, t.get(0));
    t = iter.next();
    assertEquals(5, t.get(0));
    t = iter.next();
    assertEquals(7, t.get(0));
}