Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-13812

Changing column from float to string group type will drop some factional digits

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.1
    • None
    • None
    • None

    Description

      Create a textfile table with a float column and insert some values:

      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> create table test(f float);
      No rows affected (0.237 seconds)
      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> insert into table test values(-35664.76171875),(29497.349609375);
      INFO  : Session is already open
      INFO  : Dag name: insert into table tes...5),(29497.349609375)(Stage-1)
      INFO  :
      
      INFO  : Status: Running (Executing on YARN cluster with App id application_1463771904371_0006)
      
      INFO  : Map 1: 0/1
      INFO  : Map 1: 0/1
      INFO  : Map 1: 0/1
      INFO  : Map 1: 0(+1)/1
      INFO  : Map 1: 1/1
      INFO  : Loading data to table default.test from hdfs://os-r6-pxwhrs-hiveserver2-3re-5.openstacklocal:8020/apps/hive/warehouse/test/.hive-staging_hive_2016-05-20_21-06-29_377_6487823927119226603-10/-ext-10000
      INFO  : Table default.test stats: [numFiles=1, numRows=2, totalSize=19, rawDataSize=17]
      No rows affected (11.069 seconds)
      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> select * from test;
      +------------------+--+
      |      test.f      |
      +------------------+--+
      | -35664.76171875  |
      | 29497.349609375  |
      +------------------+--+
      2 rows selected (0.137 seconds)
      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> describe test;
      +-----------+------------+----------+--+
      | col_name  | data_type  | comment  |
      +-----------+------------+----------+--+
      | f         | float      |          |
      +-----------+------------+----------+--+
      1 row selected (0.173 seconds)
      

      Then change float type to string successfully, but when you select table, some fractional digits are lost:

      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> alter table test change column f f string;
      No rows affected (0.214 seconds)
      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> describe test;
      +-----------+------------+----------+--+
      | col_name  | data_type  | comment  |
      +-----------+------------+----------+--+
      | f         | string     |          |
      +-----------+------------+----------+--+
      1 row selected (0.151 seconds)
      0: jdbc:hive2://os-r6-pxwhrs-hiveserver2-3re-> select * from test;
      +------------+--+
      |   test.f   |
      +------------+--+
      | -35664.76  |
      | 29497.35   |
      +------------+--+
      2 rows selected (0.141 seconds)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            taksaito Takahiko Saito
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: