How to reverse words in a string in HIVE?

181 Views Asked by At

Is it possible to reverse the order of words in a string, which are separated by a single space, in Hive SQL?

I saw there are function like reverse but it only work for string (ofc, we can use it to reverse words by doing 1) reverse whole string 2) reverse each word, it's easy to written in java or other language, but I am not sure how to do it in SQL).

Any ideas?

For example,

// assuming I have one column field in a table like 
WITH example_data AS (
  SELECT "I am learning Hive SQL" as my_string
)

I want to return "SQL Hive learning am I". 
0

There are 0 best solutions below