<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Hive is rounding the number columns automatically. in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108258#M33602</link>
    <description>&lt;P&gt;Decimal declaration format is decimal(precision,scale). Precision is the total number of digits including the digits after the decimal point. So , if you want a number for example 1001.23 the the decimal declaration should be decimal(6,2). Or decimal(4,2) for your given example of 15.56.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2016 17:20:43 GMT</pubDate>
    <dc:creator>apathak</dc:creator>
    <dc:date>2016-07-01T17:20:43Z</dc:date>
    <item>
      <title>Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108257#M33601</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a table where I have defined all the number fields as DECIMAL(38,0). Everytime I do inserts in this table it somehow automatically rounds the numbers. I would like to see the decimal values. eg 15.56 automatically becomes 16 when inserted into this table.&lt;/P&gt;&lt;P&gt;I have tried recreating the tables with INT datatype as well but it does the same.&lt;/P&gt;&lt;P&gt;P.S - The table is defined as an ORC, so that I can do updates and deletes too&lt;/P&gt;&lt;P&gt;Any suggestions if I can define another datatype?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 16:33:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108257#M33601</guid>
      <dc:creator>parinita</dc:creator>
      <dc:date>2016-07-01T16:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108258#M33602</link>
      <description>&lt;P&gt;Decimal declaration format is decimal(precision,scale). Precision is the total number of digits including the digits after the decimal point. So , if you want a number for example 1001.23 the the decimal declaration should be decimal(6,2). Or decimal(4,2) for your given example of 15.56.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 17:20:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108258#M33602</guid>
      <dc:creator>apathak</dc:creator>
      <dc:date>2016-07-01T17:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108259#M33603</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/319/apathak.html" nodeid="319"&gt;@apathak&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your quick response.&lt;/P&gt;&lt;P&gt;I created 2 tables with same structure and data type, one of them was an ORC table for ACID transactions and the other one was a normal table and I used DECIMAL(38,2) this time&lt;/P&gt;&lt;P&gt;When I do inserts in both of them, the normal table retains the decimals but the ORC table always rounds the number.&lt;/P&gt;&lt;P&gt;Is there some issue with ORC tables or am I missing out on some settings.&lt;/P&gt;&lt;P&gt;ORC TABLE :-&lt;/P&gt;&lt;PRE&gt;create table unica.FACT_PUNTER_ALL_MARKETS
(
  punter_key       DECIMAL(38,2),
  user_no          DECIMAL(38,2),
  user_name        STRING,
  provider         STRING,
  product_name     STRING,
  sub_product_name STRING,
  channel          STRING,
  indicator_name   STRING,
  indicator_value  DECIMAL(38,2),
  brand            STRING,
  country          STRING,
  time_zone        STRING,
  time_key         DECIMAL(38,2),
  calendar_date    STRING,
  jurisdiction     STRING,
  insert_time      STRING,
  source_table     STRING
)
clustered by (TIME_KEY) into 50 buckets stored as orc TBLPROPERTIES ('transactional' = 'true');
&lt;/PRE&gt;&lt;P&gt;NORMAL TABLE :-&lt;/P&gt;&lt;PRE&gt;create table unica.FACT_PUNTER_ALL_MARKETS_INCR
(
  punter_key       DECIMAL(38,2),
  user_no          DECIMAL(38,2),
  user_name        STRING,
  provider         STRING,
  product_name     STRING,
  sub_product_name STRING,
  channel          STRING,
  indicator_name   STRING,
  indicator_value  DECIMAL(38,2),
  brand            STRING,
  country          STRING,
  time_zone        STRING,
  time_key         DECIMAL(38,2),
  calendar_date    STRING,
  jurisdiction     STRING,
  insert_time      STRING,
  source_table     STRING
);
&lt;/PRE&gt;&lt;P&gt;INSERT STATEMENTS USED&lt;/P&gt;&lt;PRE&gt;-- normal table
insert into table unica.FACT_PUNTER_ALL_MARKETS_INCR
select * from unica.FACT_PUNTER_ALL_MARKETS_TEMP

