private String getCommand() {
    String commands = inputContent;
    StringBuilder newCommands = new StringBuilder(commands.length());
    int lastMatchEnd = 0;
    Matcher commentMatcher = Pattern.compile("^--.*$", Pattern.MULTILINE).matcher(commands);
    // remove the comments
    while (commentMatcher.find()) {
      newCommands.append(commands.substring(lastMatchEnd, commentMatcher.start()));
      lastMatchEnd = commentMatcher.end();
    }
    newCommands.append(commands.substring(lastMatchEnd, commands.length()));
    commands = newCommands.toString();
    return commands;
  }
This allows a .q file to continue executing after a statement runs into an error which is convenient
if you want to use another hive cmd after the failure to sanity check the state of the system.
itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java