@Udf(description = "Splits a string into an array of substrings based on a regexp.")
  public List<String> regexpSplit(
      @UdfParameter(
          description = "The string to be split. If NULL, then function returns NULL.")
      final String string,
      @UdfParameter(
          description = "The regular expression to split the string by. "
              + "If NULL, then function returns NULL.")
      final String regexp) {
    if (string == null || regexp == null) {
      return null;
    }

    // Use Guava version to be compatible with other splitting functions.
    final Pattern p = getPattern(regexp);
    if (regexp.isEmpty() || p.matcher("").matches()) {
      return Arrays.asList(p.split(string));
    } else {
      return Splitter.on(p).splitToList(string);
    }
  }
@Test(expected = KsqlFunctionException.class)
  public void shouldThrowOnInvalidPattern() {
    udf.regexpSplit("abcd", "(()");
  }