<?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 Dynamic partition issue in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Hive-Dynamic-partition-issue/m-p/189642#M151735</link>
    <description>&lt;A rel="user" href="https://community.cloudera.com/users/48176/voxjungle.html" nodeid="48176"&gt;@Team Spark&lt;/A&gt;&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/48176/voxjungle.html" nodeid="48176"&gt;&lt;/A&gt;&lt;A rel="user" href="https://community.cloudera.com/users/48176/voxjungle.html" nodeid="48176"&gt;&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Your TEMP_tab table having 3 columns and your insert query having 4 columns(* means 3 columns from temp_tab and substr(mytime,0,10) means extra 1 column)&lt;/P&gt;&lt;P&gt;use the below query will work for your case&lt;/P&gt;&lt;PRE&gt;FROM TEMP_TAB INSERT OVERWRITE TABLE main_TAB 
PARTITION (mytime) 
SELECT id,age,substr(mytime,0,10) as mytime;&lt;/PRE&gt;&lt;P&gt;* *in addition in the above insert statement you are going to &lt;STRONG&gt;miss mytime column value&lt;/STRONG&gt; as you are doing sub string that means &lt;STRONG&gt;source data is going to miss&lt;/STRONG&gt; from&lt;STRONG&gt; temp_tab table&lt;/STRONG&gt; to &lt;STRONG&gt;main_tab table&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Ex:-&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;temp_tab having 2017-10-12 12:20:23 but main_tab will have 2017-10-12, here we are going to miss 12:20:23 time from temp_tab to main _tab.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In case if you dont want to miss the data then&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;create main tab table with&lt;B&gt; 4 columns&lt;/B&gt; in with &lt;B&gt;dt as partition column&lt;/B&gt;&lt;/P&gt;&lt;PRE&gt;CREATE TABLE IF NOT EXISTS main_TAB(id int,mytime STRING,age int)
PARTITIONED BY (dt string)
STORED AS ORC
tblproperties ("orc.compress"="ZLIB");&lt;/PRE&gt;&lt;P&gt;then do insert statement as below&lt;/P&gt;&lt;PRE&gt;FROM TEMP_TAB INSERT OVERWRITE TABLE main_TAB PARTITION (mytime) SELECT *,substr(mytime,0,10) as mytime;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this case &lt;STRONG&gt;partition column would be dt &lt;/STRONG&gt;and you are &lt;STRONG&gt;not missing temp_tab&lt;/STRONG&gt; data at all. &lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2017 21:35:01 GMT</pubDate>
    <dc:creator>Shu_ashu</dc:creator>
    <dc:date>2017-11-06T21:35:01Z</dc:date>
  </channel>
</rss>

