Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Transform


Description:

This Snap compares two sorted streams of documents (Original and New) and returns four output streams: Deletions, Insertions, Modified and Unmodified.

Note

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 will need to flatten an array into documents using the JSON Splitter, then sort the data before sending it to the Diff Snap.


 

Prerequisites:

[None].


Support and limitations:
  • Ultra pipelines: Does not work in Ultra Pipelines
  • Spark mode: Not supported in /wiki/spaces/SD/pages/1437917 modeNone.
    Account: 

    Accounts are not used with this Snap.


    Views:


    Input

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

    Note

    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.
    ErrorThis Snap has at most one document error view and produces zero or more documents in the view.


    Settings



    Label


    Required. 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.

    Sort paths



    Required. 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.

    Example$person.firstname

    Default value: [None]


    Sort order


    Required. Ordering of the sort of the data coming in. Allowed values are ascending or descending.

    Default value: ascending


    Output view mapping


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

    Multiexcerpt include macro
    nameSnap Execution
    pageAnaplan Read


    Multiexcerpt include macro
    nameSnap_Execution_Introduced
    pageAnaplan Read

    Examples


    A Diff Made between Two Files Shows What Data Goes to Which Output View

    In this example, a diff is made between two files, showing what data goes to which output view.

     


    Let's assume that the original file contains only a rew records (as demonstrated being created in a CSV Generator Snap, but can be a read from a File Reader with a CSV Parser).


     

    By comparison, the new file has over 1000 records (again, demonstrated being created in a CSV Generator Snap).

     


    Because the compare can only be done of sorted stream, each file will need to be sorted by the same column, such as $Last, with the same sort order, so add a Sort Snap after each file input (CSV Generators in this example).

    Next, configure the Diff Snap with the Sort path and Sort order

    This results in deleted lines routing to the Deletions view, new lines to the Insertions view, modified lines to the Modified view, and unchanged lines to the Unmodified view.

    Reading an Original csv File and a Modified Version

    This example pipeline reads two files, an original csv and a modified version. The modified version includes changes to existing rows, deleted rows and added rows. It creates four different output files based on the diff conditions.

     

    Downloads

    Attachments
    patterns.*slp, .*zip

    Insert excerpt
    Transform Snap Pack
    Transform Snap Pack
    nopaneltrue