@Override
  protected void execSql(String scriptDir, String scriptFile)
      throws IOException, HiveMetaException {
    NestedScriptParser dbCommandParser = getDbCommandParser(dbType, metaDbType);

    // expand the nested script
    // If the metaDbType is set, this is setting up the information
    // schema in Hive. That specifically means that the sql commands need
    // to be adjusted for the underlying RDBMS (correct quotation
    // strings, etc).
    String sqlCommands = dbCommandParser.buildCommand(scriptDir, scriptFile, metaDbType != null);
    File tmpFile = File.createTempFile("schematool", ".sql");
    tmpFile.deleteOnExit();

    // write out the buffer into a file. Add beeline commands for autocommit and close
    FileWriter fstream = new FileWriter(tmpFile.getPath());
    BufferedWriter out = new BufferedWriter(fstream);
    if (!dbType.equalsIgnoreCase(HiveSchemaHelper.DB_HIVE)) {
      out.write("!autocommit off" + System.getProperty("line.separator"));
      out.write(sqlCommands);
      out.write("!commit" + System.getProperty("line.separator"));
    } else {
      out.write("!autocommit on" + System.getProperty("line.separator"));
      out.write(sqlCommands);
    }
    out.write("!closeall" + System.getProperty("line.separator"));
    out.close();
    execSql(tmpFile.getPath());
  }
Run beeline with the given metastore script. Flatten the nested scripts
into single file.
beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java