@Test
  public void testHiveVariableInHplsql() throws Throwable {
    String scriptText =
        "DROP TABLE IF EXISTS result;\n" +
            "CREATE TABLE result (s string);\n" +
            "CREATE PROCEDURE p1()\n" +
            "DECLARE hivedb_tbl string;\n" +
            "BEGIN\n" +
            "SELECT hivedb || '.' || hivetbl into hivedb_tbl;\n" +
            "INSERT INTO result VALUES(hivedb_tbl);\n" +
            "END;\n" +
            "p1();\n" +
            "SELECT * FROM result;" ;
    List<String> args = new ArrayList<>(args());
    args.add("--hivevar");
    args.add("hivedb=sys");
    args.add("--hivevar");
    args.add("hivetbl=tbls");
    testScriptFile(scriptText, args, "sys.tbls");
  }
Start up a local Hive Server 2 for these tests
itests/hive-unit/src/test/java/org/apache/hive/beeline/TestHplSqlViaBeeLine.java