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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
regexpContains
(String value, String regex) SQLREGEXP_CONTAINS(value, regexp)
function.@Nullable String
regexpExtract
(String value, String regex) SQLREGEXP_EXTRACT(value, regexp)
function.@Nullable String
regexpExtract
(String value, String regex, int position) SQLREGEXP_EXTRACT(value, regexp, position)
function.@Nullable String
regexpExtract
(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.int
regexpInstr
(String value, String regex) SQLREGEXP_INSTR(value, regexp)
function.int
regexpInstr
(String value, String regex, int position) SQLREGEXP_INSTR(value, regexp, position)
function.int
regexpInstr
(String value, String regex, int position, int occurrence) SQLREGEXP_INSTR(value, regexp, position, occurrence)
function.int
regexpInstr
(String value, String regex, int position, int occurrence, int occurrencePosition) SQLREGEXP_INSTR(value, regexp, position, occurrence, occurrencePosition)
function.boolean
regexpLike
(String value, String regex, String stringFlags) SQLREGEXP_LIKE(value, regexp, flags)
function.regexpReplace
(String s, String regex) SQLREGEXP_REPLACE
function with 2 arguments.regexpReplace
(String s, String regex, String replacement) SQLREGEXP_REPLACE
function with 3 arguments.regexpReplace
(String s, String regex, String replacement, int pos) SQLREGEXP_REPLACE
function with 4 arguments.regexpReplace
(String s, String regex, String replacement, int pos, int occurrence) SQLREGEXP_REPLACE
function with 5 arguments.regexpReplace
(String s, String regex, String replacement, int pos, int occurrence, @Nullable String matchType) SQLREGEXP_REPLACE
function with 6 arguments.regexpReplace
(String s, String regex, String replacement, int pos, String matchType) SQLREGEXP_REPLACE
function with 5 arguments.regexpReplaceNonDollarIndexed
(String s, String regex, String replacement) SQLREGEXP_REPLACE
function with 3 arguments with\\
based indexing for capturing groups.regexpReplacePg
(String s, String regex, String replacement) SQLREGEXP_REPLACE
function for PostgreSQL with 3 arguments.regexpReplacePg
(String s, String regex, String replacement, String matchType) SQLREGEXP_REPLACE
function for PostgreSQL with 4 arguments.static String
replaceNonDollarIndexedString
(String replacement) Preprocesses double-backslash-based indexing for capturing groups into $-based indices recognized by java regex, throws an error for invalid escapes.boolean
SQLRLIKE
function.
-
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_REPLACE
function with 2 arguments. -
regexpReplace
SQLREGEXP_REPLACE
function with 3 arguments. -
regexpReplace
SQLREGEXP_REPLACE
function with 4 arguments. -
regexpReplace
SQLREGEXP_REPLACE
function with 5 arguments. Last argument is occurrence. -
regexpReplace
SQLREGEXP_REPLACE
function 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_REPLACE
function with 6 arguments. -
regexpReplacePg
SQLREGEXP_REPLACE
function for PostgreSQL with 3 arguments. -
regexpReplacePg
SQLREGEXP_REPLACE
function for PostgreSQL with 4 arguments. -
regexpReplaceNonDollarIndexed
SQLREGEXP_REPLACE
function with 3 arguments with\\
based indexing for capturing groups. -
rlike
SQLRLIKE
function.
-