<?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>topic Re: Using HIVE query for parsing nested JSON in SAS pass-through in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961442#M374810</link>
    <description>&lt;P&gt;This query is working fine for me in HIVE&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Mar 2025 15:38:00 GMT</pubDate>
    <dc:creator>RichaM</dc:creator>
    <dc:date>2025-03-10T15:38:00Z</dc:date>
    <item>
      <title>Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961228#M374742</link>
      <description>&lt;P&gt;I have a dataset in Hadoop which contains nested JSON, I have to parse the JSOn and use the values to create a SAS dataset.&lt;/P&gt;&lt;P&gt;I have used Lateral view explode outer to parse nested JSON value but when I am using this HIVE code in SAS there is some SYntax issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help me with this&lt;/P&gt;&lt;PRE&gt;%LET ESQUEMA = gcgdlkmxusg_ecrm_db;
%LET HDFS = hv_u_stt_general_emmrm; 
%LET amb = xyz


PROC SQL;
    CONNECT TO HADOOP(
    host = "bigdataplatform-gcg-&amp;amp;amb..cal.nsroot.net"
    schema = &amp;amp;ESQUEMA.
	    HDFS_TEMPDIR = "/data/&amp;amp;HDFS./work/hive/&amp;amp;HDFS._work/"
    DBMAX_TEXT = 32768
    uri = "jdbc:hive2://bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net:10000/&amp;amp;ESQUEMA.;principal=hive/bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net@LAC.NSROOT.NET;ssl=true" 
    scratch_db = "&amp;amp;HDFS._work"
	subchar=questionmark
    ); 
	    CREATE TABLE Applicant AS
    SELECT * 
FROM CONNECTION TO HADOOP(
create table  product as(
select( 
  xml_data, application_number,interface_id,
  get_json_object(xml_data,'$.application.applicationid')as applicationid,
  cast(get_json_object(xml_data,'$.application.applicants[0].nationality') as INT) as Nationality,
 regexp_replace(regexp_replace(get_json_object(xml_data, '$.application.products[]'), '\\[|\\]', ''), '\\}\\,\\{', '\\}\\;\\{') AS phone_JSON)
  from &amp;amp;ESQUEMA..ci_rpdm_t_d
  where application_number='202829000002900' 
  )
  select(
  application_number,
  INTERFACE_ID,
  applicationid,
  nationality,
  get_json_object(phone_item,'$.type') as phonetype,
  get_json_object(phone_item,'$.productCode') as phoneAvailabilityFlag)
  from product
  LATERAL VIEW OUTER EXPLODE(split(phone_JSON, ';')) p AS phone_item
);
disconnect from hadoop;
quit;

&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Mar 2025 14:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961228#M374742</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-07T14:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961243#M374748</link>
      <description>&lt;P&gt;Do NOT tell HADOOP to make a TABLE.&amp;nbsp; That means it will not return any observations to SAS for the SAS select statement to retrieve.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just ask it to return the observations you want to store into the SAS dataset.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1741363413882.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105269i31259CB5B7E3087C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1741363413882.png" alt="Tom_0-1741363413882.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 16:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961243#M374748</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-07T16:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961401#M374799</link>
      <description>&lt;P&gt;If I dont use create table here , How do i use it below where I am referencing this product table.&lt;/P&gt;&lt;P&gt;In Hive this syntax works and I able to understand your view but I am not able to get the change of syntax for SAS&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 10:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961401#M374799</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-10T10:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961423#M374806</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/474060"&gt;@RichaM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;If I dont use create table here , How do i use it below where I am referencing this product table.&lt;/P&gt;
&lt;P&gt;In Hive this syntax works and I able to understand your view but I am not able to get the change of syntax for SAS&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That does not look like valid SQL to me.&amp;nbsp; Are you sure it works.&amp;nbsp; Modern versions of SQL would use WITH to specify a query that you want to reference as if it was an actual table later in the same query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; with product as (
  select xml_data, application_number,interface_id
       , get_json_object(xml_data,'$.application.applicationid') as applicationid
       , cast(get_json_object(xml_data,'$.application.applicants[0].nationality') as INT) as Nationality
       , regexp_replace(regexp_replace(get_json_object(xml_data, '$.application.products[]'), '\\[|\\]', ''), '\\}\\,\\{', '\\}\\;\\{') AS phone_JSON
  from &amp;amp;ESQUEMA..ci_rpdm_t_d
  where application_number='202829000002900' 
  )

  select application_number
       , INTERFACE_ID
       , applicationid
       , nationality
       , get_json_object(phone_item,'$.type') as phonetype
       , get_json_object(phone_item,'$.productCode') as phoneAvailabilityFlag
    from product
    LATERAL VIEW OUTER EXPLODE(split(phone_JSON, ';')) p AS phone_item
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really did want to make a table named PRODUCT and then QUERY that table you should do that in TWO steps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;execute by hadoop
(create table product .....
);

