Returning Nth element from the list – Apache Hive

The ELT function in Apache Hive helps in retrieving the Nth element from the list of the strings provided. This is equivalent to ELT in MySQL.

This function returns NULL if N is less than 1 or greater than the number of arguments. ELT() is the complement of FIELD().

Syntax: elt(N int,str1 string,str2 string,str3 string,…)

hive> SELECT ELT(1, ‘Aa’, ‘Bb’, ‘Cc’, ‘Dd’);
Returns ‘Aa’
hive> SELECT ELT(4, ‘Aa’, ‘Bb’, ‘Cc’, ‘Dd’);
Returns ‘Dd’

Please click on the follow button to receive updates on latest posts.

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s