Need to use Multiple explode function | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kumar29917170hcyp

Hi @bellasnow5378,

 

If you have just one Object Array in the schema, then explode the Object itself and then use the outer query to fetch the attribute value:

Say the object array name is transactionDetails, and there are string fields (transactionAmt, transactionChannel) inside it, then your query will look like this:

select aa.transactionAmt, aa.transactionChannel,... from (select explode(transactionDetails) as aa from table_name);

 

If you have multiple string arrays in the schema, you may need to explode one array first, and then wrap that SELECT with another SELECT to explode:

select distinct aa, explode (column_name2) as bb, eventType timestamp from (select explode(column_name1) as aa, eventType from table_name);

 

Note: explode() will explode one array into multiple records, duplicating the fields that are not part of the explode. You can nest queries including the aggregation (use Distinct or Group by).

 

Regards,

Kumar Saurabh

1 reply

Kumar29917170hcypAdobe EmployeeAccepted solution
Adobe Employee
April 24, 2024

Hi @bellasnow5378,

 

If you have just one Object Array in the schema, then explode the Object itself and then use the outer query to fetch the attribute value:

Say the object array name is transactionDetails, and there are string fields (transactionAmt, transactionChannel) inside it, then your query will look like this:

select aa.transactionAmt, aa.transactionChannel,... from (select explode(transactionDetails) as aa from table_name);

 

If you have multiple string arrays in the schema, you may need to explode one array first, and then wrap that SELECT with another SELECT to explode:

select distinct aa, explode (column_name2) as bb, eventType timestamp from (select explode(column_name1) as aa, eventType from table_name);

 

Note: explode() will explode one array into multiple records, duplicating the fields that are not part of the explode. You can nest queries including the aggregation (use Distinct or Group by).

 

Regards,

Kumar Saurabh