create table sasdataset as select * from connection to hadoop
(select var1,var2, .... from product ..... 
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 15:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961423#M374806</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-10T15:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961442#M374810</link>
      <description>&lt;P&gt;This query is working fine for me in HIVE&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 15:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961442#M374810</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-10T15:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961445#M374811</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/474060"&gt;@RichaM&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This query is working fine for me in HIVE&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Define working fine.&amp;nbsp; Do you mean it can be used to create table?&amp;nbsp; Or can&amp;nbsp; it also be used to stream its results to some viewer tool.&amp;nbsp; It is the latter that the FROM CONNECTION TO syntax in needs SAS needs to get.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 16:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961445#M374811</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-10T16:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961447#M374812</link>
      <description>&lt;P&gt;This looks like documentation that HIVE support WITH clause (also known as Common Table Expression or CTE).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.cloudera.com/runtime/7.3.1/using-hiveql/topics/hive_create_a_table_using_a_cte.html" target="_blank" rel="noopener"&gt;https://docs.cloudera.com/runtime/7.3.1/using-hiveql/topics/hive_create_a_table_using_a_cte.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To work with PROC SQL's FROM CONNECTION TO syntax you will want to use example number 3:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WITH q1 AS (SELECT key from src where key = '5') 
  SELECT * from q1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The name Q1 that appears after the WITH keyword is the name you use in the FROM clause of the actual SELECT statement that follows the WITH clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure that all of the variables you are selecting are valid for porting to SAS.&amp;nbsp; You might need cast() some of the strange variable types that HIVE might support into either fixed length character strings or floating point numbers so that SAS can use them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;WITH q1 AS (SELECT key from src where key = '5') 
  SELECT cast(key as float) as key from q1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Mar 2025 16:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961447#M374812</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-10T16:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961458#M374817</link>
      <description>Working fine in Hive for me.It displays the final result to me.But in sas when I use the query it gives EOF parse exception</description>
      <pubDate>Mon, 10 Mar 2025 16:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961458#M374817</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-10T16:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961460#M374819</link>
      <description>&lt;P&gt;What are the types of the variables you a returning to SAS?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select application_number
       , INTERFACE_ID
       , applicationid
       , nationality
       , get_json_object(phone_item,'$.type') as phonetype
       , get_json_object(phone_item,'$.productCode') as phoneAvailabilityFlag&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I would expect a different error message if it was an unknown variable type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your original code had a macro variable in it to make it dynamic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does it work when you hard code the value instead of using the macro variable reference?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 17:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961460#M374819</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-10T17:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961529#M374851</link>
      <description>&lt;P&gt;I used 'With' as suggested but still I am getting the same error.&lt;/P&gt;&lt;P&gt;I think the issue is because of the Lteral view function which works fine in HIVE but there are some syntax issue with SAS.Attaching both code and error log&lt;/P&gt;&lt;PRE&gt;%LET ESQUEMA = gcgdlsg_ecrm_db;
%LET HDFS = hv_u_stg_general_ecrm;
%LET amb = uat; 

/*APPlCANT*/

PROC SQL;
    CONNECT TO HADOOP(
    host = "bigdataplatform-gcg-&amp;amp;ab..lac.nsroot.net"
    schema = &amp;amp;ESQUEMA.
	    HDFS_TEMPDIR = "/data/&amp;amp;HDFS./work/hive/&amp;amp;HDFS._work/"
    DBMAX_TEXT = 32768
    uri = "jdbc:hive2://bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net:10000/&amp;amp;ESQUEMA.;principal=hive/bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net@LAC.NSROOT.NET;ssl=true" 
    scratch_db = "&amp;amp;HDFS._work"
	subchar=questionmark
    ); 
	    CREATE TABLE Applicant AS
    SELECT * 
FROM CONNECTION TO HADOOP(
with product as(
select( 
  xml_data, application_number,interface_id,
  get_json_object(xml_data,'$.application.applicationid')as applicationid,
  cast(get_json_object(xml_data,'$.application.applicants[0].nationality') as INT) as Nationality,
 regexp_replace(regexp_replace(get_json_object(xml_data, '$.application.products[]'), '\\[|\\]', ''), '\\}\\,\\{', '\\}\\;\\{') AS phone_JSON)
  from &amp;amp;ESQUEMA..ci_rpdm_t_d
  where application_number='20289898' AND INTERFACE_ID=102
  )
  select(
  application_number,
  INTERFACE_ID,
  applicationid,
  nationality,
  get_json_object(phone_item,'$.type') as phonetype,
  get_json_object(phone_item,'$.productCode') as phoneAvailabilityFlag)
  from product
  LATERAL VIEW OUTER EXPLODE(split(phone_JSON, ';')) p AS phone_item
);
disconnect from hadoop;
quit;&lt;/PRE&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;HR /&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;ERROR: Prepare error: Method not supportedError while compiling statement: FAILED: ParseException line 1:123 missing ) at 'as' near &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;'ci_rpdm_t_d' in statement&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SQL statement: with product as( select( xml_data, application_number,interface_id, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;get_json_object(xml_data,'$.application.applicationid')as applicationid, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;cast(get_json_object(xml_data,'$.application.applicants[0].nationality') as INT) as Nationality, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;regexp_replace(regexp_replace(get_json_object(xml_data, '$.application.products[]'), '\\[|\\]', ''), '\\}\\,\\{', &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;'\\}\\;\\{') AS phone_JSON) from gcgdlkmxusg_ecrm_db.ci_rpdm_t_d where application_number='20240829000002810' AND &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;INTERFACE_ID=102 ) select( application_number, INTERFACE_ID, applicationid, nationality, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;get_json_object(phone_item,'$.type') as phonetype, get_json_object(phone_item,'$.productCode') as phoneAvailabilityFlag) &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;from product LATERAL VIEW OUTER EXPLODE(split(phone_JSON, ';')) p AS phone_item&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 11 Mar 2025 10:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961529#M374851</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-11T10:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961536#M374855</link>
      <description>&lt;P&gt;That error message seems to pointing at this line of code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  from &amp;amp;ESQUEMA..ci_rpdm_t_d&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the value of the macro variable EQUEMA?&lt;/P&gt;
