0

Why is the Hive split function returning two extra elements? My input string only has 4 characters but split returns an array with 6 elements.

hive> select split('TEST','');
OK
["","T","E","S","T",""]

My goal was to convert the input string to character array.

Dhiraj
  • 3,396
  • 4
  • 41
  • 80
  • 1
    Because your delimiter is empty, then it matches the empty before and after TEST as well – Dijkgraaf Jul 22 '16 at 01:41
  • But there is no empty before and after. I guess this is how it behaves. Anyway, thanks, I think I got the answer. – Dhiraj Jul 22 '16 at 01:43
  • You mean there is no space before and after the word. :-) It uses a regular expression, and so giving it an empty string as the split criteria would cause it to match before and after the last characters. – Dijkgraaf Jul 22 '16 at 01:58
  • @Dhiraj I described the issue here - https://stackoverflow.com/a/51044214/2271325 – Sergey Khudyakov Jun 26 '18 at 13:35

0 Answers0