How can I split a field with an array of multiple values, similar to SPLIT(T.field," ")[2]?

Alec Judd
  • Edited

To accomplish this, you can use the element_at function to return a value given a specific index.  You can find more information on the apache spark sql functions website.

Syntax: element_at(array, index)

Below is an example of this in use.  It returns the second value in the array.

> SELECT element_at(array(1, 2, 3), 2); 
2
0

Comments

0 comments

Please sign in to leave a comment.