You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "phZhou (Jira)" <ji...@apache.org> on 2022/07/15 08:29:00 UTC
[jira] [Updated] (HIVE-26396) The trunc function has a problem with precision interception and the result has many 0
[ https://issues.apache.org/jira/browse/HIVE-26396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
phZhou updated HIVE-26396:
--------------------------
Docs Text: (was: The trunc function has a problem with precision interception and the result has many 0,There is a problem with the return when the data is of decimal type, and it is displayed normally when the data is of double type。The test is as follows:
1:Execute on beeline:
SELECT trunc(15.8963,3);
+------------------------+
| _c0 |
+------------------------+
| 15.896000000000000000 |
+------------------------+
1 row selected (0.074 seconds)
need return “15.896”is correct。
2.There is a problem with the return when the data is of decimal type, and it is displayed normally when the data is of double type:
SELECT trunc(cast(15.8963 as double),3);
+---------+
| _c0 |
+---------+
| 15.896 |
+---------+
1 row selected (0.075 seconds)
SELECT trunc(cast(15.8963 as decimal(24,12)),3) ;
+------------------------+
| _c0 |
+------------------------+
| 15.896000000000000000 |
+------------------------+
1 row selected (0.087 seconds)
3.There is a problem with the return when the data is of decimal type, and it is displayed normally when the data is of double type,contrary to the description “desc function extended trunc;”
| Example: | | >
>SELECT trunc('2009-02-12', 'MM'); | | OK | | '2009-02-01' | |
> SELECT trunc('2017-03-15', 'Q'); | | OK | | '2017-01-01' | |
> SELECT trunc('2015-10-27', 'YEAR'); | | OK | | '2015-01-01'
> SELECT trunc(1234567891.1234567891,4); | | OK | | 1234567891.1234 | |
> SELECT trunc(1234567891.1234567891,-4); | | OK | | 1234560000
> SELECT trunc(1234567891.1234567891,0); | | OK | | 1234567891 | | >
>SELECT trunc(1234567891.1234567891); | | OK | | 1234567891 | | )
> The trunc function has a problem with precision interception and the result has many 0
> --------------------------------------------------------------------------------------
>
> Key: HIVE-26396
> URL: https://issues.apache.org/jira/browse/HIVE-26396
> Project: Hive
> Issue Type: Bug
> Components: Hive
> Affects Versions: 3.1.3
> Environment: CDP7.1.7 ,RedHat7.6
> Reporter: phZhou
> Priority: Blocker
> Fix For: 3.2.0, 4.0.0, 4.0.0-alpha-2
>
>
> The trunc function has a problem with precision interception and the result has many 0,There is a problem with the return when the data is of decimal type, and it is displayed normally when the data is of double type。The test is as follows:
> 1:Execute on beeline:
> SELECT trunc(15.8963,3);
> +------------------------+
> | _c0 |
> +------------------------+
> | 15.896000000000000000 |
> +------------------------+
> 1 row selected (0.074 seconds)
> need return “15.896”is correct。
--
This message was sent by Atlassian Jira
(v8.20.10#820010)