Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Change numbers to a three significant digits format in Hive?

Highlighted

Change numbers to a three significant digits format in Hive?

New Contributor

We are working with HQL and facing problems in getting numbers in a certain format.
We want to accomplish the following:

input: 0.000000098812
output: 9.88E-8

We don't want any digits after the first three significant digits.

Can someone please help us out?

1 REPLY 1

Re: Change numbers to a three significant digits format in Hive?

Super Guru

@Apoorva Sharma

You can use Regexp_extract and extract only the required digits.

refer to this link for more details regards to regexp_extract in hive.

Let us know if you have any issues..!!