<?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: How can i import JSON field data from mySql server into Hive table using sqoop. in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149764#M112282</link>
    <description>&lt;P&gt;Thanks @Simon,&lt;/P&gt;&lt;P&gt;I put into a string field in hive table and query it using get_json_object. That works for me.&lt;/P&gt;&lt;P&gt;But i have another set of data in HDFS like.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1023,UK,{"cities":{"city1":"London","city2":"Birmingham","city3":"Liverpool"},"universities":{"universities1":"Cambridge","universities2":"Oxford"}},07-30-2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So i want to store it in a hive table with schema like:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table data (SerNo int, country string , detail string,date string )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then what should be the table definition so that   {"cities: ..... }  will come as one column and rest with other ? what should be the column separator ?&lt;/P&gt;&lt;P&gt;If i put everything as one string field in hive table , then how i query &lt;STRONG&gt;SerNo&lt;/STRONG&gt; ,&lt;STRONG&gt;country &lt;/STRONG&gt;and&lt;STRONG&gt; date&lt;/STRONG&gt; column. Is it possible by get_json_object ?&lt;/P&gt;</description>
    <pubDate>Sat, 30 Jul 2016 21:23:32 GMT</pubDate>
    <dc:creator>PapuRay</dc:creator>
    <dc:date>2016-07-30T21:23:32Z</dc:date>
    <item>
      <title>How can i import JSON field data from mySql server into Hive table using sqoop.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149762#M112280</link>
      <description>&lt;P&gt;I have a table name EmpData in mySql server with two field as EmpID (INT) and Details (nvarchar). Deatils field contain &lt;STRONG&gt;JSON &lt;/STRONG&gt;string . &lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;EmpID&lt;/TD&gt;&lt;TD&gt;Details&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;567&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;{ "name": "Michel","address":{"house no":"12","street":"Johnson road","city":"London","country":"UK"}}&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;927&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;{ "name": "John","address":{"house no":"99","street":"Johnson road","city":"London","country":"UK"}}&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to import "Details" field JSON data into HDP hive table EmpHiveStore and query on hive table like &lt;/P&gt;&lt;P&gt;&lt;EM&gt;SELECT name,address.street from EmpHiveStore;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Is there any way to import JSON field data into Hive table using sqoop ? &lt;/P&gt;&lt;P&gt;Thank You.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 02:09:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149762#M112280</guid>
      <dc:creator>PapuRay</dc:creator>
      <dc:date>2016-07-27T02:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can i import JSON field data from mySql server into Hive table using sqoop.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149763#M112281</link>
      <description>&lt;P&gt;You JSON there is just going to be stored as a string by the looks of it, unless your RDBMS is using a JSON type. &lt;/P&gt;&lt;P&gt;To import this, you can just have that put into a string field and then use Hive to convert that to a map type for instance, or just use hive udfs to query it as json from the string type field (try using get_json_object in Hive for instance).&lt;/P&gt;&lt;P&gt;Once you've got the bits you want there you can transform them to a complex type table with proper maps for instance. &lt;/P&gt;&lt;P&gt;Another option worth considering would be to have sqoop just dump out just the json field, and have that stored as a text file rather than going to a hive table. You can then use the spark dataframe json reader to read in and infer the complex json schema for you, and then use that to build a Hive table with the spark saveAsTable function.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jul 2016 17:09:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149763#M112281</guid>
      <dc:creator>sball</dc:creator>
      <dc:date>2016-07-27T17:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can i import JSON field data from mySql server into Hive table using sqoop.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149764#M112282</link>
      <description>&lt;P&gt;Thanks @Simon,&lt;/P&gt;&lt;P&gt;I put into a string field in hive table and query it using get_json_object. That works for me.&lt;/P&gt;&lt;P&gt;But i have another set of data in HDFS like.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1023,UK,{"cities":{"city1":"London","city2":"Birmingham","city3":"Liverpool"},"universities":{"universities1":"Cambridge","universities2":"Oxford"}},07-30-2016&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;So i want to store it in a hive table with schema like:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table data (SerNo int, country string , detail string,date string )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Then what should be the table definition so that   {"cities: ..... }  will come as one column and rest with other ? what should be the column separator ?&lt;/P&gt;&lt;P&gt;If i put everything as one string field in hive table , then how i query &lt;STRONG&gt;SerNo&lt;/STRONG&gt; ,&lt;STRONG&gt;country &lt;/STRONG&gt;and&lt;STRONG&gt; date&lt;/STRONG&gt; column. Is it possible by get_json_object ?&lt;/P&gt;</description>
      <pubDate>Sat, 30 Jul 2016 21:23:32 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-can-i-import-JSON-field-data-from-mySql-server-into-Hive/m-p/149764#M112282</guid>
      <dc:creator>PapuRay</dc:creator>
      <dc:date>2016-07-30T21:23:32Z</dc:date>
    </item>
  </channel>
</rss>

