Thanks for your response and appreciate for sharing the sample data.
I see that you have 4 array objects which will have to flatten. In order to flatten them you have to have 4 subsequent flatten transformations as shown below to flatten them at each level. At the end you will see the data flattened as table structure.
And for each flatten transformation you can verify the data by clicking on data preview as below:
Here is the dataflow script I tested for your reference (please note I might have missed few columns but you can add them as per your requirment):
source(output(
entities as (agent as (id as string, name as string, division as (id as string, name as string, selfUri as string), chat as (jabberId as string), email as string, primaryContactInfo as (address as string, mediaType as string, type as string)[], addresses as string[], state as string, username as string, manager as (id as string, selfUri as string), version as integer, acdAutoAnswer as boolean, selfUri as string), numEvaluations as integer, averageEvaluationScore as integer, numCriticalEvaluations as integer, highestEvaluationScore as double, lowestEvaluationScore as double, agentEvaluatorActivityList as (agent as (id as string, name as string, division as (id as string, name as string, selfUri as string), chat as (jabberId as string), email as string, primaryContactInfo as (address as string, mediaType as string, type as string)[], addresses as string[], state as string, username as string, manager as (id as string, selfUri as string), version as integer, acdAutoAnswer as boolean, selfUri as string), evaluator as (id as string, name as string, division as (id as string, name as string, selfUri as string), chat as (jabberId as string), department as string, email as string, primaryContactInfo as (address as string, mediaType as string, type as string)[], addresses as string[], state as string, title as string, username as string, manager as (id as string, selfUri as string), version as integer, acdAutoAnswer as boolean, selfUri as string), numEvaluations as integer, averageEvaluationScore as integer, numEvaluationsWithoutViewPermission as integer)[], numEvaluationsWithoutViewPermission as integer)[],
pageSize as integer,
pageNumber as integer,
total as integer,
nextUri as string,
lastUri as string,
firstUri as string,
selfUri as string,
pageCount as integer
),
allowSchemaDrift: true,
validateSchema: false,
ignoreNoFilesFound: false,
documentForm: 'documentPerLine') ~> source1
source1 foldDown(unroll(entities, entities),
mapColumn(
entity_agent_id = entities.agent.id,
entity_agent_name = entities.agent.name,
entities_agent_division_id = entities.agent.division.id,
entities_agent_division_name = entities.agent.division.name,
entities_agent_division_selfUri = entities.agent.division.selfUri,
entities_agent_chat_jabberId = entities.agent.chat.jabberId,
entities_agent_email = entities.agent.email,
entities_agent_state = entities.agent.state,
entities_agent_username = entities.agent.username,
entities_agent_manager_id = entities.agent.manager.id,
entities_agent_manager_selfUri = entities.agent.manager.selfUri,
entities_agent_version = entities.agent.version,
entities_agent_acdAutoAnswer = entities.agent.acdAutoAnswer,
entity_numEvaluations = entities.numEvaluations,
entity_averageEvaluationScore = entities.averageEvaluationScore,
entity_numCriticalEvaluations = entities.numCriticalEvaluations,
entity_highestEvaluationScore = entities.highestEvaluationScore,
entity_lowestEvaluationScore = entities.lowestEvaluationScore,
entity_numEvaluationsWithoutViewPermission = entities.numEvaluationsWithoutViewPermission,
entity_agent_addresses = entities.agent.addresses,
primaryContactInfo = entities.agent.primaryContactInfo,
entity_agentEvaluatorActivityList = entities.agentEvaluatorActivityList
),
skipDuplicateMapInputs: false,
skipDuplicateMapOutputs: false) ~> flattenEntities
flattenEntities foldDown(unroll(primaryContactInfo, primaryContactInfo),
mapColumn(
entity_agent_id,
entity_agent_name,
entities_agent_division_id,
entities_agent_division_name,
entities_agent_division_selfUri,
entities_agent_chat_jabberId,
entities_agent_email,
entities_agent_state,
entities_agent_username,
entities_agent_manager_id,
entities_agent_manager_selfUri,
entities_agent_version,
entities_agent_acdAutoAnswer,
entity_numEvaluations,
entity_averageEvaluationScore,
entity_numCriticalEvaluations,
entity_highestEvaluationScore,
entity_lowestEvaluationScore,
entity_numEvaluationsWithoutViewPermission,
entity_agent_primaryContactInfo_address = primaryContactInfo.address,
entity_agent_primaryContactInfo_mediaType = primaryContactInfo.mediaType,
entity_agent_primaryContactInfo_type = primaryContactInfo.type,
entity_agent_addresses,
entity_agentEvaluatorActivityList = entity_agentEvaluatorActivityList
),
skipDuplicateMapInputs: false,
skipDuplicateMapOutputs: false) ~> flattenAgentPrimaryContactInfo
flattenAgentPrimaryContactInfo foldDown(unroll(entity_agentEvaluatorActivityList, entity_agentEvaluatorActivityList),
mapColumn(
entity_agent_id,
entity_agent_name,
entities_agent_division_id,
entities_agent_division_name,
entities_agent_division_selfUri,
entities_agent_chat_jabberId,
entities_agent_email,
entities_agent_state,
entities_agent_username,
entities_agent_manager_id,
entities_agent_manager_selfUri,
entities_agent_version,
entities_agent_acdAutoAnswer,
entity_numEvaluations,
entity_averageEvaluationScore,
entity_numCriticalEvaluations,
entity_highestEvaluationScore,
entity_lowestEvaluationScore,
entity_numEvaluationsWithoutViewPermission,
entity_agent_primaryContactInfo_address,
entity_agent_primaryContactInfo_mediaType,
entity_agent_primaryContactInfo_type,
entity_agentEvaluatorActivityList_id = entity_agentEvaluatorActivityList.agent.id,
entity_agentEvaluatorActivityList_name = entity_agentEvaluatorActivityList.agent.name,
entity_agentEvaluatorActivityList_division_id = entity_agentEvaluatorActivityList.agent.division.id,
entity_agentEvaluatorActivityList_division_name = entity_agentEvaluatorActivityList.agent.division.name,
entity_agentEvaluatorActivityList_division_selfUri = entity_agentEvaluatorActivityList.agent.division.selfUri,
entity_agentEvaluatorActivityList_chat_jabberId = entity_agentEvaluatorActivityList.agent.chat.jabberId,
entity_agentEvaluatorActivityList_email = entity_agentEvaluatorActivityList.agent.email,
entity_agentEvaluatorActivityList_primaryContactInfo = entity_agentEvaluatorActivityList.agent.primaryContactInfo,
entity_agentEvaluatorActivityList_addresses = entity_agentEvaluatorActivityList.agent.addresses,
entity_agentEvaluatorActivityList_state = entity_agentEvaluatorActivityList.agent.state,
entity_agentEvaluatorActivityList_username = entity_agentEvaluatorActivityList.agent.username,
entity_agentEvaluatorActivityList_manager_id = entity_agentEvaluatorActivityList.agent.manager.id,
entity_agentEvaluatorActivityList_manager_selfUri = entity_agentEvaluatorActivityList.evaluator.manager.selfUri,
entity_agentEvaluatorActivityList_version = entity_agentEvaluatorActivityList.agent.version,
entity_agentEvaluatorActivityList_acdAutoAnswer = entity_agentEvaluatorActivityList.agent.acdAutoAnswer,
entity_agentEvaluatorActivityList_selfUri = entity_agentEvaluatorActivityList.agent.selfUri,
entity_agentEvaluatorActivityList_evaluator_id = entity_agentEvaluatorActivityList.evaluator.id,
entity_agentEvaluatorActivityList_evaluator_name = entity_agentEvaluatorActivityList.evaluator.name,
entity_agentEvaluatorActivityList_evaluator_division_id = entity_agentEvaluatorActivityList.evaluator.division.id,
entity_agentEvaluatorActivityList_evaluator_division_name = entity_agentEvaluatorActivityList.evaluator.division.name,
entity_agentEvaluatorActivityList_evaluator_division_selfUri = entity_agentEvaluatorActivityList.evaluator.division.selfUri
),
skipDuplicateMapInputs: false,
skipDuplicateMapOutputs: false) ~> flattenAgentEvaluatorActivityList
flattenAgentEvaluatorActivityList foldDown(unroll(entity_agentEvaluatorActivityList_primaryContactInfo, entity_agentEvaluatorActivityList_primaryContactInfo),
mapColumn(
entity_agent_id,
entity_agent_name,
entities_agent_division_id,
entities_agent_division_name,
entities_agent_division_selfUri,
entities_agent_chat_jabberId,
entities_agent_email,
entities_agent_state,
entities_agent_username,
entities_agent_manager_id,
entities_agent_manager_selfUri,
entities_agent_version,
entities_agent_acdAutoAnswer,
entity_numEvaluations,
entity_averageEvaluationScore,
entity_numCriticalEvaluations,
entity_highestEvaluationScore,
entity_lowestEvaluationScore,
entity_numEvaluationsWithoutViewPermission,
entity_agent_primaryContactInfo_address,
entity_agent_primaryContactInfo_mediaType,
entity_agent_primaryContactInfo_type,
entity_agentEvaluatorActivityList_id,
entity_agentEvaluatorActivityList_name,
entity_agentEvaluatorActivityList_division_id,
entity_agentEvaluatorActivityList_division_name,
entity_agentEvaluatorActivityList_division_selfUri,
entity_agentEvaluatorActivityList_chat_jabberId,
entity_agentEvaluatorActivityList_email,
entity_agentEvaluatorActivityList_state,
entity_agentEvaluatorActivityList_username,
entity_agentEvaluatorActivityList_manager_id,
entity_agentEvaluatorActivityList_manager_selfUri,
entity_agentEvaluatorActivityList_version,
entity_agentEvaluatorActivityList_acdAutoAnswer,
entity_agentEvaluatorActivityList_selfUri,
entity_agentEvaluatorActivityList_evaluator_id,
entity_agentEvaluatorActivityList_evaluator_name,
entity_agentEvaluatorActivityList_evaluator_division_id,
entity_agentEvaluatorActivityList_evaluator_division_name,
entity_agentEvaluatorActivityList_evaluator_division_selfUri,
entity_agentEvaluatorActivityList_evaluator_primaryContactInfo_address = entity_agentEvaluatorActivityList_primaryContactInfo.address,
entity_agentEvaluatorActivityList_evaluator_primaryContactInfo_mediaType = entity_agentEvaluatorActivityList_primaryContactInfo.mediaType,
entity_agentEvaluatorActivityList_evaluator_primaryContactInfo_type = entity_agentEvaluatorActivityList_primaryContactInfo.type
),
skipDuplicateMapInputs: false,
skipDuplicateMapOutputs: false) ~> flattenEvaluatorActivityListPrimaryContactInfo
flattenEvaluatorActivityListPrimaryContactInfo sink(allowSchemaDrift: true,
validateSchema: false,
input(
author as string,
title as string,
genre as string,
price as string,
pub_date as string,
review as string,
{@id} as string,
fileName as string
),
partitionFileNames:['FlattenedComplextJson.csv'],
umask: 0022,
preCommands: [],
postCommands: [],
skipDuplicateMapInputs: true,
skipDuplicateMapOutputs: true,
partitionBy('hash', 1)) ~> sinkFlattened
Hope this info helps.
Please don’t forget to Accept Answer
and Yes
for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.