<?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- escaping field delimiter in column value in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/294296#M217173</link>
    <description>&lt;P&gt;Hi Manoj,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are using textfiles with separationchar as '|', but the problem we have embedded new lines in columns which is resulting data empty in hive as its considering as new line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rest data is migrating perfectly fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please suggest us how to avoid new line characters in between column-data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;amp;Regards&lt;/P&gt;&lt;P&gt;Sreeja&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 19 Apr 2020 11:44:11 GMT</pubDate>
    <dc:creator>sreeja1</dc:creator>
    <dc:date>2020-04-19T11:44:11Z</dc:date>
    <item>
      <title>Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233346#M195173</link>
      <description>&lt;P&gt;My dataset set is as below:&lt;/P&gt;&lt;P&gt;700,Angus (1995),Comedy &lt;/P&gt;&lt;P&gt;702,Faces (1968),Drama &lt;/P&gt;&lt;P&gt;703,Boys (1996),Drama &lt;/P&gt;&lt;P&gt;704,"Quest, The (1996)",Action|Adventure &lt;/P&gt;&lt;P&gt;705,Cosi (1996),Comedy&lt;/P&gt;&lt;P&gt;747,"Stupids, The (1996)",Comedy&lt;/P&gt;&lt;PRE&gt;Create table movies(
movieid int,
title String,
genre string)
row format delimited
fields terminated by ','
;

Select title , genre from movies;

&lt;/PRE&gt;&lt;P&gt;Since the rows have comma separated values, the records like&lt;STRONG&gt; &lt;/STRONG&gt;&lt;STRONG&gt;704,"Quest, The (1996)",Action|Adventure &lt;/STRONG&gt;returns &lt;STRONG&gt;Quest &lt;/STRONG&gt;as title, instead of  &lt;STRONG&gt;Quest,The (1996).&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;And Genre value is shown as &lt;STRONG&gt;The(1996) &lt;/STRONG&gt;instead of &lt;STRONG&gt;Action|Adventure.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;How to load such data correctly by escaping the delimiter in the value ?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 04:42:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233346#M195173</guid>
      <dc:creator>rmy1712</dc:creator>
      <dc:date>2017-08-25T04:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233347#M195174</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/30206/rmy1712.html" nodeid="30206"&gt;@Ramya Jayathirtha&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Try the following:&lt;/P&gt;&lt;P&gt;create table movies( &lt;/P&gt;&lt;P&gt;movieid int, &lt;/P&gt;&lt;P&gt;title String, &lt;/P&gt;&lt;P&gt;genre string) &lt;/P&gt;&lt;P&gt;ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'&lt;/P&gt;&lt;P&gt;This should resolve your issue as the OpenCSVSerde's default properties should work for your use case.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 05:49:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233347#M195174</guid>
      <dc:creator>ssahi</dc:creator>
      <dc:date>2017-08-25T05:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233348#M195175</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/30206/rmy1712.html" nodeid="30206"&gt;@Ramya Jayathirtha&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Adding to &lt;A rel="user" href="https://community.cloudera.com/users/12636/ssahi.html" nodeid="12636"&gt;@Sonu Sahi&lt;/A&gt;'s reply, the CSVSerde is available in &lt;A href="https://issues.apache.org/jira/browse/HIVE-7777"&gt;Hive 0.14&lt;/A&gt; and greater.
