<?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 Table Default Format in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220989#M182863</link>
    <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;. &lt;/P&gt;&lt;P&gt;So if input file is tab delimited and it says create hive table with default format, then just : &lt;/P&gt;&lt;P&gt;"create table mydb.user (uid int,name string) row format delimited fields terminated by '\t' ; " &lt;/P&gt;&lt;P&gt;should be sufficient. This will create table with tab delimiter, and it will take file storage from default format which is TextFile. (hive.default.fileformat)&lt;/P&gt;&lt;P&gt;Thanking you&lt;/P&gt;&lt;P&gt;Santanu&lt;/P&gt;</description>
    <pubDate>Fri, 20 Apr 2018 00:05:33 GMT</pubDate>
    <dc:creator>Santanu</dc:creator>
    <dc:date>2018-04-20T00:05:33Z</dc:date>
    <item>
      <title>Hive Table Default Format</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220987#M182861</link>
      <description>&lt;P&gt;Hello Friends, &lt;/P&gt;&lt;P&gt;I have couple of questions related to Hive and I am confused about the correct answer. &lt;/P&gt;&lt;P&gt;Q1: What is the correct way to define default Hive table ? &lt;/P&gt;&lt;P&gt;Q2: Also, what is the default delimiter for Hive table ? &lt;/P&gt;&lt;P&gt;In other words, requirement says create hive table with default format. &lt;/P&gt;&lt;P&gt;Now I am checking "set hive.default.fileformat;" on hive cli. It is showing "TextFile". &lt;/P&gt;&lt;P&gt;So I am creating the Hive table like : create table mydb.user (uid int,name string) ; &lt;/P&gt;&lt;P&gt;
But it is creating table with Row Format "LazySimpleSerDe" and without any delimiter. &lt;/P&gt;&lt;P&gt;Is this correct way to define default hive table ? &lt;/P&gt;&lt;P&gt;Or shall I define it as : create table mydb.user (uid int,name string) row format delimited fields terminated by '\t' ;&lt;/P&gt;&lt;P&gt;Because, in this case it is showing Row Format "DELIMITED" and Fields Terminated By '\t'. &lt;/P&gt;&lt;P&gt;Thanking you &lt;/P&gt;&lt;P&gt;Santanu&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 15:59:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220987#M182861</guid>
      <dc:creator>Santanu</dc:creator>
      <dc:date>2018-04-19T15:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Hive Table Default Format</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220988#M182862</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/26178/sanutopia.html" nodeid="26178"&gt;@Santanu Ghosh&lt;BR /&gt;&lt;/A&gt;&lt;STRONG&gt;Q1:
