public static List<String> splitSemiColon(String line) {
    boolean inQuotes = false;
    boolean escape = false;

    List<String> ret = new ArrayList<>();

    char quoteChar = '"';
    int beginIndex = 0;
    for (int index = 0; index < line.length(); index++) {
      char c = line.charAt(index);
      switch (c) {
      case ';':
        if (!inQuotes) {
          ret.add(line.substring(beginIndex, index));
          beginIndex = index + 1;
        }
        break;
      case '"':
      case '`':
      case '\'':
        if (!escape) {
          if (!inQuotes) {
            quoteChar = c;
            inQuotes = !inQuotes;
          } else {
            if (c == quoteChar) {
              inQuotes = !inQuotes;
            }
          }
        }
        break;
      default:
        break;
      }

      if (escape) {
        escape = false;
      } else if (c == '\\') {
        escape = true;
      }
    }

    if (beginIndex < line.length()) {
      ret.add(line.substring(beginIndex));
    }

    return ret;
  }
Split the line by semicolon by ignoring the ones in the single/double quotes.
cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java