data prep function upsert_array_replace is not replacing array, but appending to array | Community
Skip to main content
Level 2
July 29, 2025
Solved

data prep function upsert_array_replace is not replacing array, but appending to array

  • July 29, 2025
  • 1 reply
  • 485 views

Hi Community,

I have to replace complete array with new values of array on every batch ingestion, but on every batch ingestion new items gets appended to this array in target dataset instead of replace. I have used upsert_array_replace in a calculated field and my dataset is profile and upsert enabled. Below is the structure of my target and source array, it has a primary identifier as "key" and "comm_details" array object to  replace. 

Calculate Field : upsert_array_replace (_tenant.comm_details)    -- Source 

Dataset Field   :                                  _tenant.comm_detail[*]       -- Target

I have already gone through documentation.

 https://experienceleaguecommunities.adobe.com/t5/adobe-experience-platform/overwriting-the-array-object/m-p/566290

https://experienceleague.adobe.com/sv/docs/experience-platform/data-prep/functions#arrays

Could you please let me know if this is expected behavior or I am missing anything.

[
{
    "_tenant": {
      "key": 111111,
      "comm_details": [
        {
          "pol_id": "0018801",
          "email_address1": "sat@SBI.com",
          "email_address2": null,
          "telephone1": "033-333-5533 2211",
          "pol_status": "Active",
          "timeStamp": "2025-07-20T05:49:20Z"
        }
      ]
    }
},
{
  "_tenant": {
    "key": 222222,
    "comm_details": [
      {
        "pol_id": "0018802",
        "email_address1": "adi@SBI.com",
        "email_address2": null,
        "telephone1": "033-333-6633 3322",
        "pol_status": "Active",
        "timeStamp": "2025-07-20T05:49:20Z"
      }
    ]
  }
}
]
 
Thanks in advance !!
Best answer by SantoshRa5

Hi Communicty,

upsert_array_replace() works for streaming ingestions only, not for batch ingestion. I am using batch ingestion.

Regards

Santosh

 

1 reply

KumarRishii
Level 5
July 29, 2025

The upsert_array_replace() function in AEP only replaces arrays if the schema is correctly aligned and the merge policy is configured to support full array replacement. If not, arrays may get appended instead.

To fix this, ensure the source and target schemas match exactly, use a merge policy that replaces (not merges) arrays based on timestamps, and always send the full array in each batch. If the issue persists, contact Adobe Support with payload samples and your merge policy details.

Level 2
July 29, 2025

Hi RishiKumar,

Thanks for the reply.

Merge polices is default i.e. timestamp based, and source and target schema are aligned. I will raise ticket to Adobe.

Regards,

Santosh