I have an id column and a string column as follows:
id values
1 AD123~DF123~SQ345
2 CF234~DF234
3 BG123
I need the first occurrence and last occurrence of columns below in Hive
id first last
1 AD123 SQ345
2 CF234 DF234
3 BG123 BG123
I have already tried using the HIVE split function to solve it
select id, split(values, '\~') [0] as first, reverse(split(reverse(values), '\~')[0]) from demo;
I keep getting a syntax error in Hive saying that [ is unexpected.
Another alternative I found is regex but I am new to Hive, can some one please help me out here with regex or split. Thanks