Hive从双重转换为字符串不在科学中 [英] Hive Converting from Double to String Not in Scientific
问题描述
我有一个列双列的表,我试图将它从double转换为string。然而,当我使用cast命令时,它会巧妙地将其转换为科学记数法。如下所示:
select
数字,
cast(数字为字符串),
从...
它看起来像
编号c1_
9999999902 9.999999902E9
9999999902 9.999999902E9
9999999902 9.999999902E9
9999999902 9.999999902E9
9999999909 9.999999909E9
任何人都可以告诉我如何避免将其转化为科学并保留原始文本?
Hive在转换为字符串时将double转换为科学表示形式,因为Hive以相同方式处理double本身。因此,问题不在于转换为字符串。
请参阅下面的示例:
选择9999999902.0,投射(9999999902.0作为BIGINT),投射(作为字符串投射(9999999902.0作为BIGINT))从..
输出:
确定
9.999999902E9 9999999902
I have a table with a column double type, and I am trying to convert that from double to string.
However, when I use the cast command, it "smartly" convert that into scientific notation. like below:
select
number,
cast(number as string),
from ...
it looks like
number c1_
9999999902 9.999999902E9
9999999902 9.999999902E9
9999999902 9.999999902E9
9999999902 9.999999902E9
9999999909 9.999999909E9
Can anyone show me how to avoid converting that into scientific and keep the raw text?
Hive converts double to scientific representation while cast to string because Hive treats double itself in a same way. Therefore, problem is not with cast to string.
See below example:
select 9999999902.0, cast(9999999902.0 as BIGINT), cast(cast(9999999902.0 as BIGINT) as string) from ..
Output:
OK
9.999999902E9 9999999902
这篇关于Hive从双重转换为字符串不在科学中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!