Diff

Overview

You can use this Snap to compare two sorted streams of documents (Original and New) and return four output streams: Deletions, Insertions, Modified, and Unmodified.

Ensure the first input is always New and the second input as Original in order for the Snap to display the output (insertions/deletions/modifications) in reference to the original document.

Note: This Snap does not handle arrays. You need to flatten an array into documents using the JSON Splitter, then sort the data before sending it to the Diff Snap.


Limitations

When using the new UI form to create new or edit existing Pipelines with the Diff Snap, Output view name values go missing in Snap Settings after switching to the Views or Info tab. The workaround is to switch back to the old UI form (disable New UI Form in User Settings) and then create the new Pipelines or edit existing pipelines.

Snap views

View Description Examples of upstream and downstream Snaps
Input

This Snap has exactly two document input views: New and Original.

Ensure the first input is always New and the second input as Original in order for the Snap to display the output (insertions/deletions/modifications) in reference to the original document.

Output

This Snap has four document output views:

  • Deletions – Contains documents that exist in the Original view but not the New view.
  • Insertions – Contains documents that exist in the New view but not the Original view.
  • Modified – Contains documents that exist in both views but are different in some property.
  • Unmodified – Contains documents that are the same in both input views.
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Diff

Example: Diff_new

Sort paths String Required. Specify the list of paths to sort on. For example, to sort a list of person objects by the field firstname, then $person.firstname should be used.

Default value: None

Example: $person.firstname

Sort order Dropdown list Required. Allows you to map output view name to output view type if you removed and then re-added output views.

Default value: Ascending

Example: Descending

Output view mapping String Required. Allows you to map output view name to output view type if you removed and then re-added output views.
Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Validate & Execute

Example: Disabled