Equivalent of split_function() in HIVE

Viewed 281

As per my project requirement I have come up with one complex logic which has 'a small section' as following:

    'regexp_extract(split_part(vw_cart.order_detail,':',2), '[0-9]+', 0)'

It works like a charm in IMPALA but fails in HIVE.

I am working on to find something similar to 'SPLIT_PART' for HIVE execution of my Code.

Any guidance will be helpful.

1 Answers

In Hive split() function returns array and array elements are numbered started from 0.

In Impala split_part(vw_cart.order_detail,':',2) - returns second element from delimited string, numbered from 1

So, in Hive it will be:

regexp_extract(split(vw_cart.order_detail,':')[1], '[0-9]+', 0)
Related