}
@Test
public void testIfExprStringColumnStringColumn() {
VectorizedRowBatch batch = getBatch1Long3BytesVectors();
VectorExpression expr = new IfExprStringGroupColumnStringGroupColumn(0, 1, 2, 3);
BytesColumnVector r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(getString(r, 0).equals("arg3_0"));
assertTrue(getString(r, 1).equals("arg3_1"));
assertTrue(getString(r, 2).equals("arg2_2"));
assertTrue(getString(r, 3).equals("arg2_3"));
// test first IF argument repeating
batch = getBatch1Long3BytesVectors();
batch.cols[0].isRepeating = true;
r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(getString(r, 0).equals("arg3_0"));
assertTrue(getString(r, 1).equals("arg3_1"));
assertTrue(getString(r, 2).equals("arg3_2"));
assertTrue(getString(r, 3).equals("arg3_3"));
// test second IF argument repeating
batch = getBatch1Long3BytesVectors();
batch.cols[1].isRepeating = true;
r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(getString(r, 0).equals("arg3_0"));
assertTrue(getString(r, 1).equals("arg3_1"));
assertTrue(getString(r, 2).equals("arg2_0"));
assertTrue(getString(r, 3).equals("arg2_0"));
// test third IF argument repeating
batch = getBatch1Long3BytesVectors();
batch.cols[2].isRepeating = true;
r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(getString(r, 0).equals("arg3_0"));
assertTrue(getString(r, 1).equals("arg3_0"));
assertTrue(getString(r, 2).equals("arg2_2"));
assertTrue(getString(r, 3).equals("arg2_3"));
// test second IF argument with nulls
batch = getBatch1Long3BytesVectors();
batch.cols[1].noNulls = false;
batch.cols[1].isNull[2] = true;
// set vector[2] to null to verify correct null handling
((BytesColumnVector) batch.cols[1]).vector[2] = null;
r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(getString(r, 0).equals("arg3_0"));
assertTrue(getString(r, 1).equals("arg3_1"));
assertTrue(!r.noNulls && r.isNull[2]);
assertTrue(getString(r, 3).equals("arg2_3"));
assertFalse(r.isNull[0] || r.isNull[1] || r.isNull[3]);
// test third IF argument with nulls
batch = getBatch1Long3BytesVectors();
batch.cols[2].noNulls = false;
batch.cols[2].isNull[0] = true;
// set vector[0] to null object reference to verify correct null handling
((BytesColumnVector) batch.cols[2]).vector[0] = null;
r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(!r.noNulls && r.isNull[0]);
assertTrue(getString(r, 1).equals("arg3_1"));
assertTrue(getString(r, 2).equals("arg2_2"));
assertTrue(getString(r, 3).equals("arg2_3"));
assertFalse(r.isNull[1] || r.isNull[2] || r.isNull[3]);
// test second IF argument with nulls and repeating
batch = getBatch1Long3BytesVectors();
batch.cols[1].noNulls = false;
batch.cols[1].isNull[0] = true;
batch.cols[1].isRepeating = true;
r = (BytesColumnVector) batch.cols[3];
expr.evaluate(batch);
assertTrue(getString(r, 0).equals("arg3_0"));
assertTrue(getString(r, 1).equals("arg3_1"));
assertTrue(!r.noNulls && r.isNull[2]);
assertTrue(!r.noNulls && r.isNull[3]);
assertFalse(r.isNull[0] || r.isNull[1]);