title: Explode the Array of Struct in Hive
body: <p>This is the below Hive Table</p>
  
  <pre><code>CREATE EXTERNAL TABLE IF NOT EXISTS SampleTable
  (
  USER_ID BIGINT,
  NEW_ITEM ARRAY&lt;STRUCT&lt;PRODUCT_ID: BIGINT,TIMESTAMPS:STRING&gt;&gt;
  )
  </code></pre>
  
  <p>And this is the data in the above table-</p>
  
  <pre><code>1015826235     [{"product_id":220003038067,"timestamps":"1340321132000"},{"product_id":300003861266,"timestamps":"1340271857000"}]
  </code></pre>
  
  <p>Is there any way I can get the below output from the HiveQL after exploding the array?</p>
  
  <pre><code>**USER_ID**  |  **PRODUCT_ID**  |   **TIMESTAMPS**
   ------------+------------------+----------------
  1015826235      220003038067       1340321132000
  1015826235      300003861266       1340271857000
  </code></pre>
  
  <p><strong>Updated</strong></p>
  
  <p>I wrote this query to get the output in the above format, but it is not giving me the result in the way I wanted to.</p>
  
  <pre><code>SELECT myTable1.myCol1,myTable2.myCol2 FROM sampletable st LATERAL VIEW 
  explode(st.purchased_item.product_id) myTable1 AS myCol1 LATERAL VIEW 
  explode(st.purchased_item.timestamps) myTable2 AS myCol2;
  </code></pre>
  
  <p>Can anyone help me what wrong I am doing? Any suggestions will be appreciated.</p>