@Test
  public void testColConcatCol() throws HiveException {

    // has nulls, not repeating
    VectorizedRowBatch batch = makeStringBatch2In1Out();
    StringGroupConcatColCol expr = new StringGroupConcatColCol(0, 1, 2);
    expr.evaluate(batch);
    BytesColumnVector outCol = (BytesColumnVector) batch.cols[2];

    int cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
        outCol.start[0], outCol.length[0]);
    Assert.assertEquals(0, cmp);
    Assert.assertTrue(outCol.isNull[2]);
    int cmp2 = StringExpr.compare(greengreen, 0, greengreen.length, outCol.vector[1],
        outCol.start[1], outCol.length[1]);
    Assert.assertEquals(0, cmp2);
    Assert.assertFalse(outCol.noNulls);
    Assert.assertFalse(outCol.isRepeating);

    // no nulls, not repeating
    batch = makeStringBatch2In1Out();
    batch.cols[0].noNulls = true;
    batch.cols[1].noNulls = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
        outCol.start[0], outCol.length[0]);
    Assert.assertEquals(0, cmp);

    cmp2 = StringExpr.compare(greengreen, 0, greengreen.length, outCol.vector[1],
        outCol.start[1], outCol.length[1]);
    Assert.assertEquals(0, cmp2);

    int cmp3 = StringExpr.compare(emptyString, 0, emptyString.length,
        outCol.vector[2], outCol.start[2], outCol.length[2]);
    Assert.assertEquals(0, cmp3);

    Assert.assertTrue(outCol.noNulls);
    Assert.assertFalse(outCol.isRepeating);

    // has nulls, is repeating

    batch = makeStringBatch2In1Out();
    batch.cols[0].isRepeating = true;                  // only left input repeating
    batch.cols[0].isNull[0] = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    Assert.assertEquals(3, batch.size);
    Assert.assertEquals(true, outCol.isRepeating);
    Assert.assertEquals(true, outCol.isNull[0]);

       // same, but repeating input is not null

    batch = makeStringBatch2In1Out();
    batch.cols[0].isRepeating = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];
    Assert.assertEquals(false, outCol.isRepeating);  //TEST FAILED
    cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
        outCol.start[0], outCol.length[0]);
    Assert.assertEquals(0, cmp);
    Assert.assertEquals(true, outCol.isNull[2]);

    batch = makeStringBatch2In1Out();
    batch.cols[1].isRepeating = true;                  // only right input repeating
    batch.cols[1].isNull[0] = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    Assert.assertEquals(3, batch.size);
    Assert.assertEquals(true, outCol.isRepeating);
    Assert.assertEquals(true, outCol.isNull[0]);

    batch = makeStringBatch2In1Out();
    batch.cols[0].isRepeating = true;                  // both inputs repeat
    batch.cols[0].isNull[0] = true;
    batch.cols[1].isRepeating = true;
    batch.cols[1].isNull[0] = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    Assert.assertEquals(3, batch.size);
    Assert.assertEquals(true, outCol.isRepeating);
    Assert.assertEquals(true, outCol.isNull[0]);

    // no nulls, is repeating
    batch = makeStringBatch2In1Out();
    batch.cols[1].isRepeating = true;             // only right input repeating and has no nulls
    batch.cols[1].noNulls = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    Assert.assertEquals(3, batch.size);
    Assert.assertEquals(false, outCol.isRepeating);
    Assert.assertEquals(false, outCol.isNull[0]);
    Assert.assertEquals(false, outCol.noNulls);
    Assert.assertEquals(true, outCol.isNull[2]);
    cmp = StringExpr.compare(greenred, 0, greenred.length, outCol.vector[1],
        outCol.start[1], outCol.length[1]);
    Assert.assertEquals(0, cmp);

         // try again with left input also having no nulls
    batch.cols[0].noNulls = true;
    expr.evaluate(batch);
    Assert.assertEquals(false, outCol.isRepeating);
    cmp = StringExpr.compare(red, 0, red.length, outCol.vector[2],
        outCol.start[2], outCol.length[2]);
    Assert.assertEquals(0, cmp);

    batch = makeStringBatch2In1Out();
    batch.cols[0].isRepeating = true;             // only left input repeating and has no nulls
    batch.cols[0].noNulls = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    Assert.assertEquals(3, batch.size);
    Assert.assertEquals(false, outCol.isRepeating);
    Assert.assertEquals(false, outCol.isNull[0]);
    Assert.assertEquals(false, outCol.noNulls);
    Assert.assertEquals(true, outCol.isNull[2]);
    cmp = StringExpr.compare(redgreen, 0, redgreen.length, outCol.vector[1],
        outCol.start[1], outCol.length[1]);
    Assert.assertEquals(0, cmp);

    batch = makeStringBatch2In1Out();
    batch.cols[0].isRepeating = true;                  // both inputs repeat
    batch.cols[0].noNulls = true;
    batch.cols[1].isRepeating = true;
    batch.cols[1].noNulls = true;
    expr.evaluate(batch);
    outCol = (BytesColumnVector) batch.cols[2];

    Assert.assertEquals(3, batch.size);
    Assert.assertEquals(true, outCol.isRepeating);
    Assert.assertEquals(false, outCol.isNull[0]);
    cmp = StringExpr.compare(redred, 0, redred.length, outCol.vector[0],
        outCol.start[0], outCol.length[0]);
    Assert.assertEquals(0, cmp);
  }
Test vectorized expression and filter evaluation for strings.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java