ADF - Dataflow - flatten json with drifting schema

Kailash Ravuri 11 Reputation points
2021-05-06T14:48:30.437+00:00

I have a requirement to convert the json into csv(or a SQL table) or any other flatten structure using Data Flow in Azure Data Factory. I need to take the property names at some hierarchy and values of the child properties at lower of hierrarchy from the source json and add them both as column/row values in csv or any other flatten structure.

Is there a way to flatten the following rather inconvenient type of JSON object in Azure Data Factory (V2)? Top-level keys in the data represent dynamically generated dates, which are different in each file. Hence, the schema is drifting.

Source Data Rules/Constraints :

Parent level data property names will change dynamically (e.g. ABCDataPoints,CementUse, CoalUse, ABCUseIndicators names are dynamic)  
The hierarchy always remains same as in below sample json.  

I need some help in defining Json path/expression to get the names ABCDataPoints,CementUse, CoalUse, ABCUseIndicators etc. I am able to figure out how to retrieve the values for the properties Value,ValueDate,ValueScore,AsReported.

Source Data sample
{
"ABCDataPoints": {
"CementUse": {
"Value": null,
"ValueDate": null,
"ValueScore": null,
"AsReported": [],
"Sources": []
},
"CoalUse": {
"Value": null,
"ValueDate": null,
"AsReported": [],
"Sources": []
}
},
"ABCUseIndicators": {
"EnvironmentalControversies": {
"Value": false,
"ValueDate": "2021-03-06T23:22:49.870Z"
},
"RenewableEnergyUseRatio": {
"Value": null,
"ValueDate": null,
"ValueScore": null
}
},
"XYZDataPoints": {
"AccountingControversiesCount": {
"Value": null,
"ValueDate": null,
"AsReported": [],
"Sources": []
},
"AdvanceNotices": {
"Value": null,
"ValueDate": null,
"Sources": []
}
},
"XYXIndicators": {
"AccountingControversies": {
"Value": false,
"ValueDate": "2021-03-06T23:22:49.870Z"
},
"AntiTakeoverDevicesAboveTwo": {
"Value": 4,
"ValueDate": "2021-03-06T23:22:49.870Z",
"ValueScore": "0.8351945854483925"
}
}

Destination Sample
94453-rq345.png

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,627 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,031 Reputation points
    2021-05-13T23:30:53.677+00:00

    I see. I've uploaded your sample data, and been trying different things for several hours. I'm not sure your ask is possible.

    @MarkKromer-MSFT do you have any ideas for this dynamic flatten? I'd like to just pivot, but column names aren't exactly available.


  2. Abheesh S Kurup 1 Reputation point
    2021-09-08T17:50:19.327+00:00

    @MarkKromer-MSFT Is Flatten transformation now configurable with expressions and parameters. I have used Flattening but now I understand that I have a dynamic data coming so ..just checking.