String functions are classified as those primarily accepting or returning
The string functions operate mainly on these data types:
Function reference:
Impala supports the following string functions:
Return type:
Return type:
For general information about Base64 encoding, see
Return type:
For general information about Base64 encoding, see
Return type:
The following examples show the default
Return type:
When applied to a
Return type:
Usage notes: Can be used as the inverse of the
Return type:
Return type:
Return type:
Return type:
By default, returns a single string covering the whole result set. To include other
columns or values in the result set, or to produce multiple concatenated strings for
subsets of rows, include a
Strictly speaking,
Return type:
Return type:
If the substring is not present in the string, the function returns 0:
The optional third and fourth arguments let you find instances of the substring other than the first instance starting from the left:
The third argument lets you specify a starting point within the string other than 1:
If the third argument is negative, the search works right-to-left starting that many characters from the right. The return value still represents the position starting from the left side of the string.
The fourth argument lets you specify an occurrence other than the first:
If the fourth argument is greater than the number of matching occurrences, the function returns 0:
The fourth argument cannot be negative or zero. A non-positive value for this argument causes an error:
If either of the optional arguments is
Return type:
When applied to a
Return type:
Return type:
Return type:
Return type:
Return type:
Usage notes: This function is important for the traditional Hadoop use case
of interpreting web logs. For example, if the web traffic data features raw URLs not
divided into separate table columns, you can count visitors to a particular page by
extracting the
Return type:
This example shows escaping one of special characters in RE2.
This example shows escaping all the special characters in RE2.
q\|r\:s\-t | +------------------------------------------------------------+ ]]>
Return type:
This example shows how group 0 matches the full pattern string, including the
portion outside any
This example shows how group 1 matches just the contents inside the first
Unlike in earlier Impala releases, the regular expression library used in Impala 2.0
and later supports the
The flags that you can include in the optional third argument are:
Return type:
This example shows how
Return type:
These examples show how you can replace parts of a string matching a pattern with
replacement text, which can include backreferences to any
Replace a character pattern with new text:
Replace a character pattern with substitution text that includes the original matching text:
Remove all characters that are not digits:
Return type:
Return type:
Because this function does not use any regular expression patterns, it is typically
faster than
If any argument is
Matching is case-sensitive.
If the replacement string contains another instance of the target string, the expansion is only performed once, instead of applying again to the newly constructed string.
Return type:
Return type:
Return type:
Return type:
Return type:
These examples show how to retrieve the nth field from a delimited string:
These examples show what happens for out-of-range field positions. Specifying a
value less than 1 produces an error. Specifying a value greater than the number of
fields returns a zero-length string (which is not the same as
These examples show how the delimiter can be a multi-character value:
Return type:
Return type:
Return type:
For example:
Return type:
Usage notes:
If
For example:
If
If
If
For example:
Usage notes: Often used during data cleansing operations during the ETL
cycle, if input values might still have surrounding spaces. For a more
general-purpose function that can remove other leading and trailing characters
besides spaces, see
Return type:
Return type: