<?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: create hive table in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171420#M45766</link>
    <description>&lt;P&gt;Also refer this &lt;A href="https://community.hortonworks.com/content/kbentry/60802/ranger-audit-in-hive-table-a-sample-approach-1.html" target="_blank"&gt;https://community.hortonworks.com/content/kbentry/60802/ranger-audit-in-hive-table-a-sample-approach-1.html&lt;/A&gt;. pm how an audit logs in hdfs can server a hive table.&lt;/P&gt;</description>
    <pubDate>Sat, 12 Nov 2016 03:39:22 GMT</pubDate>
    <dc:creator>rmani</dc:creator>
    <dc:date>2016-11-12T03:39:22Z</dc:date>
    <item>
      <title>create hive table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171418#M45764</link>
      <description>&lt;P&gt;I need some help to create hive table for the below format. this is ranger audit info, will create partitions accordingly. below info is just one line, &lt;/P&gt;&lt;P&gt;{"repoType":1,"repo":"abc_hadoop","reqUser":"ams","evtTime":"2016-09-19 13:14:40.197","access":"READ","resource":"/ambari-metrics-collector/hbase/data/hbase/meta/1588230740/info/ed3e52d8b86e4800801539fc4a7b1318","resType":"path","result":1,"policy":41,"reason":"/ambari-metrics-collector/hbase/data/hbase/meta/1588230740/info/ed3e52d8b86e4800801539fc4a7b1318","enforcer":"ranger-acl","cliIP":"123.129.390.140","agentHost":"hostname.sample.com","logType":"RangerAudit","id":"94143368-600c-44b9-a0c8-d906b4367537","seq_num":1240883,"event_count":1,"event_dur_ms":0}&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 08:59:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171418#M45764</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-11-10T08:59:17Z</dc:date>
    </item>
    <item>
      <title>Re: create hive table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171419#M45765</link>
      <description>&lt;P&gt;One way you can do it easily is by using hive-serde-schema-generator (https://github.com/strelec/hive-serde-schema-gen).  Another way is to use hive json serde (https://github.com/rcongiu/Hive-JSON-Serde_&lt;/P&gt;&lt;P&gt;The formatted json is below:&lt;/P&gt;&lt;PRE&gt;{  
   "repoType":1,
   "repo":"abc_hadoop",
   "reqUser":"ams",
   "evtTime":"2016-09-19 13:14:40.197",
   "access":"READ",
   "resource":"/ambari-metrics-collector/hbase/data/hbase/meta/1588230740/info/ed3e52d8b86e4800801539fc4a7b1318",
   "resType":"path",
   "result":1,
   "policy":41,
   "reason":"/ambari-metrics-collector/hbase/data/hbase/meta/1588230740/info/ed3e52d8b86e4800801539fc4a7b1318",
   "enforcer":"ranger-acl",
   "cliIP":"123.129.390.140",
   "agentHost":"hostname.sample.com",
   "logType":"RangerAudit",
   "id":"94143368-600c-44b9-a0c8-d906b4367537",
   "seq_num":1240883,
   "event_count":1,
   "event_dur_ms":0
}
&lt;/PRE&gt;&lt;P&gt;since the json is not nested, it seems the above choices are most definitely doable.  However maybe the most easiest way to do it is using this (https://community.hortonworks.com/articles/37937/importing-and-querying-json-data-in-hive.html) option&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2016 11:58:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171419#M45765</guid>
      <dc:creator>sunile_manjee</dc:creator>
      <dc:date>2016-11-10T11:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: create hive table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171420#M45766</link>
      <description>&lt;P&gt;Also refer this &lt;A href="https://community.hortonworks.com/content/kbentry/60802/ranger-audit-in-hive-table-a-sample-approach-1.html" target="_blank"&gt;https://community.hortonworks.com/content/kbentry/60802/ranger-audit-in-hive-table-a-sample-approach-1.html&lt;/A&gt;. pm how an audit logs in hdfs can server a hive table.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Nov 2016 03:39:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171420#M45766</guid>
      <dc:creator>rmani</dc:creator>
      <dc:date>2016-11-12T03:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: create hive table</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171421#M45767</link>
      <description>&lt;P&gt;I was able to create hive table on top of json files. below is the syntax i used to create external table..so i donot have to move data, all i need is to add partition&lt;/P&gt;&lt;P&gt;CREATE EXTERNAL
TABLE hdfs_audit(&lt;/P&gt;&lt;P&gt;  access string,&lt;/P&gt;&lt;P&gt;  agenthost string,&lt;/P&gt;&lt;P&gt;  cliip string,&lt;/P&gt;&lt;P&gt;  enforcer string,&lt;/P&gt;&lt;P&gt;  event_count bigint,&lt;/P&gt;&lt;P&gt;  event_dur_ms bigint,&lt;/P&gt;&lt;P&gt;  evttime timestamp,&lt;/P&gt;&lt;P&gt;  id string,&lt;/P&gt;&lt;P&gt;  logtype string,&lt;/P&gt;&lt;P&gt;  policy bigint,&lt;/P&gt;&lt;P&gt;  reason string,&lt;/P&gt;&lt;P&gt;  repo string,&lt;/P&gt;&lt;P&gt;  repotype bigint,&lt;/P&gt;&lt;P&gt;  requser string,&lt;/P&gt;&lt;P&gt;  restype string,&lt;/P&gt;&lt;P&gt;  resource string,&lt;/P&gt;&lt;P&gt;  result bigint,&lt;/P&gt;&lt;P&gt;  seq_num bigint)&lt;/P&gt;&lt;P&gt;PARTITIONED BY (&lt;/P&gt;&lt;P&gt;  evt_time string)&lt;/P&gt;&lt;P&gt;ROW FORMAT SERDE&lt;/P&gt;&lt;P&gt;  'org.apache.hive.hcatalog.data.JsonSerDe'&lt;/P&gt;&lt;P&gt;STORED AS
INPUTFORMAT&lt;/P&gt;&lt;P&gt;  'org.apache.hadoop.mapred.TextInputFormat'&lt;/P&gt;&lt;P&gt;OUTPUTFORMAT&lt;/P&gt;&lt;P&gt; 
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'&lt;/P&gt;&lt;P&gt;LOCATION&lt;/P&gt;&lt;P&gt;'hdfs://CLUSTERNAME/ranger/database/hdfs';&lt;/P&gt;&lt;P&gt;Add partition:&lt;/P&gt;&lt;P&gt;ALTER
TABLE ranger_audit.hdfs_audit ADD PARTITION (evt_time='20160601') LOCATION
'/ranger/audit/hdfs/20160601/hdfs/20160601';&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 22:17:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/create-hive-table/m-p/171421#M45767</guid>
      <dc:creator>chrsvarma</dc:creator>
      <dc:date>2016-12-02T22:17:07Z</dc:date>
    </item>
  </channel>
</rss>

