@Test
  public void testPackage() throws Throwable {
    String scriptText =
      "DROP TABLE IF EXISTS result;\n" +
      "CREATE TABLE result (n int);\n" +
      "CREATE PACKAGE Counter AS\n" +
      "  count INT := 0;\n" +
      "  FUNCTION current() RETURNS INT;\n" +
      "  PROCEDURE inc(i INT);\n" +
      "END;\n" +
      "CREATE PACKAGE BODY Counter AS\n" +
      "  FUNCTION current() RETURNS INT IS BEGIN RETURN count; END;\n" +
      "  PROCEDURE inc(i INT) IS BEGIN count := count + i; END;\n" +
      "END;\n" +
      "Counter.inc(6172);\n" +
      "Counter.inc(6173);\n" +
      "INSERT INTO result VALUES(Counter.current());\n" +
      "SELECT * FROM result;\n";
    testScriptFile(scriptText, args(), "12345");
  }
Start up a local Hive Server 2 for these tests
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java