08-07-2022 12:38 AM
I am trying below data converting rows into columns
input:
[
{
“CARRIERCODE”: “abc”,
“SHIPCARRIERTRACKINGNUM”: “531”,
“DATETIMEVALUE”: “2022-05-16 08:05:00”,
“DATETIMETYPE”: “ACTUAL_DELIVERY”,
“DATEVALUE”: “2022-05-16”
},
{
“CARRIERCODE”: “abc”,
“SHIPCARRIERTRACKINGNUM”: “531”,
“DATETIMEVALUE”: “2022-05-11 09:31:00”,
“DATETIMETYPE”: “ACTUAL_PICKUP”,
“DATEVALUE”: “2022-05-11”
},
{
“CARRIERCODE”: “abc”,
“SHIPCARRIERTRACKINGNUM”: “531”,
“DATETIMEVALUE”: “2022-05-11 12:00:00”,
“DATETIMETYPE”: “SHIP”,
“DATEVALUE”: “2022-05-11”
},
{
“CARRIERCODE”: “abc”,
“SHIPCARRIERTRACKINGNUM”: “531”,
“DATETIMEVALUE”: “2022-05-11 09:49:00”,
“DATETIMETYPE”: “ACTUAL_TENDER”,
“DATEVALUE”: “2022-05-11”
},
expected output:
any leads here
Solved! Go to Solution.
08-08-2022 04:11 AM
Hi @kkishore,
Group the incoming data by CARRIERCODE & SHIPCARRIERTRACKINGNUM:
And add the following expression in a mapper after the group by snap:
$group.map(x=>{[x.DATETIMETYPE+"_DATETIMEVALUE"]:x.DATETIMEVALUE,[x.DATETIMETYPE+"_DATEVALUE"]:x.DATEVALUE}).reduce((acc,curr)=>acc.extend(curr),{}).extend($groupBy)
Hope this helps,
Regards
08-08-2022 04:11 AM
Hi @kkishore,
Group the incoming data by CARRIERCODE & SHIPCARRIERTRACKINGNUM:
And add the following expression in a mapper after the group by snap:
$group.map(x=>{[x.DATETIMETYPE+"_DATETIMEVALUE"]:x.DATETIMEVALUE,[x.DATETIMETYPE+"_DATEVALUE"]:x.DATEVALUE}).reduce((acc,curr)=>acc.extend(curr),{}).extend($groupBy)
Hope this helps,
Regards
08-09-2022 05:33 AM
Thank you @bojanvelevski , perfect it is working as expected.
08-09-2022 08:39 AM
Thank you @kkishore, can you please mark @bojanvelevski’s suggestion as a Solution so that anybody looking at this thread in the future can refer to the solution directly?