@Test
  public void testACTIVITY_COUNTHplSqlFunction2() throws Throwable {
    String SCRIPT_TEXT =
        "DROP TABLE IF EXISTS result;\n" +
            "CREATE TABLE result (col1 string);\n" +
            "INSERT INTO result VALUES('Alice');\n" +
            "INSERT INTO result VALUES('Bob');\n" +
            "DECLARE var INT;\n" +
            "SELECT count(*) INTO var FROM result;\n" +
            "IF ACTIVITY_COUNT = 1 THEN\n" +
            " PRINT 'id = ' || var;\n" +
            "END IF;";
    testScriptFile(SCRIPT_TEXT, args(), "id = 2", OutStream.ERR);
  }
Start up a local Hive Server 2 for these tests
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java