<?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: Querying JSON Data in Hive - returning null in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241326#M203129</link>
    <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/112879/li-h.html" nodeid="112879"&gt;@Haijin Li&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The input file you are using is incorrect stock2.json&lt;/P&gt;&lt;PRE&gt;{"myid":"0001","mytype":"donut"}&lt;/PRE&gt;&lt;P&gt;command is correct &lt;/P&gt;&lt;PRE&gt;CREATE EXTERNAL TABLE stock4_json (&lt;STRONG&gt;myjson struct&lt;/STRONG&gt;&amp;lt;myid:string, mytype:string&amp;gt;)ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' LOCATION '/warehouse/tablespace/external/hive/haijintest.db/stock2';&lt;/PRE&gt;&lt;P&gt;myjson struct define it is having further list and map.&lt;/P&gt;&lt;P&gt;You have to place correct input file stock3.json&lt;/P&gt;&lt;PRE&gt;{"myjson":{"myid":"0001","mytype":"donut"}}&lt;/PRE&gt;&lt;P&gt;and create table with same command and check.&lt;/P&gt;&lt;P&gt;Let me know if still you are facing issue.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vinay K&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2019 14:41:44 GMT</pubDate>
    <dc:creator>vinayk</dc:creator>
    <dc:date>2019-05-28T14:41:44Z</dc:date>
    <item>
      <title>Querying JSON Data in Hive - returning null</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241325#M203128</link>
      <description>&lt;P&gt;Content of stock2.json file&lt;/P&gt;&lt;PRE&gt;{"myid":"0001","mytype":"donut"}&lt;/PRE&gt;&lt;P&gt;stock2.json file is in the path of '/warehouse/tablespace/external/hive/haijintest.db/stock2';&lt;/P&gt;&lt;P&gt;Below is the table creation script.&lt;/P&gt;&lt;PRE&gt;CREATE EXTERNAL TABLE stock4_json (myjson struct&amp;lt;myid:string, mytype:string&amp;gt;)ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' LOCATION '/warehouse/tablespace/external/hive/haijintest.db/stock2';&lt;/PRE&gt;&lt;P&gt;Below is the query that returned null value.&lt;/P&gt;&lt;PRE&gt;0: jdbc:hive2://&amp;gt; select myjson.myid from stock4_json;
19/05/27 20:20:18 [103d2343-eb59-4072-8a07-5469b2112093 main]: WARN optimizer.SimpleFetchOptimizer: Table haijintest@stock4_json is external table, falling back to filesystem scan.
OK
+-------+
| myid &amp;nbsp;|
+-------+
| NULL &amp;nbsp;|
+-------+
1 row selected (0.232 seconds)
0: jdbc:hive2://&amp;gt; select * from stock4_json;
OK
+---------------------+
| stock4_json.myjson &amp;nbsp;|
+---------------------+
| NULL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|
+---------------------+
1 row selected (0.242 seconds)&lt;/PRE&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 10:28:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241325#M203128</guid>
      <dc:creator>Seaport</dc:creator>
      <dc:date>2019-05-28T10:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Querying JSON Data in Hive - returning null</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241326#M203129</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/112879/li-h.html" nodeid="112879"&gt;@Haijin Li&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The input file you are using is incorrect stock2.json&lt;/P&gt;&lt;PRE&gt;{"myid":"0001","mytype":"donut"}&lt;/PRE&gt;&lt;P&gt;command is correct &lt;/P&gt;&lt;PRE&gt;CREATE EXTERNAL TABLE stock4_json (&lt;STRONG&gt;myjson struct&lt;/STRONG&gt;&amp;lt;myid:string, mytype:string&amp;gt;)ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' LOCATION '/warehouse/tablespace/external/hive/haijintest.db/stock2';&lt;/PRE&gt;&lt;P&gt;myjson struct define it is having further list and map.&lt;/P&gt;&lt;P&gt;You have to place correct input file stock3.json&lt;/P&gt;&lt;PRE&gt;{"myjson":{"myid":"0001","mytype":"donut"}}&lt;/PRE&gt;&lt;P&gt;and create table with same command and check.&lt;/P&gt;&lt;P&gt;Let me know if still you are facing issue.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vinay K&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2019 14:41:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241326#M203129</guid>
      <dc:creator>vinayk</dc:creator>
      <dc:date>2019-05-28T14:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Querying JSON Data in Hive - returning null</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241327#M203130</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/69412/testtest12p.html" nodeid="69412"&gt;@Vinay&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Your are right. The issue is resolved. &lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 00:13:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Querying-JSON-Data-in-Hive-returning-null/m-p/241327#M203130</guid>
      <dc:creator>Seaport</dc:creator>
      <dc:date>2019-05-29T00:13:20Z</dc:date>
    </item>
  </channel>
</rss>

