How to use ADF copy activity to map complex JSON to table

Kumar, Sunil 26 Reputation points
2023-08-26T14:15:06.2566667+00:00

I would like to insert the data from copy activity (REST API as source) to Snowflake table (Sink). While using the mapping provided by copy activity is giving option to map all the elements in the nested JSON to columns in table.

In the below example, i wanted to map the nested JSON (batters) to a single column in table instead of mapping all the inner elements of "batters".
I tried different options to map "batters" to a varchar/variant column in Snowflake however getting empty data.
Any help would be great!

{
	"id": "0001",
	"type": "donut",
	"name": "Cake",
	"ppu": 0.55,
	"batters":
		{
			"batter":
				[
					{ "id": "1001", "type": "Regular" },
					{ "id": "1002", "type": "Chocolate" },
					{ "id": "1003", "type": "Blueberry" },
					{ "id": "1004", "type": "Devil's Food" }
				]
		},
	"topping":
		[
			{ "id": "5001", "type": "None" },
			{ "id": "5002", "type": "Glazed" },
			{ "id": "5005", "type": "Sugar" },
			{ "id": "5007", "type": "Powdered Sugar" },
			{ "id": "5006", "type": "Chocolate with Sprinkles" },
			{ "id": "5003", "type": "Chocolate" },
			{ "id": "5004", "type": "Maple" }
		]
}
Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
{count} vote

Accepted answer
  1. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2023-08-29T17:46:11.6333333+00:00

    Hi Kumar, Sunil,

    Thank you for posting query in Microsoft Q&A Platform.

    One possible way, I can think of is use web activity to get your json from API. Then have a variable in pipeline and using set variable activity, take all the batters key data as string into variable. Use copy activity, use additional column field to add send this variable data as additional column. and then map only that additional column with your snowflake table column.

    Hope this helps. Please let me know how it goes. Thank you.


    Please consider hitting Accept Answer button. Accepted answers help community as well.


0 additional answers

Sort by: Most helpful

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.