|
1 | 1 | ---
|
2 |
| -title: Parse data transformation in mapping data flow |
| 2 | +title: Parse data transformations in mapping data flow |
3 | 3 | description: Parse embedded column documents
|
4 | 4 | author: kromerm
|
5 | 5 | ms.author: makromer
|
@@ -41,21 +41,31 @@ Use the expression builder to set the source for your parsing. This can be as si
|
41 | 41 | * Source JSON data: ```{"ts":1409318650332,"userId":"309","sessionId":1879,"page":"NextSong","auth":"Logged In","method":"PUT","status":200,"level":"free","itemInSession":2,"registration":1384448}```
|
42 | 42 | * Expression: ```(level as string, registration as long)```
|
43 | 43 |
|
| 44 | +* Source Nested JSON data: ```{"car" : {"model" : "camaro", "year" : 1989}, "color" : "white", "transmission" : "v8"}``` |
| 45 | +* Expression: ```(car as (model as string, year as integer), color as string, transmission as string)``` |
| 46 | + |
44 | 47 | * Source XML data: ```<Customers><Customer>122</Customer><CompanyName>Great Lakes Food Market</CompanyName></Customers>```
|
45 | 48 | * Expression: ```(Customers as (Customer as integer, CompanyName as string))```
|
46 | 49 |
|
| 50 | +* Source XML with Attribute data: ```<cars><car model="camaro"><year>1989</year></car></cars>``` |
| 51 | +* Expression: ```(cars as (car as ({@model} as string, year as integer)))``` |
| 52 | +* Note: If you run into errors extracting attributes (i.e. @model) from a complex type, a workaround is to convert the complex type to a string, remove the @ symbol (i.e. replace(toString(your_xml_string_parsed_column_name.cars.car),'@','') |
| 53 | +), and then use the parse JSON transformation activity. |
| 54 | + |
47 | 55 | ### Output column type
|
48 | 56 |
|
49 |
| -Here is where you'll configure the target output schema from the parsing that will be written into a single column. The easiest way to set a schema for your output from parsing is to click the 'Detect Type' button on the top right of the expression builder. ADF will attempt to autodetect the schema from the string field which you are parsing and set it for you in the output expression. |
| 57 | +Here's where you'll configure the target output schema from the parsing that will be written into a single column. The easiest way to set a schema for your output from parsing is to select the 'Detect Type' button on the top right of the expression builder. ADF will attempt to autodetect the schema from the string field, which you're parsing and set it for you in the output expression. |
50 | 58 |
|
51 | 59 | :::image type="content" source="media/data-flow/data-flow-parse-2.png" alt-text="Parse example":::
|
52 | 60 |
|
53 |
| -In this example, we have defined parsing of the incoming field "jsonString" which is plain text, but formatted as a JSON structure. We're going to store the parsed results as JSON in a new column called "json" with this schema: |
| 61 | +In this example, we have defined parsing of the incoming field "jsonString", which is plain text, but formatted as a JSON structure. We're going to store the parsed results as JSON in a new column called "json" with this schema: |
54 | 62 |
|
55 | 63 | `(trade as boolean, customers as string[])`
|
56 | 64 |
|
57 | 65 | Refer to the inspect tab and data preview to verify your output is mapped properly.
|
58 | 66 |
|
| 67 | +Use the Derived Column activity to extract hierarchical data (that is, your_complex_column_name.car.model in the expression field) |
| 68 | + |
59 | 69 | ## Examples
|
60 | 70 |
|
61 | 71 | ```
|
|
0 commit comments