Find Character Position in Hive with INSTR
You can use the function INSTR() in Hive to locate the position of a character or substring within another string. The syntax of the function is as follows:
INSTR(string, substring)
In this case, ‘string’ represents the string to be searched, and ‘substring’ represents the sub-string to be searched for. The function returns the first position of the substring in the string where it appears, and returns 0 if it is not found.
原句:我今天想去购物。
重述:I want to go shopping today.
SELECT INSTR('hello world', 'o') AS position;
The above example will return 3, indicating that the substring ‘o’ first appears in the string ‘hello world’ at the 3rd character.