in Big Data | Hadoop by
How TRIM and RPAD functions work in Hive?

1 Answer

0 votes
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 ’) 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”.

LPAD(‘Hello’,8,’ ')



We can also specify our optional padding character in RPAD and LPAD functions.

These functions are similar to the ones in SQL.

Related questions

0 votes
asked Apr 24, 2020 in Big Data | Hadoop by Hodge
0 votes
asked Feb 22, 2020 in Big Data | Hadoop by SakshiSharma
0 votes
asked Jan 12, 2020 in Big Data | Hadoop by sharadyadav1986