@Test
  public void testStringLikeRandomized() throws HiveException {
    final String [] patterns = new String[] {
        "ABC%",
        "%ABC",
        "%ABC%",
        "ABC%DEF",
        "ABC%DEF%",
        "%ABC%DEF",
        "%ABC%DEF%",
        "ABC%DEF%EFG",
        "%ABC%DEF%EFG",
        "%ABC%DEF%EFG%H",
    };
    long positive = 0;
    long negative = 0;
    Random control = new Random(1234);
    UDFLike udf = new UDFLike();
    for (String pattern : patterns) {
      VectorExpression expr = new FilterStringColLikeStringScalar(0, pattern.getBytes(StandardCharsets.UTF_8));
      expr.transientInit(hiveConf);
      VectorizedRowBatch batch = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1, 1, 1);
      batch.cols[0] = new BytesColumnVector(1);
      BytesColumnVector bcv = (BytesColumnVector) batch.cols[0];

      Text pText = new Text(pattern);
      for (int i=0; i < 1024; i++) {
        String input = generateCandidate(control,pattern);
        BooleanWritable like = udf.evaluate(new Text(input), pText);
        batch.reset();
        bcv.initBuffer();
        byte[] utf8 = input.getBytes(StandardCharsets.UTF_8);
        bcv.setVal(0, utf8, 0, utf8.length);
        bcv.noNulls = true;
        batch.size = 1;
        expr.evaluate(batch);
        if (like.get()) {
          positive++;
        } else {
          negative++;
        }
        assertEquals(String.format("Checking '%s' against '%s'", input, pattern), like.get(), (batch.size != 0));
      }
    }
    LOG.info(String.format("Randomized testing: ran %d positive tests and %d negative tests",
        positive, negative));
  }
Test vectorized expression and filter evaluation for strings.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java