TRIM and RPAD functions are for processing String data type in Hive.
With TRIM function we can delete the spaces before and after a String. It is very useful for formatting user input in which user may have entered extra spaces. The other variations of TRIM function are LTRIM and RTRIM that remove spaces from left and right side of the string respectively.
E.g. TRIM(‘ Smith ’)
RPAD function is used to add padding (extra spaces) in a String on the right hand side. So that String reaches a specified length. LPAD function is same as RPAD but it pads on the left hand side of String.
E.g. Let say we have a String “Hello”.
We can also specify our optional padding character in RPAD and LPAD functions.
These functions are similar to the ones in SQL.