title: How to access the last element in an array ?
body: <p>In my hive table, the <code>session</code> field is a string in format like:</p>
  
  <p><code>ip-sessionID-userID</code> or <code>area-sessionID-userID</code></p>
  
  <p>There's 3 or 4 fields separated by "<code>-</code>", but userID is always the last one.</p>
  
  <p>i wanna select userID, but how to access the last field? In python, there's something like:
  <code>
  arr[-1]
  </code></p>
  
  <p>but in hive, how to achieve this? The following SQL seems not correct.</p>
  
  <p><code>
  select split(session,"\-")[-1] as user from my_table;
  </code></p>
  
  <p>Thanks!</p>