title: Hive dynamic partition in insert overwrite from select statement is not loading the data for the dynamic partition
body: <p>Hive dynamic partition in insert overwrite from select statement is not loading the data for the dynamic partition instead it gives the data <strong>HIVE_DEFAULT_PARTITION</strong>.</p>
  
  <p>If I say show partitions table2;</p>
  
  <p>it just give only one partition detail which is <strong>HIVE_DEFAULT_PARTITION</strong></p>
  
  <p>I have a staging table without any partitions which reads data from a sequence file.</p>
  
  <p>CREATE EXTERNAL TABLE IF NOT EXISTS table1(DS string, col1 string, col2 string, col3 string)<br>
  ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
  STORED AS SEQUENCEFILE
  LOCATION '/user/'
  tblproperties ("skip.header.line.count"="1");</p>
  
  <p>The date format is m/d/yy for the field DS which is coming from the file.</p>
  
  <p>Then I am creating production table like below.</p>
  
  <p>CREATE EXTERNAL TABLE IF NOT EXISTS table2(col1 string, col2 string, col3 string)<br>
  PARTITIONED BY (DS string)
  STORED AS SEQUENCEFILE
  tblproperties ("skip.header.line.count"="1");</p>
  
  <p>set hive.exec.dynamic.partition.mode=nonstrict;</p>
  
  <p>Then the insert query as below</p>
  
  <p>INSERT OVERWRITE TABLE table2 PARTITION (DS)
  SELECT col1, col2,col3, cast(DS as date)
  FROM table1;</p>
  
  <p>When I query the table 2 I get the result as below</p>
  
  <p>d1 d2 d3 <strong>HIVE_DEFAULT_PARTITION</strong>
  d4 d5 d5 <strong>HIVE_DEFAULT_PARTITION</strong></p>
  
  <p>for the last column where I expect a date field from my partition column instead I get <strong>HIVE_DEFAULT_PARTITION</strong></p>
  
  <p>My expected data is like</p>
  
  <p>d1 d2 d3 5/1/17
  d4 d5 d5 5/1/17</p>
  
  <p>Can anyone help on this?</p>