&lt;P&gt;What happens if you replace the macro variable reference with that actual value?&amp;nbsp; So if &amp;amp;EQUEMA. resolves to FRED what happens if you modify the code to use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  from FRED.ci_rpdm_t_d&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Mar 2025 12:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961536#M374855</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-11T12:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961578#M374862</link>
      <description>&lt;P&gt;Thanks for your reply. I found out that this was because of an additional round brace near line. I have corrected it . But now am getting a similar error again. I figured out that this is because of a missing brace for 'CONNECTION TO HADOOP' statement but cannot figure out where to place it as it is giving me error every time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;Error:&amp;nbsp;ERROR: Prepare error: Method not supportedError while compiling statement: FAILED: ParseException line 1:760 cannot recognize input &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;near ';' '&amp;lt;EOF&amp;gt;' '&amp;lt;EOF&amp;gt;' in lateral view&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;SQL statement: with ecs as ( select xml_data, application_number,interface_id, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;get_json_object(xml_data,'$.application.applicationid')as applicationid, &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;regexp_replace(regexp_replace(get_json_object(xml_data,'$.application.applicants[0].internalSystem.ecs[]'), '\\[|\\]', ''), &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;'\\}\\,\\{', '\\}\\;\\{') AS ecs_JSOn from gcgdlkmxusg_ecrm_db.ci_rpdm_t_d where application_number='20240829000002810' AND &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;INTERFACE_ID=102 ) select application_number, INTERFACE_ID, applicationid, get_json_object(ecs_item,'$.productLine') as &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;productLine, get_json_object(ecs_item,'$.productCode') as productCode, get_json_object(ecs_item,'$.creditLineAmtCards') as &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;creditLineAmtCards, get_json_object(ecs_item,'$.cin') as cin from ecs LATERAL VIEW OUTER EXPLODE(split(ecs_json, ';')) p AS &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="batang,apple gothic" size="3"&gt;ecs_item;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;PROC SQL;
    CONNECT TO HADOOP(
    host = "bigdataplatform-gcg-&amp;amp;ab..lac.nsroot.net"
    schema = &amp;amp;ESQUEMA.
	    HDFS_TEMPDIR = "/data/&amp;amp;HDFS./work/hive/&amp;amp;HDFS._work/"
    DBMAX_TEXT = 32768
    uri = "jdbc:hive2://bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net:10000/&amp;amp;ESQUEMA.;principal=hive/bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net@LAC.NSROOT.NET;ssl=true" 
    scratch_db = "&amp;amp;HDFS._work"
	subchar=questionmark
    ); 
	    CREATE TABLE Applicant AS
    SELECT * 
