How to flatten an Array json using Azure Data Flow

djidji 0 Reputation points
2024-06-12T22:36:49.2066667+00:00

I am tying to convert the following json to parquet file in azure synapse analytics, to get data from rows[].

The json response has : dimensionsheaders , metricheaders and rows, Where the dimensionsheaders and metricheaders hold the field names and rows hold the corresponding data for these fields. I want the data from dimensionsheaders and metricheaders as the columns names and data from rows as the rows in the results. I tried using flatten, parse transformations with dataflow but was not able to get results.thank you for your help.

the sample json is:

{

"Dimensionheaders": [

 { "name": "XXXX"}, 

 {"name": "XYZ"}, 

 {"name": "YYY"}

],

"Metricsheaders": [

{

  "name": "AAA",

   "type": "Float"

}

],

"rows": [

 {

     "Dimensions values":  [

        {"value": "cccc" }, 

        { "value: "bbbb"}, 

        {"value": "eeee" }

],

  "metrics values":  [  {"value": "111111" }]

},

    "Dimensions values":  [

        {"value": "hhhhh" }, 

        { "value: "fffff"}, 

        {"value": "nnnnn" }

],

  "metrics values":  [  {"value": "16555" }]

}

],

"rowscount": 2,

}

Thank you!

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,916 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vahid Ghafarpour 21,240 Reputation points
    2024-06-13T00:56:24.61+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    You can load the JSON data into a Spark DataFrame in your Synapse Spark Notebook and develop the code in the notebook.

    https://stackoverflow.com/questions/71084684/howto-flatten-simple-json-file-in-azure-synapse-spark-notebook-and-convert-to-pa

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful **

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.