The following example creates a TSV (Tab-separated) file.&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&amp;lt;code&amp;gt;CREATE&lt;/CODE&gt; &lt;CODE&gt;TABLE&lt;/CODE&gt; &lt;CODE&gt;my_table(a string, b string, ...)&lt;/CODE&gt;&lt;/P&gt;&lt;CODE&gt;ROW FORMAT SERDE &lt;/CODE&gt;&lt;CODE&gt;'org.apache.hadoop.hive.serde2.OpenCSVSerde'&lt;/CODE&gt;&lt;CODE&gt;WITH&lt;/CODE&gt; &lt;CODE&gt;SERDEPROPERTIES (&lt;/CODE&gt;
&lt;CODE&gt;"separatorChar"&lt;/CODE&gt; &lt;CODE&gt;= &lt;/CODE&gt;&lt;CODE&gt;"\t"&lt;/CODE&gt;&lt;CODE&gt;,&lt;/CODE&gt;
&lt;CODE&gt;"quoteChar"&lt;/CODE&gt; &lt;CODE&gt;= &lt;/CODE&gt;&lt;CODE&gt;"'"&lt;/CODE&gt;&lt;CODE&gt;,&lt;/CODE&gt;
&lt;CODE&gt;"escapeChar"&lt;/CODE&gt; &lt;CODE&gt;= &lt;/CODE&gt;&lt;CODE&gt;"\\"&lt;/CODE&gt;
&lt;CODE&gt;) &lt;/CODE&gt;
&lt;CODE&gt;STORED &lt;/CODE&gt;&lt;CODE&gt;AS&lt;/CODE&gt; &lt;CODE&gt;TEXTFILE;&lt;/CODE&gt;
Default properties for SerDe is Comma-Separated (CSV) file&lt;DIV&gt;&lt;CODE&gt;DEFAULT_ESCAPE_CHARACTER \&lt;/CODE&gt;&lt;/DIV&gt;&lt;DIV&gt;
&lt;CODE&gt;DEFAULT_QUOTE_CHARACTER  "&lt;/CODE&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;CODE&gt;DEFAULT_SEPARATOR  ,&lt;/CODE&gt;
&lt;P&gt;This SerDe works for most CSV data, but does not handle embedded newlines. To use the SerDe, specify the fully qualified class name org.apache.hadoop.hive.serde2.OpenCSVSerde.&lt;/P&gt;&lt;P&gt;If you want to use the TextFile format, then use 'ESCAPED BY' in the DDL.&lt;/P&gt;&lt;P&gt;"&lt;EM&gt;Enable escaping for the delimiter characters by using the 'ESCAPED BY' clause (such as ESCAPED BY '\') &lt;BR /&gt;Escaping is needed if you want to work with data that can contain these delimiter characters. &lt;BR /&gt;&lt;BR /&gt;A custom NULL format can also be specified using the 'NULL DEFINED AS' clause (default is '\N').&lt;/EM&gt;"&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 25 Aug 2017 14:33:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233348#M195175</guid>
      <dc:creator>ssubhas</dc:creator>
      <dc:date>2017-08-25T14:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233349#M195176</link>
      <description>&lt;P&gt;Thank you &lt;A rel="user" href="https://community.cloudera.com/users/5019/ssubhas.html" nodeid="5019"&gt;@Sindhu&lt;/A&gt; for the elaborate explanation and the solution..!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 03:04:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233349#M195176</guid>
      <dc:creator>rmy1712</dc:creator>
      <dc:date>2017-08-28T03:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233350#M195177</link>
      <description>&lt;P&gt;Thank You &lt;A rel="user" href="https://community.cloudera.com/users/12636/ssahi.html" nodeid="12636"&gt;@Sonu Sahi&lt;/A&gt; for the solution.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 03:05:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233350#M195177</guid>
      <dc:creator>rmy1712</dc:creator>
      <dc:date>2017-08-28T03:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233351#M195178</link>
      <description>&lt;P&gt;I have the same situation in log file. My data set looks like this &lt;/P&gt;&lt;P&gt;2017-11-29 16:19:39,217 DEBUG Conn -&amp;gt; 8=FIXT.1.1|9=76|35=A &lt;/P&gt;&lt;P&gt;2017-11-29 16:19:43,618 DEBUG Conn -&amp;gt; 8=FIXT.1.1|9=52|35=0|49=1151|56=BSEEQ|34=2 &lt;/P&gt;&lt;P&gt;How to handle this Regex serde.
