nested arrays using sql query insertion to a dataset not working | Community
Skip to main content
Level 2
September 20, 2024
Solved

nested arrays using sql query insertion to a dataset not working

  • September 20, 2024
  • 1 reply
  • 554 views

I am trying to insert nested arrays output from a sql query into another dataset but it is not working.

 

insert into b_array_processed_data_testing(_spnam.profileIds.B_UID,_spnam.arrayOfObjects)
SELECT
b_array.UID,
b_array.arrayOfObjects
FROM
(WITH grouped_data AS (
SELECT
_spnam.profileIds.B_UID as UID,
ARRAY_AGG(STRUCT(_spnam.arrayOfObjects.coolestInt,_spnam.arrayOfObjects.FavDessert)) AS arrayOfObjects
FROM
b_array_staging_poc_testing
GROUP BY
_spnam.profileIds.B_UID
)
SELECT
UID,
arrayOfObjects
FROM
grouped_data;)b_array

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 nnakirikanti

@ritwikmoWhen you are working with complex data structure (array's) you will need to use the collect_set function to write data into the array of the target schema dataset.

 

https://experienceleague.adobe.com/en/docs/experience-platform/query/key-concepts/nested-data-structures#use-insert-into-to-update-nested-data-fieldshttps://experienceleague.adobe.com/en/docs/experience-platform/query/key-concepts/nested-data-structures

 

~cheers,

Naresh Nakirikanti.

1 reply

nnakirikanti
Community Advisor
nnakirikantiCommunity AdvisorAccepted solution
Community Advisor
September 20, 2024

@ritwikmoWhen you are working with complex data structure (array's) you will need to use the collect_set function to write data into the array of the target schema dataset.

 

https://experienceleague.adobe.com/en/docs/experience-platform/query/key-concepts/nested-data-structures#use-insert-into-to-update-nested-data-fieldshttps://experienceleague.adobe.com/en/docs/experience-platform/query/key-concepts/nested-data-structures

 

~cheers,

Naresh Nakirikanti.