[ 
https://issues.apache.org/jira/browse/HIVE-21062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16728503#comment-16728503
 ] 

Ravi Shetye commented on HIVE-21062:
------------------------------------

{noformat}
it seem it just trims away zeros - and packages it into the minimal type it 
fits.{noformat}
Yes, that is precisely what is happening, but would you agree that "packages it 
into the minimal type it fits" might not be the right thing to do?

for 1.200 hive prunes the insignificant zeros, and retains 1.2
{code:java}
0: jdbc:hive2://localhost:10000> select 1.200 ;
+------+
| _c0  |
+------+
| 1.2  |
+------+
1 row selected (0.221 seconds)
0: jdbc:hive2://localhost:10000> 
{code}
on older version of hive select 1.0 would return 1.0.
 on hive 1.2
{code:java}
0: jdbc:hive2://node1.ubuntu.localdomain:2181> select 1.0 ;
+------+--+
| _c0  |
+------+--+
| 1.0  |
+------+--+
{code}

corresponding plan 

{noformat}
+----------------------------------------------+--+
|                   Explain                    |
+----------------------------------------------+--+
| ABSTRACT SYNTAX TREE:                        |
|                                              |
| TOK_QUERY                                    |
|    TOK_INSERT                                |
|       TOK_DESTINATION                        |
|          TOK_DIR                             |
|             TOK_TMP_FILE                     |
|       TOK_SELECT                             |
|          TOK_SELEXPR                         |
|             1.0                              |
|                                              |
|                                              |
| STAGE DEPENDENCIES:                          |
|   Stage-0 is a root stage                    |
|                                              |
| STAGE PLANS:                                 |
|   Stage: Stage-0                             |
|     Fetch Operator                           |
|       limit: -1                              |
|       Processor Tree:                        |
|         TableScan                            |
|           alias: _dummy_table                |
|           Row Limit Per Split: 1             |
|           GatherStats: false                 |
|           Select Operator                    |
|             expressions: 1.0 (type: double)  |
|             outputColumnNames: _col0         |
|             ListSink                         |
|                                              |
+----------------------------------------------+--+
{noformat}

> Hive 2.X auto converts a round decimal to integer
> -------------------------------------------------
>
>                 Key: HIVE-21062
>                 URL: https://issues.apache.org/jira/browse/HIVE-21062
>             Project: Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 2.3.4
>            Reporter: Ravi Shetye
>            Priority: Major
>
> {noformat}
> 0: jdbc:hive2://localhost:10000> select 1.0 ;
> +------+
> | _c0  |
> +------+
> | 1    |
> +------+
> {noformat}
> It happens with parameters to functions as well
> {code:java}
> 0: jdbc:hive2://localhost:10000> select CONCAT("hi",1.0) ;
> +------+
> | _c0  |
> +------+
> | hi1  |
> +------+
> {code}
> Hive reads 1.0 as decimal(1,0), and then may be is converting it to int ?
> {code:java}
> 0: jdbc:hive2://localhost:10000> EXPLAIN EXTENDED select 1.0;
> +--------------------------------------------------+
> |                     Explain                      |
> +--------------------------------------------------+
> | STAGE DEPENDENCIES:                              |
> |   Stage-0 is a root stage                        |
> |                                                  |
> | STAGE PLANS:                                     |
> |   Stage: Stage-0                                 |
> |     Fetch Operator                               |
> |       limit: -1                                  |
> |       Processor Tree:                            |
> |         TableScan                                |
> |           alias: _dummy_table                    |
> |           Row Limit Per Split: 1                 |
> |           GatherStats: false                     |
> |           Select Operator                        |
> |             expressions: 1 (type: decimal(1,0))  |
> |             outputColumnNames: _col0             |
> |             ListSink                             |
> |                                                  |
> +--------------------------------------------------+
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to