<?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 Hive ignoring data type declarations in create table statement in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152840#M40684</link>
    <description>&lt;P&gt;I am creating an external table with some fields that are numeric decimals.  I have tried declaring them as floats, doubles, and decimal formats, but hive is casting them as strings regardless.  &lt;/P&gt;&lt;P&gt;Here is a sample of the query:  &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create external table sapbw.copa_ods(&lt;EM&gt;currency_type  string, cost_for_fi decimal,
                                                                        gross_margin_fi decimal, sales_for_fi decimal&lt;/EM&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;
stored as textfile&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;
location &lt;/STRONG&gt;&lt;STRONG&gt;'/data_LZ/BW/COPA_ODS';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Why is this happening?&lt;/P&gt;</description>
    <pubDate>Thu, 15 Sep 2016 02:16:27 GMT</pubDate>
    <dc:creator>joshua_persinge</dc:creator>
    <dc:date>2016-09-15T02:16:27Z</dc:date>
    <item>
      <title>Hive ignoring data type declarations in create table statement</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152840#M40684</link>
      <description>&lt;P&gt;I am creating an external table with some fields that are numeric decimals.  I have tried declaring them as floats, doubles, and decimal formats, but hive is casting them as strings regardless.  &lt;/P&gt;&lt;P&gt;Here is a sample of the query:  &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create external table sapbw.copa_ods(&lt;EM&gt;currency_type  string, cost_for_fi decimal,
                                                                        gross_margin_fi decimal, sales_for_fi decimal&lt;/EM&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;
stored as textfile&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;
location &lt;/STRONG&gt;&lt;STRONG&gt;'/data_LZ/BW/COPA_ODS';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Why is this happening?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 02:16:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152840#M40684</guid>
      <dc:creator>joshua_persinge</dc:creator>
      <dc:date>2016-09-15T02:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Hive ignoring data type declarations in create table statement</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152841#M40685</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/7629/joshuapersinger.html" nodeid="7629"&gt;@Josh Persinger&lt;/A&gt;&lt;P&gt;May be someone else can confirm but I think you are storing the data as text format so it is storing it as a string. When loading the data in memory it will be loaded as decimal. The on disk representation varies based on file format. &lt;/P&gt;&lt;P&gt;Try creating data in Avro or ORC format and see if it retains the data type as Decimal.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 02:28:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152841#M40685</guid>
      <dc:creator>mqureshi</dc:creator>
      <dc:date>2016-09-15T02:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Hive ignoring data type declarations in create table statement</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152842#M40686</link>
      <description>&lt;P&gt;I just tried following the method shown here:  &lt;A href="https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.0/bk_dataintegration/content/moving_data_from_hdfs_to_hive_external_table_method.html"&gt;https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.0/bk_dataintegration/content/moving_data_from_hdfs_to_hive_external_table_method.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I created the ORC table and it still stores everything as a string&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 02:50:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152842#M40686</guid>
      <dc:creator>joshua_persinge</dc:creator>
      <dc:date>2016-09-15T02:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Hive ignoring data type declarations in create table statement</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152843#M40687</link>
      <description>&lt;P&gt;Found the culprit, it's the CSVSerde, it casts all fields as strings.  &lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2016 03:05:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Hive-ignoring-data-type-declarations-in-create-table/m-p/152843#M40687</guid>
      <dc:creator>joshua_persinge</dc:creator>
      <dc:date>2016-09-15T03:05:12Z</dc:date>
    </item>
  </channel>
</rss>