FROM CONNECTION TO HADOOP(
with ecs as (
select 
  xml_data, application_number,interface_id,
  get_json_object(xml_data,'$.application.applicationid')as applicationid,
 
   regexp_replace(regexp_replace(get_json_object(xml_data,'$.application.applicants[0].internalSystem.ecs[]'), '\\[|\\]', ''), '\\}\\,\\{', '\\}\\;\\{') AS ecs_JSOn
  from gcgdlkmxsg_ecrm_db.ci_rpdm_t_d
  where application_number='202410' AND INTERFACE_ID=1089
  )
  select 
  application_number,
  INTERFACE_ID,
  applicationid,
   get_json_object(ecs_item,'$.productLine') as productLine,
  get_json_object(ecs_item,'$.productCode') as productCode,
  get_json_object(ecs_item,'$.creditLineAmtCards') as creditLineAmtCards,
  get_json_object(ecs_item,'$.cin') as cin
  from ecs
  LATERAL VIEW OUTER EXPLODE(split(ecs_json, ';')) p AS ecs_item;)
/*  disconnect from hadoop;*/
quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 15:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961578#M374862</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-11T15:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961582#M374864</link>
      <description>&lt;P&gt;Why do you have that extra&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; p AS ecs_item;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;stuff after the LATERAL VIEW clause?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The examples I see on line look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FROM mytable LATERAL VIEW explode(myarray) exploded_array_table&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the end of your query should probable just be just one of these&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;from ecs LATERAL VIEW OUTER EXPLODE(split(ecs_json, ';'))&amp;nbsp;p
from ecs LATERAL VIEW OUTER EXPLODE(split(ecs_json, ';'))&amp;nbsp;ecs_item&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It does not look to me like it matters what ALIAS you code for the "exploded_array_table" since your SELECT statement is not referencing any table aliases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint to avoid loosing track of the closing parentheses in your multiple line code put the ) at the beginning of NEW LINE instead of hiding them at the end of (a possibly very long) line of code.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Mar 2025 16:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961582#M374864</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-11T16:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using HIVE query for parsing nested JSON in SAS pass-through</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961663#M374893</link>
      <description>&lt;P&gt;Thanks a lot for your help. I figured out the missing parenthesis location.&lt;/P&gt;&lt;P&gt;As for the alias , It is needed for lateral explode to reference the variables.&lt;/P&gt;&lt;P&gt;Writing the working code below:&lt;/P&gt;&lt;PRE&gt;%LET ESQUEMA = gcgdlkusg_ecrm_db;
%LET HDFS = hv_u_stg_ral_ecrm; 
%LET amb = ut

/*APPlCANT*/

PROC SQL;
    CONNECT TO HADOOP(
    host = "bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net"
    schema = &amp;amp;ESQUEMA.
	    HDFS_TEMPDIR = "/data/&amp;amp;HDFS./work/hive/&amp;amp;HDFS._work/"
    DBMAX_TEXT = 32768
    uri = "jdbc:hive2://bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net:10000/&amp;amp;ESQUEMA.;principal=hive/bigdataplatform-gcg-&amp;amp;amb..lac.nsroot.net@LAC.NSROOT.NET;ssl=true" 
    scratch_db = "&amp;amp;HDFS._work"
	subchar=questionmark
    ); 
	    CREATE TABLE Phone AS
    SELECT * 
FROM CONNECTION TO HADOOP(
with phn as (
select 
  xml_data, application_number,interface_id,
    get_json_object(xml_data,'$.application.applicationid')as applicationid,
  cast(get_json_object(xml_data,'$.application.applicants[0].nationality') as INT) as Nationality,
get_json_object(xml_data,'$.application.applicants[0].cin') as cin,
 
   regexp_replace(regexp_replace(get_json_object(xml_data,'$.application.applicants[].phones'), '\\[|\\]', ''), '\\}\\,\\{', '\\}\\;\\{') AS phone_JSON
  from &amp;amp;ESQUEMA..ci_rp_t_d
  where application_number='2024123' AND INTERFACE_ID=1023
  )
  select 
  application_number,
  INTERFACE_ID,
  applicationid,
  nationality,
  cin,
  get_json_object(phone_item,'$.phoneType') as phonetype,
  get_json_object(phone_item,'$.phoneAvailabilityFlag') as phoneAvailabilityFlag
  from phn
  LATERAL VIEW OUTER EXPLODE(split(phone_JSON, ';')) p AS phone_item
);
/*  disconnect from hadoop;*/
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Mar 2025 11:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-HIVE-query-for-parsing-nested-JSON-in-SAS-pass-through/m-p/961663#M374893</guid>
      <dc:creator>RichaM</dc:creator>
      <dc:date>2025-03-12T11:09:46Z</dc:date>
    </item>
  </channel>
</rss>

