ADF Data Flow Parsing an array inside a row

Hadi Chahine 0 Reputation points
2023-10-15T10:43:41.0466667+00:00

Hi,

I have a table rows from a postgres database. The table has the structure (id string, cat_data json, variants json)

cat_data has the structure ["a","b","c"]

variants has the structure {"624": {name: "Test"}, "631": {name: "Hello"}}

I'm using ADF data flows to parse those two strings. Here's what I tried to do for cat_data: enter image description here

This caused an error: "statusCode":400,"shortMessage":"DF-PARS-005 at Parse 'parse1'(Line 270/Col 8): Only arrays and array of structures allowed"

First request: Not sure on how to proceed on either cat_data, and variants. Ultimately I want both of those parsed.

Second request: Is there a way to parse those strings without knowing the structure (just as JSON.parse(string) would be used in js) ?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Harishga 6,000 Reputation points Microsoft External Staff
    2023-10-18T11:00:23.0966667+00:00

    Hi @Hadi Chahine ,

    Welcome to Microsoft Q&A platform and thanks for posting your question here.

    In this specific situation, you have the option to use the 'flatten transformation' to convert the JSON data into a tabular format, and subsequently, pass the JSON column.

    For reference, kindly check this Thread:

    https://learn.microsoft.com/en-us/answers/questions/545933/flatten-and-parsing-json-using-azure-data-flow

    It appears that the data in cat_data is structured as an array, and this might be the root cause of the issue. Please consider passing the data in JSON format instead. If you still encounter the same error after making this change, please provide us with a sample of the data to help us further investigate the problem.

    I hope this information helps you resolve the issue. Let me know if you have any further questions or concerns.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.


  2. Harishga 6,000 Reputation points Microsoft External Staff
    2023-10-27T12:35:45.4266667+00:00

    Hi Hadi Chahine,
    Thank you for your response.
    Yes, it seems that you are correct. Parse can only parse objects, not arrays or maps. If cat_data is not valid, Parse will raise an error. This is because Parse expects the input to be a JSON string, and JSON strings must represent objects. Arrays and maps can be represented as JSON strings, but they must be nested inside of an object.

    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.