title: Hive str_to_map
body: <p>I have a sample data as below
  Id(string),   delimProperties(string)<br>
  ==   ==============</p>
  
  <p>1, foo.prop=foo value|bar.prop=bar value<br>
  2, foo2.prop=foo2 value|bar2.prop=bar2 value</p>
  
  <p>Here is my dml<br>
  1)</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS test_data(Id STRING, delimProperties STRING)&lt;br&gt;
  row format delimited &lt;br&gt;
  fields terminated by ","&lt;br&gt;
  COLLECTION ITEMS TERMINATED BY '|' &lt;br&gt;
  map keys terminated by '='&lt;br&gt;
  STORED AS textfile;&lt;br&gt;
  </code></pre>
  
  <p>2)</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS final_data(Id STRING, delimProperties STRING)
  row format delimited
  fields terminated by ","
  COLLECTION ITEMS TERMINATED BY '|'
  map keys terminated by '=';
  </code></pre>
  
  <p>3)</p>
  
  <pre><code>alter table final_data add columns (properties map&lt;string,string&gt;);
  </code></pre>
  
  <p>4)</p>
  
  <pre><code>load data local inpath 'file:/c:/data/sample.csv' into table test_data;
  </code></pre>
  
  <p>5)</p>
  
  <pre><code>insert into table final_data select Id,
  str_to_map(delimproperties,'|','=')
  from test_data;
  </code></pre>
  
  <p>6)</p>
  
  <pre><code>Select * from final_data limit 1;
  </code></pre>
  
  <p>1                     {"":"", " ":null, ".":null}</p>
  
  <p>Any idea what I must be doing wrong?</p>