Mapper
In this article
Overview
Use this Snap to transform incoming data with the specific mappings and produce new output data (binary or document). The Mapper Snap evaluates an expression and writes the result to the target path. Use the Views tab to specify error handling if an expression fails to evaluate.
Pass Binary Data
To convert binary data to document data add the Binary-to-Document Snap upstream of the Mapper Snap. Similarly, add the Document-to-Binary Snap downstream of the Mapper Snap to convert the document output to binary data.
You can also transform binary data to document data in the Mapper Snap itself with the
$content
expression.
Binary Input and Output
If you only work with a binary stream as both input and output, you must set both source and target fields with
$content
, then use the Expression Builder to manipulate the binary data. If you do not specify this mapping, then the binary stream from the binary input document passes through with no change.
Snap Type
The Mapper Snap is a Transform-type Snap that transforms data and passes it to the downstream Snap.
Support for Ultra Pipelines
Works in Ultra Pipelines.
Limitations
The Mapper Snap does not support Base64URL decoding.
Expressions used in this Snap (downstream of any Snowflake Snaps) that evaluate to very large values such as
EXP(900)
displays asInfinity
in the input/output previews. However, the exact evaluated values are in the validation previews. Learn more: JavaScript Limitations in Displaying Numbers.
Snap Views
Type | Format | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input |
|
| Binary-to-Document | This Snap can have at most one document or binary input view. If you do not specify an input view, the Snap generates a downstream flow of one row. By default, the Input type is Document. You can select Binary type if your input is in Binary format. |
Output |
|
| Any Document Snap | This Snap has exactly one document or binary output view. By default, the Output type is Document. You can select the Binary type to view the output in the Binary format. |
Error | Error handling is a generic way to handle errors without data loss or Snap execution failure. You can handle the errors that the Snap might encounter when running the pipeline with one of the following options from the When errors occur list under the Views tab. The available options are:
Learn more about Error handling in Pipelines. |
Snap Settings
Field Name | Field Type | Description | |
---|---|---|---|
Label*
Default Value: Mapper | String | The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline. | |
Null-safe access
Default Value: Deselected | Checkbox | Select this checkbox to set the target value to null if the source path does not exist. For example, | |
Pass through
Default Value: Deselected | Checkbox | Select this checkbox so the Snap passes all the original input data into the output document with the data transformation results. If you deselect this checkbox, only the data transformation results in the mapping section appear in the output document and the input data is discarded. Always select Pass through if you plan to leave the Target path field blank. Otherwise, an error displays to indicate that the field you want to delete does not exist. This is the expected behavior. For example, if you have an input file that contains a number of attributes and you need only two of these downstream. To accomplish that: 1. Connect a Mapper Snap to the downstream Snap. 2. List the two attributes you need in the Expression fields, 3. Leave the Target path field blank. 4. Select Pass through. When you execute the pipeline, this Snap evaluates the input document/binary data, extracts the two attributes that you want, and passes the entire document/binary data through to the Target schema. From the list of available attributes in the Target Schema, the Mapper Snap picks up the two attributes you listed in the Expression fields, and passes them as output. However, if you do not select the Pass through checkbox, the Target Schema would be empty, and the Snap displays the
| |
Transformations*
| Use this field set to configure the settings for data transformations. | ||
Mapping Root
Default Value: $ | String/Suggestion | Specify the subsection of the input data to map. Learn more: Understand the Mapping Root. | |
Input Schema | Dropdown list | Select the input data (from the upstream Snap) that you want to transform. Drag the item you want to map and place it under the Mapping table. | |
Sorted
Default Value: Selected | Checkbox | Select this checkbox to sort the input schema and the target schema. The sort options are:
| |
Mapping table* | Use this field set to specify the source path, expression, and target path columns used to map schema structure. The mapping table makes it easier to:
Learn more: Use the Mapping Table. | ||
Expression*
Default Value: N/A | String/Expression | Specify the function to use to transform the data. For example, combine, concatenate, or flatten. Expressions that are evaluated replace the source targets at the end of the pipeline runtime. Learn More: Understand Expressions in SnapLogic and Use Expressions for usage guidelines. When you work with upstream numeric data, you might see some unexpected behavior. For example, consider a mapping that reads as follows: Expression: Now, the value passes from upstream for $num is 20.05. You expect the value of This happens because, as of now, the Mapper Snap reads all incoming data as strings, unless they are specifically listed as integers (INT) or decimals (FLOAT). So, to ensure that the upstream numeric data is appropriately interpreted, parse the data as a float to convert the numeric data into a decimal, and all calculations on the upstream data in the Mapper Snap work as expected: Expression: The value of | |
Target path
Default Value: N/A | String/Suggestion | Specify the target JSON path where the value from the evaluated expression is written. For example, after evaluation of the Target Path Recommendation For example, you have the Expression $Emp.Emp_Personal.FirstName in one of your pipelines. You set the Target path for this expression as $FirstName. Now, if you use the expression $Emp.Emp_Personal.FirstName in a new pipeline, then Iris recommends $FirstName as one of the Target paths to help you standardize the naming standards in your org. The following shows how Iris recommends the Target path in a Mapper Snap: | |
Snap Execution | Dropdown list | Select one of the three modes in which the Snap executes. Available options are:
|
Input and Output Preview
The Input Schema of the Mapper Snap displays the input strings from the upstream Snap. On validation, the Input Preview displays the preview of the input from the upstream Snap, and the Output Preview displays the output preview that passes to the downstream Snap. The following elements are available in the input and output previews:
Number | Element | Description |
---|---|---|
1 | Expand All | Expands the objects in the Input/Output. |
2 | Collapse All | Collapses the objects in the Input/Output. |
3 | Render whitespace | When you select this checkbox, the blank spaces (leading, trailing, or in the middle of a string) in an expression field renders as symbols in the output:
When you deselect this checkbox, the Snap renders blank spaces and tabs as-is. By default, the Render whitespace checkbox is selected. |
4 | Download | Downloads the JSON file. |
Data Output Example
Successful Mapping | ||
---|---|---|
If your source data looks like | And your mapping looks like | Your output data will look like |
{
"first_name": "John",
"last_name": "Smith",
"phone_num": "123-456-7890"
} |
| {
"full_name": "John Smith",
"phone_num": "123-456-7890"
}
|
Unsuccessful Mapping | ||
{
"first_name": "John",
"last_name": "Smith",
"phone_num": "123-456-7890"
} |
| An error displays. |
Mapper Examples
Watch the Data Mapper in Action
The Data Mapper
Best Practices: Data Transformations and Mappings
Related Content
Community Links:
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.