@Test
  public void testStringLikePatternType() throws HiveException {
    FilterStringColLikeStringScalar expr;
    VectorizedRowBatch vrb = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1, 1, 1);
    vrb.cols[0] = new BytesColumnVector(1);
    BytesColumnVector bcv = (BytesColumnVector) vrb.cols[0];
    vrb.size = 0;

    // BEGIN pattern
    expr = new FilterStringColLikeStringScalar(0, "abc%".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.BeginChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "abc\\%def%".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.BeginChecker.class,
        expr.checker.getClass());

    // END pattern
    expr = new FilterStringColLikeStringScalar(0, "%abc".getBytes(StandardCharsets.UTF_8));
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.EndChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "%abc\\%def".getBytes(StandardCharsets.UTF_8));
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.EndChecker.class,
        expr.checker.getClass());

    // MIDDLE pattern
    expr = new FilterStringColLikeStringScalar(0, "%abc%".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.MiddleChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "%abc\\%def%".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.MiddleChecker.class,
        expr.checker.getClass());

    // CHAIN pattern
    expr = new FilterStringColLikeStringScalar(0, "%abc%de".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ChainedChecker.class,
        expr.checker.getClass());

    // COMPLEX pattern
    expr = new FilterStringColLikeStringScalar(0, "%abc_%de".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "abc_".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "abc\\_def_".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "_abc".getBytes(StandardCharsets.UTF_8));
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "_abc\\_def".getBytes(StandardCharsets.UTF_8));
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "_abc_".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "_abc\\_def_".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    expr = new FilterStringColLikeStringScalar(0, "_abc_de".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());


    expr = new FilterStringColLikeStringScalar(0,
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_b".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.ComplexChecker.class,
        expr.checker.getClass());

    // NONE pattern
    expr = new FilterStringColLikeStringScalar(0, "abc".getBytes());
    expr.transientInit(hiveConf);
    expr.evaluate(vrb);
    Assert.assertEquals(FilterStringColLikeStringScalar.NoneChecker.class,
        expr.checker.getClass());
  }
Test vectorized expression and filter evaluation for strings.
ql/src/test/org/apache/hadoop/hive/ql/exec/vector/expressions/TestVectorStringExpressions.java