<?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 have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping. in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401988#M251377</link>
    <description>&lt;P&gt;Try :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH json_extract AS (
  SELECT 
    get_json_object(xml_data, '$.app.Id') AS ID,
    get_json_object(xml_data, '$.app.apply[0].flag') AS Flag,
    get_json_object(xml_data, '$.app.apply[0].Product') AS products
  FROM check
)
SELECT 
  ID,
  Flag,
  get_json_object(product_data, '$.Code') AS Code,
  get_json_object(product_data, '$.Line') AS Line,
  get_json_object(product_data, '$.status') AS Status
FROM json_extract
LATERAL VIEW OUTER EXPLODE(SPLIT(products, '},')) p AS product_data;&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 13 Feb 2025 16:54:00 GMT</pubDate>
    <dc:creator>smruti</dc:creator>
    <dc:date>2025-02-13T16:54:00Z</dc:date>
    <item>
      <title>I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401886#M251344</link>
      <description>&lt;P&gt;The JSON is example is :&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"app": {&lt;BR /&gt;"Id": "123",&lt;BR /&gt;"apply": [&lt;BR /&gt;{&lt;BR /&gt;"flag": "1",&lt;BR /&gt;"Product": [&lt;BR /&gt;{&lt;BR /&gt;"Code": "DZ9e",&lt;BR /&gt;"Line": "10000",&lt;BR /&gt;"status": "C",&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;"Code": "EZ9e",&lt;BR /&gt;"Line": "19000",&lt;BR /&gt;"status": "C",&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;I need output like&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%"&gt;ID&lt;/TD&gt;&lt;TD width="25%"&gt;Flag&lt;/TD&gt;&lt;TD width="25%"&gt;Code&lt;/TD&gt;&lt;TD width="12.5%"&gt;Line&lt;/TD&gt;&lt;TD width="12.5%"&gt;Status&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;DZ9e&lt;/TD&gt;&lt;TD&gt;10000&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%"&gt;123&lt;/TD&gt;&lt;TD width="25%"&gt;1&lt;/TD&gt;&lt;TD width="25%"&gt;EZ9e&lt;/TD&gt;&lt;TD width="12.5%"&gt;19000&lt;/TD&gt;&lt;TD width="12.5%"&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used lateral explode/lalteral inline explode . But it is not giving value in separate rows.&lt;/P&gt;&lt;P&gt;Anybody has any solution&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 09:38:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401886#M251344</guid>
      <dc:creator>Rich_Learner</dc:creator>
      <dc:date>2025-02-12T09:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401946#M251358</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123988"&gt;@Rich_Learner&lt;/a&gt;,&amp;nbsp;Welcome to our community! To help you get the best possible answer, I have tagged our Hive experts &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82698"&gt;@smruti&lt;/a&gt;&amp;nbsp;who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 07:41:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401946#M251358</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2025-02-13T07:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401954#M251359</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123988"&gt;@Rich_Learner&lt;/a&gt;&amp;nbsp;could you please share your table definition?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;show create table &amp;lt;table_name&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I wanted to see if you are using textfile or json serde. Also I could try replicating the issue with that info.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 09:04:56 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401954#M251359</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2025-02-13T09:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401957#M251361</link>
      <description>&lt;P&gt;Hi I am attaching the result for a similar example:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rich_Learner_0-1739440051869.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43888i35D019F4958395BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rich_Learner_0-1739440051869.png" alt="Rich_Learner_0-1739440051869.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;column xml_data contains json&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 09:48:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401957#M251361</guid>
      <dc:creator>Rich_Learner</dc:creator>
      <dc:date>2025-02-13T09:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401964#M251364</link>
      <description>&lt;P&gt;Try something like this :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH json_extract AS (
  SELECT 
    get_json_object(xml_data, '$.app.Id') AS ID,
    get_json_object(xml_data, '$.app.apply[0].flag') AS Flag,
    get_json_object(xml_data, '$.app.apply[0].Product') AS products_json
  FROM check
)
SELECT 
  ID,
  Flag,
  get_json_object(product_item, '$.Code') AS Code,
  get_json_object(product_item, '$.Line') AS Line,
  get_json_object(product_item, '$.status') AS Status
FROM json_extract
LATERAL VIEW OUTER EXPLODE(split(regexp_replace(regexp_replace(products_json, '\\[|\\]', ''), '\\}\\s*,\\s*\\{', '}|{'), '|')) p AS product_item;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 13 Feb 2025 10:57:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401964#M251364</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2025-02-13T10:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401969#M251365</link>
      <description>&lt;P&gt;Thanks for the solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right the code is creating separate columns . But I am getting around 143 rows whereas technically there should be 3 rows and value is coming as NULL.&lt;/P&gt;&lt;P&gt;here consider first column as id&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rich_Learner_0-1739448647716.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43893iB0F9F44BB440EF8F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rich_Learner_0-1739448647716.png" alt="Rich_Learner_0-1739448647716.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 12:11:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401969#M251365</guid>
      <dc:creator>Rich_Learner</dc:creator>
      <dc:date>2025-02-13T12:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401970#M251366</link>
      <description>&lt;P&gt;Here Phonetype and Phone availabilityflag are my array which I want in rows&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 13:18:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401970#M251366</guid>
      <dc:creator>Rich_Learner</dc:creator>
      <dc:date>2025-02-13T13:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401988#M251377</link>
      <description>&lt;P&gt;Try :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH json_extract AS (
  SELECT 
    get_json_object(xml_data, '$.app.Id') AS ID,
    get_json_object(xml_data, '$.app.apply[0].flag') AS Flag,
    get_json_object(xml_data, '$.app.apply[0].Product') AS products
  FROM check
)
SELECT 
  ID,
  Flag,
  get_json_object(product_data, '$.Code') AS Code,
  get_json_object(product_data, '$.Line') AS Line,
  get_json_object(product_data, '$.status') AS Status
FROM json_extract
LATERAL VIEW OUTER EXPLODE(SPLIT(products, '},')) p AS product_data;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 13 Feb 2025 16:54:00 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/401988#M251377</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2025-02-13T16:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/402055#M251402</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82698"&gt;@smruti&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;I am getting 3 rows now but the first two values as populated as NULL only the last values is correctly populated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rich_Learner_0-1739544782895.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43908i107F815761A89214/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rich_Learner_0-1739544782895.png" alt="Rich_Learner_0-1739544782895.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2025 14:53:10 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/402055#M251402</guid>
      <dc:creator>Rich_Learner</dc:creator>
      <dc:date>2025-02-14T14:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/402401#M251631</link>
      <description>&lt;P&gt;ahh&amp;nbsp;&lt;BR /&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/123988"&gt;@Rich_Learner&lt;/a&gt;&amp;nbsp;please use the following query. I just tested. It should work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WITH json_extract AS (
  SELECT 
    get_json_object(xml_data, '$.app.Id') AS ID,
    get_json_object(xml_data, '$.app.apply[0].flag') AS Flag,
    regexp_replace(regexp_replace(get_json_object(xml_data, '$.app.apply[0].Product'), '\\[|\\]', ''), '\\}\\,\\{', '\\}\\;\\{') AS products
  FROM check
)
SELECT 
  ID,
  Flag,
  get_json_object(product_data, '$.Code') AS Code,
  get_json_object(product_data, '$.Line') AS Line,
  get_json_object(product_data, '$.status') AS Status
FROM json_extract
LATERAL VIEW explode(split(products, ';')) p AS product_data;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Feb 2025 14:54:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/402401#M251631</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2025-02-17T14:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: I have a HIVE table which contains JSON as a column. I need to extract a struct in this JSON .But Lateral explode is not helping.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/402402#M251632</link>
      <description>&lt;P&gt;Thanks a lot.. It worked like magic &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2025 15:55:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/I-have-a-HIVE-table-which-contains-JSON-as-a-column-I-need/m-p/402402#M251632</guid>
      <dc:creator>Rich_Learner</dc:creator>
      <dc:date>2025-02-17T15:55:11Z</dc:date>
    </item>
  </channel>
</rss>

