@Test
  public void testNullCast() throws Throwable {
    String scriptText =
        "BEGIN\n" +
        "DECLARE a BIGINT;\n" +
        "print('started');\n" +
        "SELECT cast (null as BIGINT) as t INTO a\n" +
        "print (a);\n" +
        "print ('here');\n" +
        "end;\n" +
        "/";
    // Inverted match, output should not have NPE
    testScriptFile(scriptText, args(), "^(.(?!(NullPointerException)))*$", OutStream.ERR);
  }
Start up a local Hive Server 2 for these tests
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java