-- orc table
insert into table unica.FACT_PUNTER_ALL_MARKETS
select * from unica.FACT_PUNTER_ALL_MARKETS_TEMP
&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Jul 2016 18:32:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108259#M33603</guid>
      <dc:creator>parinita</dc:creator>
      <dc:date>2016-07-01T18:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108260#M33604</link>
      <description>&lt;P&gt;38 digits is the max for Decimal. You cannot do Decimal(38,2) You could do Decimal(36,2) or Decimal (10,10 ) or whatever.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 20:06:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108260#M33604</guid>
      <dc:creator>bleonhardi</dc:creator>
      <dc:date>2016-07-01T20:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108261#M33605</link>
      <description>&lt;P&gt;tried with Decimal(36,2), still seeing the numbers getting rounded.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 23:00:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108261#M33605</guid>
      <dc:creator>parinita</dc:creator>
      <dc:date>2016-07-01T23:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108262#M33606</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/1662/parinitakothari.html" nodeid="1662"&gt;@Parinita Kothari&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;I tried with hive ver. 1.2.1 and I couldn't reproduce your issue as shown in the below.&lt;/P&gt;&lt;P&gt;What version of hive are you using?&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; set hive.support.concurrency=true;
hive&amp;gt; set hive.enforce.bucketing=true;
hive&amp;gt; set hive.exec.dynamic.partition.mode=nonstrict;
hive&amp;gt; set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
hive&amp;gt; set hive.compactor.initiator.on=true;
hive&amp;gt; create table test_decimal(i int, time_key         DECIMAL(38,2)) clustered by (TIME_KEY) into 16 buckets stored as orc TBLPROPERTIES ('transactional' = 'true');
OK
Time taken: 0.557 seconds
hive&amp;gt; insert into table test_decimal values(1, 15.56);
Query ID = hrt_qa_20160702163059_7e2c279f-158e-4477-9123-357db69075b9
Total jobs = 1
Launching Job 1 out of 1
Status: Running (Executing on YARN cluster with App id application_1467208466253_0268)
--------------------------------------------------------------------------------
        VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
--------------------------------------------------------------------------------
Map 1 ..........   SUCCEEDED      1          1        0        0       0       0
Reducer 2 ......   SUCCEEDED     16         16        0        0       0       0
--------------------------------------------------------------------------------
VERTICES: 02/02  [==========================&amp;gt;&amp;gt;] 100%  ELAPSED TIME: 44.74 s
--------------------------------------------------------------------------------
Loading data to table default.test_decimal
Table default.test_decimal stats: [numFiles=1, numRows=1, totalSize=655, rawDataSize=0]
OK
Time taken: 49.152 seconds
hive&amp;gt; select * from test_decimal;
OK
115.56
Time taken: 0.282 seconds, Fetched: 1 row(s)&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Jul 2016 23:35:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108262#M33606</guid>
      <dc:creator>tsaito</dc:creator>
      <dc:date>2016-07-02T23:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Hive is rounding the number columns automatically.</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108263#M33607</link>
      <description>&lt;P&gt;Thank you guys! &lt;A rel="user" href="https://community.cloudera.com/users/333/tsaito.html" nodeid="333"&gt;@Takahiko Saito&lt;/A&gt; &lt;A rel="user" href="https://community.cloudera.com/users/168/bleonhardi.html" nodeid="168"&gt;@Benjamin Leonhardi&lt;/A&gt; &lt;A rel="user" href="https://community.cloudera.com/users/319/apathak.html" nodeid="319"&gt;@apathak&lt;/A&gt;  I tried changing the number fields to Decimal(36,2) again and this time it works without any problem.&lt;/P&gt;&lt;P&gt;Thanks once again for your quick response.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 17:33:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-is-rounding-the-number-columns-automatically/m-p/108263#M33607</guid>
      <dc:creator>parinita</dc:creator>
      <dc:date>2016-07-04T17:33:10Z</dc:date>
    </item>
  </channel>
</rss>

