Package org.apache.calcite.runtime
Class SqlFunctions.RegexFunction
java.lang.Object
org.apache.calcite.runtime.SqlFunctions.RegexFunction
- Enclosing class:
SqlFunctions
State for
REGEXP_CONTAINS, REGEXP_EXTRACT, REGEXP_EXTRACT_ALL,
REGEXP_INSTR, REGEXP_REPLACE, RLIKE.
Marked deterministic so that the code generator instantiates one once per query, not once per row.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanregexpContains(String value, String regex) SQLREGEXP_CONTAINS(value, regexp)function.@Nullable StringregexpExtract(String value, String regex) SQLREGEXP_EXTRACT(value, regexp)function.@Nullable StringregexpExtract(String value, String regex, int position) SQLREGEXP_EXTRACT(value, regexp, position)function.@Nullable StringregexpExtract(String value, String regex, int position, int occurrence) SQLREGEXP_EXTRACT(value, regexp, position, occurrence)function.regexpExtractAll(String value, String regex) SQLREGEXP_EXTRACT_ALL(value, regexp)function.intregexpInstr(String value, String regex) SQLREGEXP_INSTR(value, regexp)function.intregexpInstr(String value, String regex, int position) SQLREGEXP_INSTR(value, regexp, position)function.intregexpInstr(String value, String regex, int position, int occurrence) SQLREGEXP_INSTR(value, regexp, position, occurrence)function.intregexpInstr(String value, String regex, int position, int occurrence, int occurrencePosition) SQLREGEXP_INSTR(value, regexp, position, occurrence, occurrencePosition)function.booleanregexpLike(String value, String regex, String stringFlags) SQLREGEXP_LIKE(value, regexp, flags)function.regexpReplace(String s, String regex) SQLREGEXP_REPLACEfunction with 2 arguments.regexpReplace(String s, String regex, String replacement) SQLREGEXP_REPLACEfunction with 3 arguments.regexpReplace(String s, String regex, String replacement, int pos) SQLREGEXP_REPLACEfunction with 4 arguments.regexpReplace(String s, String regex, String replacement, int pos, int occurrence) SQLREGEXP_REPLACEfunction with 5 arguments.regexpReplace(String s, String regex, String replacement, int pos, int occurrence, @Nullable String matchType) SQLREGEXP_REPLACEfunction with 6 arguments.regexpReplace(String s, String regex, String replacement, int pos, String matchType) SQLREGEXP_REPLACEfunction with 5 arguments.regexpReplaceNonDollarIndexed(String s, String regex, String replacement) SQLREGEXP_REPLACEfunction with 3 arguments with\\based indexing for capturing groups.regexpReplacePg(String s, String regex, String replacement) SQLREGEXP_REPLACEfunction for PostgreSQL with 3 arguments.regexpReplacePg(String s, String regex, String replacement, String matchType) SQLREGEXP_REPLACEfunction for PostgreSQL with 4 arguments.static StringreplaceNonDollarIndexedString(String replacement) Preprocesses double-backslash-based indexing for capturing groups into $-based indices recognized by java regex, throws an error for invalid escapes.booleanSQLRLIKEfunction.
-
Constructor Details
-
RegexFunction
public RegexFunction()
-
-
Method Details
-
replaceNonDollarIndexedString
Preprocesses double-backslash-based indexing for capturing groups into $-based indices recognized by java regex, throws an error for invalid escapes. -
regexpContains
SQLREGEXP_CONTAINS(value, regexp)function. Throws a runtime exception for invalid regular expressions. -
regexpLike
SQLREGEXP_LIKE(value, regexp, flags)function. Throws a runtime exception for invalid regular expressions. -
regexpExtract
SQLREGEXP_EXTRACT(value, regexp)function. Returns NULL if there is no match. Returns an exception if regex is invalid. Uses position=1 and occurrence=1 as default values when not specified. -
regexpExtract
SQLREGEXP_EXTRACT(value, regexp, position)function. Returns NULL if there is no match, or if position is beyond range. Returns an exception if regex or position is invalid. Uses occurrence=1 as default value when not specified. -
regexpExtract
SQLREGEXP_EXTRACT(value, regexp, position, occurrence)function. Returns NULL if there is no match, or if position or occurrence are beyond range. Returns an exception if regex, position or occurrence are invalid. -
regexpExtractAll
SQLREGEXP_EXTRACT_ALL(value, regexp)function. Returns an empty array if there is no match, returns an exception if regex is invalid. -
regexpInstr
SQLREGEXP_INSTR(value, regexp)function. Returns 0 if there is no match or regex is empty. Returns an exception if regex is invalid. Uses position=1, occurrence=1, occurrencePosition=0 as default values if not specified. -
regexpInstr
SQLREGEXP_INSTR(value, regexp, position)function. Returns 0 if there is no match, regex is empty, or if position is beyond range. Returns an exception if regex or position is invalid. Uses occurrence=1, occurrencePosition=0 as default value when not specified. -
regexpInstr
SQLREGEXP_INSTR(value, regexp, position, occurrence)function. Returns 0 if there is no match, regex is empty, or if position or occurrence are beyond range. Returns an exception if regex, position or occurrence are invalid. Uses occurrencePosition=0 as default value when not specified. -
regexpInstr
public int regexpInstr(String value, String regex, int position, int occurrence, int occurrencePosition) SQLREGEXP_INSTR(value, regexp, position, occurrence, occurrencePosition)function. Returns 0 if there is no match, regex is empty, or if position or occurrence are beyond range. Returns an exception if regex, position, occurrence or occurrencePosition are invalid. -
regexpReplace
SQLREGEXP_REPLACEfunction with 2 arguments. -
regexpReplace
SQLREGEXP_REPLACEfunction with 3 arguments. -
regexpReplace
SQLREGEXP_REPLACEfunction with 4 arguments. -
regexpReplace
SQLREGEXP_REPLACEfunction with 5 arguments. Last argument is occurrence. -
regexpReplace
SQLREGEXP_REPLACEfunction with 5 arguments. Last argument is match type -
regexpReplace
public String regexpReplace(String s, String regex, String replacement, int pos, int occurrence, @Nullable String matchType) SQLREGEXP_REPLACEfunction with 6 arguments. -
regexpReplacePg
SQLREGEXP_REPLACEfunction for PostgreSQL with 3 arguments. -
regexpReplacePg
SQLREGEXP_REPLACEfunction for PostgreSQL with 4 arguments. -
regexpReplaceNonDollarIndexed
SQLREGEXP_REPLACEfunction with 3 arguments with\\based indexing for capturing groups. -
rlike
SQLRLIKEfunction.
-