Remove leading zeros using HiveQL

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Remove leading zeros using HiveQL



I have a string value in which i might have leading zero's, so i want to remove all leading zeros.



For example:


accNumber = "000340" ---> "340"



Any UDF is available in Hive? can we use regexp_extract for this?


regexp_extract




1 Answer
1



Yes, just use REGEXP_REPLACE().


REGEXP_REPLACE()


SELECT some_string,
REGEXP_REPLACE(some_string, "^0+", '') stripped_string
FROM db.tbl



(fixed simple typo with comma)





didn't know it. Thanks
– syadav
Jul 3 '16 at 6:51






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

PFaNHahnJYqI1 nrDUTyrD3QP7NOCqZht
aKau1l dzxaOgauom SiDMEhSVDKyD IvQzMaC090k7Di

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results