Hi
Below is the requirement:
We are getting array values from source in the column BillingSchedule as shown below and we have to extract individual billing schedule for each contract in a separate row for the respective contract, so one contract can have n numbers of billing schedules.
Source table: Contract
Case 1
Column Name :Contract_id
value=1
Column Name :Billing Schedule
values:
[ { startDate : { $numberLong : 1429501608000 }, endDate : { $numberLong : 1432093608000 }, amount : 0, amountBeforePromotion : 0, subjectPolicyIds : [ /data/SubjectPolicy/32469574 ], isFreeTrial : true }, { startDate : { $numberLong : 1432093608000 }, endDate : { $numberLong : 1440042408000 }, amount : 0, amountBeforePromotion : 17.39, subjectPolicyIds : [/data/SubjectPolicy/32469574 ], isFreeTrial : false },
Case 2
Column Name :Contract_id
value=2
Column Name :Billing Schedule
[ { startDate : { $numberLong : 1424235631000 }, endDate : { $numberLong : 1426824031000 }, amount : 0, subjectPolicyIds : [ /data/SubjectPolicy/32469574 ], isFreeTrial : true }, { startDate : { $numberLong : 1426824031000 }, endDate : { $numberLong : 1455944431000 }, amount : 17.39, subjectPolicyIds : [ /data/SubjectPolicy/32469574 ], isFreeTrial : false } ]
Please note that amountBeforePromotion is optional, it is present in Case 1 and not available in Case 2.
each row can be identified by "startdate" in the column Billingschedule, so in above cases we have 2 billing schedule for the respective contracts and we have to create 2 rows for the each contract in target table.
Target table columns
TIER_NUMBER :Billing schedule number
TIER_START_DATE:Billing schedule Start Date
TIER_END_DATE:Billing schedule End Date
TIER_$AMOUNT: Billing schedule Amount
IS_FREE_TRIAL: Billing schedule is free trail value
How to convert the values from Billing schedule column to multiple rows for the individual contract?
Thanks in advance for the help and support.