<?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: I need help to create Hive table using datalake point toad? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146394#M108961</link>
    <description>&lt;P&gt;
	@vj pan, you can use lateral view in your CTAS query to separate the fields from &lt;EM&gt;Details_str.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;
	You can create table like this in database A&lt;/P&gt;&lt;PRE&gt;create table databaseA.testtable(                                                         
  event_ts timestamp,                                                   
  cust_id int,                                                          
  ban int,                                                              
  detail_str string);
&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;

	&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then, use following CTAS query with lateral view to create second table in database B&lt;/P&gt;&lt;PRE&gt;create table databaseB.testtable as 
        select event_ts, 
               cust_id, 
               ban, 
               detail_str, 
               lv_detail_str.type_cd, 
               lv_detail_str.head_id, 
               lv_detail_str.out_id, 
               lv_detail_str.org_type_des 
        from databaseA.testtable  a 
        lateral view 
        json_tuple(a.detail_str,'type_cd','head_id','out_id','org_type_des') lv_detail_str as 
                type_cd, 
                head_id,
                out_id,
                org_type_des; 
&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Jan 2017 07:42:50 GMT</pubDate>
    <dc:creator>jvaria</dc:creator>
    <dc:date>2017-01-26T07:42:50Z</dc:date>
    <item>
      <title>I need help to create Hive table using datalake point toad?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146391#M108958</link>
      <description>&lt;P&gt;Hi I have hive table in one of the database A and want to create table in database B in hive.&lt;/P&gt;&lt;P&gt;sample field and data:-&lt;/P&gt;&lt;P&gt;event_ts - 17/04/2016 2:40:07 am&lt;/P&gt;&lt;P&gt;cust_id - 30122&lt;/P&gt;&lt;P&gt;ban - 001&lt;/P&gt;&lt;P&gt;Detail_str - {"type_cd":"A","head_id":"283680","out_id":"1111","org_type_des":"Koo"}&lt;/P&gt;&lt;P&gt;I want to copy this table and create hive table in database B like this&lt;/P&gt;&lt;P&gt;event_ts&lt;/P&gt;&lt;P&gt;cust_id&lt;/P&gt;&lt;P&gt;ban&lt;/P&gt;&lt;P&gt;Detail_str&lt;/P&gt;&lt;P&gt;type_cd&lt;/P&gt;&lt;P&gt;head_id&lt;/P&gt;&lt;P&gt;out_id&lt;/P&gt;&lt;P&gt;org_type_des&lt;/P&gt;&lt;P&gt;So what kinds of query I need to generate to create Hive table in Database B?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 00:23:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146391#M108958</guid>
      <dc:creator>vijaypatel4624</dc:creator>
      <dc:date>2017-01-26T00:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: I need help to create Hive table using datalake point toad?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146392#M108959</link>
      <description>&lt;P&gt;Something like below command should work as long as both databases are in same Hive instance. &lt;/P&gt;&lt;PRE&gt;create table databaseB.testtable as select * from databaseA.testtable&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 00:38:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146392#M108959</guid>
      <dc:creator>ravi1</dc:creator>
      <dc:date>2017-01-26T00:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: I need help to create Hive table using datalake point toad?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146393#M108960</link>
      <description>&lt;P&gt;Detail_str - {"type_cd":"A","head_id":"283680","out_id":"1111","org_type_des":"Koo"}&lt;/P&gt;&lt;P&gt;how Can I separate the fields from this string? key and value &lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 00:44:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146393#M108960</guid>
      <dc:creator>vijaypatel4624</dc:creator>
      <dc:date>2017-01-26T00:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: I need help to create Hive table using datalake point toad?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146394#M108961</link>
      <description>&lt;P&gt;
	@vj pan, you can use lateral view in your CTAS query to separate the fields from &lt;EM&gt;Details_str.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;
	You can create table like this in database A&lt;/P&gt;&lt;PRE&gt;create table databaseA.testtable(                                                         
  event_ts timestamp,                                                   
  cust_id int,                                                          
  ban int,                                                              
  detail_str string);
&lt;/PRE&gt;&lt;P&gt;&lt;EM&gt;

	&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then, use following CTAS query with lateral view to create second table in database B&lt;/P&gt;&lt;PRE&gt;create table databaseB.testtable as 
        select event_ts, 
               cust_id, 
               ban, 
               detail_str, 
               lv_detail_str.type_cd, 
               lv_detail_str.head_id, 
               lv_detail_str.out_id, 
               lv_detail_str.org_type_des 
        from databaseA.testtable  a 
        lateral view 
        json_tuple(a.detail_str,'type_cd','head_id','out_id','org_type_des') lv_detail_str as 
                type_cd, 
                head_id,
                out_id,
                org_type_des; 
&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 07:42:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-need-help-to-create-Hive-table-using-datalake-point-toad/m-p/146394#M108961</guid>
      <dc:creator>jvaria</dc:creator>
      <dc:date>2017-01-26T07:42:50Z</dc:date>
    </item>
  </channel>
</rss>

