- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
in hive casting of decimal to double is returning the exponential form rather than the non scientific form
- Labels:
-
Apache Hive
Created 08-10-2017 09:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hive> select cast(12345678910.231 as double);
1.2345678910231E10
Time taken: 0.164 seconds, Fetched: 1 row(s)
but need the value 12345678910.231 stored as double.
select cast(cast(12345678910.231 as double) as double); also wont work and is similar as the above.
I dont need the output format to be change using the printf() UDF, rather i need the value to be stored and retrieved while querying as a non exponential form.
Created 08-10-2017 09:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The value that you are receiving is as expected, this sample java code show the info. If you are wanting to get the exact value as an output, you should convert that value to string.
import java.lang.*;
public class DoubleDemo
{
public static void main(String[] args)
{
double d = 12345678910.231;
System.out.println("Value of d = " + d);
}
}
Created 02-08-2018 09:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Team,
You can cast as decimal and solve the issue as shown below. ROUND(CAST(1.750646377E7 AS DECIMAL(38,10)),2);
Thanks & regards,
Kamleshkumar Gujarathi
