Description
`split_part()` is a commonly supported function by other systems such as Postgres and some other systems. The Spark equivalent is `element_at(split(arg, delim), part)`
Function Specificaiton
Syntax
split_part(str, delimiter, partNum)
Arguments
str: string type
delimiter: string type
partNum: Integer type
Note
1. This function splits `str` by `delimiter` and return requested part of the split (1-based). 2. If any input parameter is NULL, return NULL. 3. If the index is out of range of split parts, returns empty stirng. 4. If `partNum` is 0, throws an error. 5. If `partNum` is negative, the parts are counted backward from the end of the string 6. when delimiter is empty, str is considered not split thus there is just 1 split part.
Examples
> SELECT _FUNC_('11.12.13', '.', 3); 13 > SELECT _FUNC_(NULL, '.', 3); NULL > SELECT _FUNC_('11.12.13', '', 1); '11.12.13'