Categories

Jan 12 in Big Data | Hadoop
Q: How TRIM and RPAD functions work in Hive?

1 Answer

Jan 12
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,’ ')

Hello

 

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

These functions are similar to the ones in SQL.
Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Jan 12 in Big Data | Hadoop
Jan 11 in Big Data | Hadoop
Feb 22 in Big Data | Hadoop
...