easy dataweave transformations - ashutosh

4
Dataweave Transformations Made Easy Turing Works and Mule

Upload: strawhatluffy11

Post on 22-Feb-2017

157 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Easy Dataweave transformations - Ashutosh

Dataweave Transformations Made Easy

Turing Works and Mule

Page 2: Easy Dataweave transformations - Ashutosh

Dataweave Transformations Made EasyDataWeave is a new language for querying and transforming data. DataWeave includes a connectivity layer and engine that is fundamentally different from other transformation technologies. It contains a data access layer that indexes content and accesses the binary directly, without costly conversions, enabling larger than memory payloads, random access to input documents and very high performance.We have taken a simple file transformation and set off data as an example that is to be transformed from JSON to XML.The flow below shows the file to file transformation and mapping created for showcasing the DataWeave. The transformation component is called Transform Message, when we look at the component pallet in Anypoint Studio. We will not see any component as DataWeave.

Page 3: Easy Dataweave transformations - Ashutosh

When the transform message component is selected, we can see the properties as shown below.The above image shows three sections, the first one is an input section which shows the message section and what is available for transformation. The second section is the DataWeave code and the third one output section that shows us the preview of the transformation in the expected output format.DataWeave code is a JSON like syntax and is format neutral. This is used to define the mappings. The top section defines the output, variables and the expected structure. Under that, we have the code after the three hyphens. These three hyphens are expected by the DataWeave engine to understand where the transformation actually starts.The output section is instantly updated and we can see the updates as we are making the changes to the mapping in the code section.

Page 4: Easy Dataweave transformations - Ashutosh

In the above example we have use the output type application/xml, as defined in the top section in the code, so our output is in XML format. The format for output can be changed to csv or java by just changing the output type to application/csv. The change can also be observed in the output section as shown below.or to application/java as shown below.The DataWeave language has lot of operators like functions, operators, filters, etc. built into it to help with most of the common transformations. It also supports a variety of transformations, from simple one-to-one mappings to more elaborate mappings including normalization, grouping, joins, deduplication and pivoting. It also supports XML, JSON, CSV, Java and EDI out of the box. The comprehensive reference documentation is available for full list.NOTE: currently, reading larger than memory XML is not yet supported.