All string operations are valid for both scalars and columns.
StringValue
Methods
Name | Description |
---|
ascii_str | Return the numeric ASCII code of the first character of a string. |
authority | Parse a URL and extract authority. |
capitalize | Uppercase the first letter, lowercase the rest. |
concat | Concatenate strings. |
contains | Return whether the expression contains substr . |
endswith | Determine if self ends with end . |
find | Return the position of the first occurrence of substring. |
find_in_set | Find the first occurrence of str_list within a list of strings. |
fragment | Parse a URL and extract fragment identifier. |
host | Parse a URL and extract host. |
length | Compute the length of a string. |
levenshtein | Return the Levenshtein distance between two strings. |
lower | Convert string to all lowercase. |
lpad | Pad arg by truncating on the right or padding on the left. |
lstrip | Remove whitespace from the left side of string. |
path | Parse a URL and extract path. |
protocol | Parse a URL and extract protocol. |
query | Parse a URL and returns query string or query string parameter. |
re_extract | Return the specified match at index from a regex pattern . |
re_replace | Replace all matches found by regex pattern with replacement . |
re_search | Return whether the values match pattern . |
re_split | Split a string by a regular expression pattern . |
repeat | Repeat a string n times. |
replace | Replace each exact match of pattern with replacement . |
reverse | Reverse the characters of a string. |
right | Return up to nchars from the end of each string. |
rpad | Pad self by truncating or padding on the right. |
rstrip | Remove whitespace from the right side of string. |
split | Split as string on delimiter . |
startswith | Determine whether self starts with start . |
strip | Remove whitespace from left and right sides of a string. |
substr | Extract a substring. |
to_date | |
translate | Replace from_str characters in self characters in to_str . |
upper | Convert string to all uppercase. |
userinfo | Parse a URL and extract user info. |
ascii_str
Return the numeric ASCII code of the first character of a string.
Returns
Name | Type | Description |
---|
| IntegerValue | ASCII code of the first character of the input |
Examples
authority
Parse a URL and extract authority.
Examples
Returns
capitalize
Uppercase the first letter, lowercase the rest.
This API matches the semantics of the Python
method.
Returns
Examples
concat
Concatenate strings.
NULLs are propagated. This methods is equivalent to using the +
operator.
Parameters
Returns
Examples
contains
Return whether the expression contains substr
.
Parameters
Name | Type | Description | Default |
---|
substr | str | StringValue | Substring for which to check | required |
Returns
Name | Type | Description |
---|
| BooleanValue | Boolean indicating the presence of substr in the expression |
Examples
endswith
Determine if self
ends with end
.
Parameters
Name | Type | Description | Default |
---|
end | str | StringValue | Suffix to check for | required |
Returns
Name | Type | Description |
---|
| BooleanValue | Boolean indicating whether self ends with end |
Examples
find
Return the position of the first occurrence of substring.
Parameters
Name | Type | Description | Default |
---|
substr | str | StringValue | Substring to search for | required |
start | int | ir.IntegerValue | None | Zero based index of where to start the search | None |
end | int | ir.IntegerValue | None | Zero based index of where to stop the search. Currently not implemented. | None |
Returns
Name | Type | Description |
---|
| IntegerValue | Position of substr in arg starting from start |
Examples
find_in_set
Find the first occurrence of str_list
within a list of strings.
No string in str_list
can have a comma.
Parameters
Name | Type | Description | Default |
---|
str_list | Sequence[str] | Sequence of strings | required |
Returns
Name | Type | Description |
---|
| IntegerValue | Position of str_list in self . Returns -1 if self isn’t found or if self contains ',' . |
Examples
fragment
Parse a URL and extract fragment identifier.
Examples
Returns
host
Parse a URL and extract host.
Examples
Returns
length
Compute the length of a string.
Returns
Name | Type | Description |
---|
| IntegerValue | The length of each string in the expression |
Examples
levenshtein
Return the Levenshtein distance between two strings.
Parameters
Name | Type | Description | Default |
---|
other | StringValue | String to compare to | required |
Returns
Name | Type | Description |
---|
| IntegerValue | The edit distance between the two strings |
Examples
lower
Convert string to all lowercase.
Returns
Examples
lpad
Pad arg
by truncating on the right or padding on the left.
Parameters
Returns
Examples
lstrip
Remove whitespace from the left side of string.
Returns
Examples
path
Parse a URL and extract path.
Examples
Returns
protocol
Parse a URL and extract protocol.
Examples
Returns
query
Parse a URL and returns query string or query string parameter.
If key is passed, return the value of the query string parameter named.
If key is absent, return the query string.
Parameters
Name | Type | Description | Default |
---|
key | str | StringValue | None | Query component to extract | None |
Examples
Returns
Return the specified match at index
from a regex pattern
.
Parameters
Name | Type | Description | Default |
---|
pattern | str | StringValue | Regular expression pattern string | required |
index | int | ir.IntegerValue | The index of the match group to return. The behavior of this function follows the behavior of Python’s match objects : when index is zero and there’s a match, return the entire match, otherwise return the content of the index -th match group. | required |
Returns
Name | Type | Description |
---|
| StringValue | Extracted match or whole string if index is zero |
Examples
Extract a specific group
Extract the entire match
re_replace
Replace all matches found by regex pattern
with replacement
.
Parameters
Name | Type | Description | Default |
---|
pattern | str | StringValue | Regular expression string | required |
replacement | str | StringValue | Replacement string or regular expression | required |
Returns
Examples
Replace all “a”s that are at the beginning of the string with “b”:
Double up any “a”s or “b”s, using capture groups and backreferences:
Normalize all whitespace to a single space:
re_search
Return whether the values match pattern
.
Returns True
if the regex matches a string and False
otherwise.
Parameters
Name | Type | Description | Default |
---|
pattern | str | StringValue | Regular expression use for searching | required |
Returns
Examples
re_split
Split a string by a regular expression pattern
.
Parameters
Name | Type | Description | Default |
---|
pattern | str | StringValue | Regular expression string to split by | required |
Returns
Name | Type | Description |
---|
| ArrayValue | Array of strings from splitting by pattern |
Examples
repeat
Repeat a string n
times.
Parameters
Returns
Examples
replace
Replace each exact match of pattern
with replacement
.
Parameters
Name | Type | Description | Default |
---|
pattern | StringValue | String pattern | required |
replacement | StringValue | String replacement | required |
Returns
Examples
reverse
Reverse the characters of a string.
Returns
Examples
right
Return up to nchars
from the end of each string.
Parameters
Name | Type | Description | Default |
---|
nchars | int | ir.IntegerValue | Maximum number of characters to return | required |
Returns
Examples
rpad
Pad self
by truncating or padding on the right.
Parameters
Returns
Examples
rstrip
Remove whitespace from the right side of string.
Returns
Examples
split
Split as string on delimiter
.
This API only works on backends with array support.
Parameters
Name | Type | Description | Default |
---|
delimiter | str | StringValue | Value to split by | required |
Returns
Name | Type | Description |
---|
| ArrayValue | The string split by delimiter |
Examples
startswith
Determine whether self
starts with start
.
Parameters
Name | Type | Description | Default |
---|
start | str | StringValue | prefix to check for | required |
Returns
Name | Type | Description |
---|
| BooleanValue | Boolean indicating whether self starts with start |
Examples
strip
Remove whitespace from left and right sides of a string.
Returns
Examples
substr
Extract a substring.
Parameters
Name | Type | Description | Default |
---|
start | int | ir.IntegerValue | First character to start splitting, indices start at 0 | required |
length | int | ir.IntegerValue | None | Maximum length of each substring. If not supplied, searches the entire string | None |
Returns
Examples
to_date
translate
Replace from_str
characters in self
characters in to_str
.
To avoid unexpected behavior, from_str
should be shorter than
to_str
.
Parameters
Name | Type | Description | Default |
---|
from_str | StringValue | Characters in arg to replace | required |
to_str | StringValue | Characters to use for replacement | required |
Returns
Examples
upper
Convert string to all uppercase.
Returns
Examples
userinfo
Parse a URL and extract user info.
Examples
Returns