What is the correct way to define default Hive table ?&lt;/STRONG&gt;
&lt;/P&gt;&lt;P&gt;It
depends on how you datafile is delimited &lt;/P&gt;&lt;P&gt;if your datafile is delimited with
&lt;STRONG&gt;^A(ctrl-a)&lt;/STRONG&gt; then you&lt;STRONG&gt; don’t need to specify any delimiter,&lt;/STRONG&gt;because hive default delimiter is ^A(ctrl-a) in ASCII. in this case if we do desc formatted &amp;lt;table-name&amp;gt;; hive doesn't shows any delimiter because table is created with default delimiter i.e ^A&lt;/P&gt;&lt;P&gt;If
your datafile is &lt;STRONG&gt;comma delimited&lt;/STRONG&gt; then we need to create table with &lt;STRONG&gt;row format
delimited fields terminated by ','.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;when we created table with &lt;STRONG&gt;create table mydb.user (uid int,name string); &lt;/STRONG&gt;this ddl statement without &lt;STRONG&gt;any format and delimiters &lt;/STRONG&gt;then hive creates user table with default serde (serialize,deserializer ). This serde instructs hive on how to process a record (Row) and serde library is inbuilt to Hadoop API.&lt;/P&gt;&lt;PRE&gt;Default serde --&amp;gt;  LazySimpleSerDe&amp;lt;br&amp;gt;Default InputFormat --&amp;gt; TextInputFormat&amp;lt;br&amp;gt;Default OutputFormat --&amp;gt; HiveIgnoreKeyTextOutputFormat&amp;lt;br&amp;gt;Default Delimiter --&amp;gt; ^A(ctrl-a) //although the delimiter is not showing in desc formatted &amp;lt;table-name&amp;gt;;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Q2:
Also, what is the default delimiter for Hive table ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;By
default, tables are assumed to be of text input format and the &lt;STRONG&gt;delimiters are
assumed to be ^A(ctrl-a).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Please
refer to &lt;A href="https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-DDLOperations" target="_blank"&gt;this&lt;/A&gt; link for more details regarding hive ddl operations.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Q3:
create table mydb.user (uid int,name string) row format delimited fields
terminated by '\t' ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;If
we define table with specified delimiter so that’s the reason why you are able
to see delimiter as \t in desc formatted table command.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 22:12:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220988#M182862</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2018-04-19T22:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Hive Table Default Format</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220989#M182863</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;. &lt;/P&gt;&lt;P&gt;So if input file is tab delimited and it says create hive table with default format, then just : &lt;/P&gt;&lt;P&gt;"create table mydb.user (uid int,name string) row format delimited fields terminated by '\t' ; " &lt;/P&gt;&lt;P&gt;should be sufficient. This will create table with tab delimiter, and it will take file storage from default format which is TextFile. (hive.default.fileformat)&lt;/P&gt;&lt;P&gt;Thanking you&lt;/P&gt;&lt;P&gt;Santanu&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 00:05:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220989#M182863</guid>
      <dc:creator>Santanu</dc:creator>
      <dc:date>2018-04-20T00:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hive Table Default Format</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220990#M182864</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/26178/sanutopia.html" nodeid="26178"&gt;@Santanu Ghosh&lt;/A&gt;
&lt;/P&gt;&lt;P&gt;That's correct.Just create table with &lt;STRONG&gt;\t &lt;/STRONG&gt;delimited then the hive can read the file with the delimiter specified.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Creating Tab delimited table in Hive:-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm having tab delimited file in hdfs&lt;/P&gt;&lt;PRE&gt;bash$ hadoop fs -cat /apps/hive/warehouse/t1/t.txt&amp;lt;br&amp;gt;1\tfoo
&lt;/PRE&gt;&lt;P&gt;I have created a table in hive with tab delimited as&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; create table default.t1 (id string,name string) row format delimited fields terminated by '\t';&lt;/PRE&gt;&lt;P&gt;Do &lt;STRONG&gt;desc formatted default.t1;&lt;/STRONG&gt; to see the &lt;STRONG&gt;delimiter for the table&lt;/STRONG&gt; and all the &lt;STRONG&gt;Serde,Input,Output Formats&lt;/STRONG&gt; are set to be&lt;STRONG&gt; default&lt;/STRONG&gt;(as mentioned in the above answer).&lt;/P&gt;&lt;PRE&gt;# Storage Information         | NULL                                                        | NULL 
SerDe Library:                | org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe          | NULL 
InputFormat:                  | org.apache.hadoop.mapred.TextInputFormat                    | NULL 
OutputFormat:                 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat  | NULL 
Compressed:                   | No                                                          | NULL 
Storage Desc Params:          | NULL                                                        | NULL 
                              | field.delim                                                 | \t   
&lt;/PRE&gt;&lt;P&gt;Now check the data in t1 table&lt;/P&gt;&lt;PRE&gt;hive&amp;gt; select * from default.t1;
+--------+----------+--+
| t1.id  | t1.name  |
+--------+----------+--+
| 1      | foo      |
+--------+----------+--+&lt;/PRE&gt;&lt;P&gt;Hive read the input tab delimited t.txt file and shown the results.&lt;/P&gt;&lt;P&gt;Let me know if you are having any additional questions..!!&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;If the Answer Addressed your question,&lt;STRONG&gt; Click on Accept button below to accept the answer&lt;/STRONG&gt;, That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 00:32:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220990#M182864</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2018-04-20T00:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Hive Table Default Format</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220991#M182865</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt; for the explanation. I really appreciate it.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 11:27:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-Table-Default-Format/m-p/220991#M182865</guid>
      <dc:creator>Santanu</dc:creator>
      <dc:date>2018-04-20T11:27:35Z</dc:date>
    </item>
  </channel>
</rss>