my create table query is: &lt;/P&gt;&lt;P&gt;CREATE TABLE capital_log1 ( date STRING, filed2 STRING, filed3 STRING, filed4 STRING,filed7 map&amp;lt;bigint,string&amp;gt;)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' WITH SERDEPROPERTIES 
( "input.regex" = "([^ ]*) ([^,]*)([^ ]*) (.*\-&amp;gt;) (.*\|)", "output.format.string" = "%1$s %2$s %3$s %4$s %5$s" )
 STORED AS TEXTFILE;
 It throws me an exception.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Feb 2018 11:39:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233351#M195178</guid>
      <dc:creator>rajkiranu</dc:creator>
      <dc:date>2018-02-27T11:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233352#M195179</link>
      <description>&lt;P&gt;Hello Sir,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;How do we store if via ETL layer '\n' is manipulated as '\\n'. org.apache.hadoop.hive.serde2.OpenCSVSerde  does not work as data gets misaligned. Is there any way to load it without preprocessing?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2019 03:11:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/233352#M195179</guid>
      <dc:creator>srini93vasan</dc:creator>
      <dc:date>2019-03-26T03:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/282191#M209822</link>
      <description>&lt;P&gt;as you said,the escapeChar '\n' doesn't work? such as "the great wall&lt;/P&gt;&lt;P&gt;in china",although used escapeChar '\n' ,the result were resolved into "the great wall",NULL.&lt;/P&gt;&lt;P&gt;rather than "the great wall in china" in hive table?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 10:26:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/282191#M209822</guid>
      <dc:creator>bluecean</dc:creator>
      <dc:date>2019-11-06T10:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/288284#M213545</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use (ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde') as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create Table tablename (columns)&amp;nbsp;ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Manoj&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 17:04:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/288284#M213545</guid>
      <dc:creator>Manoj_hadoop</dc:creator>
      <dc:date>2020-01-24T17:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/294296#M217173</link>
      <description>&lt;P&gt;Hi Manoj,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are using textfiles with separationchar as '|', but the problem we have embedded new lines in columns which is resulting data empty in hive as its considering as new line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rest data is migrating perfectly fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you please suggest us how to avoid new line characters in between column-data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;amp;Regards&lt;/P&gt;&lt;P&gt;Sreeja&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 11:44:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/294296#M217173</guid>
      <dc:creator>sreeja1</dc:creator>
      <dc:date>2020-04-19T11:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hive- escaping field delimiter in column value</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/350424#M235969</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/56976"&gt;@ssubhas&lt;/a&gt;&amp;nbsp;, the above worked however, when we try the same with LazySerde, it is able to escape the delimiter but loads few NULL values at the end. PFB snippet of statement I used: CREATE TABLE test1(5columns string)&lt;/P&gt;&lt;P&gt;ROW FORMAT SERDE&lt;/P&gt;&lt;P&gt;'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'&lt;/P&gt;&lt;P&gt;WITH SERDEPROPERTIES(&lt;/P&gt;&lt;P&gt;'separatorChar'='|',&lt;/P&gt;&lt;P&gt;'escapeChar'='\\'&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;STORED AS INPUTFORMAT&lt;/P&gt;&lt;P&gt;'org.apache.hadoop.mapred.TextInputFormat'&lt;/P&gt;&lt;P&gt;OUTPUTFORMAT&lt;/P&gt;&lt;P&gt;'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: also tried field.delim=|, format.serialization=|.&lt;/P&gt;&lt;P&gt;It works when serde properties are not mentioned and we use escape by Clause as you suggested, any way to make it work with LazySerde as well? (Data is Pipe delimited &amp;amp; may also have pipe in the data). Please suggest and help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 11:26:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Hive-escaping-field-delimiter-in-column-value/m-p/350424#M235969</guid>
      <dc:creator>cdsuya</dc:creator>
      <dc:date>2022-08-19T11:26:11Z</dc:date>
    </item>
  </channel>
</rss>

