Update target column with optional source columns

RUC
New Contributor

I am trying to load on prem transaction log table and update a databricks table.In Source table,the column reqdetails table hold all the information and expect ProductID remaining columns are dynamic(not all columns exists in the request) all time the optional/nullable.Could you please let me the process using python in databricks ? Explored StructType but it needs mandatory specific columns.

Source Table

Req IDTypeReq DetailsStatus
1UpdateProductID=234;ProductName=LawnMover;Price=58True
2UpdateProductID=874;Price=478True
3UpdateProductID=678;ProductParentgroup=Watersuppuly;Price=1.6True

Target table before Update

ProductIDProductParentgroupProductNamePrice
234UtilityMover86
874HOASink450
678WaterFilters1.2

Target table after Update

ProductIDProductParentgroupProductNamePrice
234UtilityLawnMover58
874HOASink478
678WatersupplyFilters1.6