Snap type: | Flow | |||||||
---|---|---|---|---|---|---|---|---|
Description: | This Snap filters a document stream based on a expression. If the filter expression evaluates to true, then the document will be passed-through. If the filter expression evaluates to false, then the document will be dropped in the stream. Expressions that do not evaluate to a boolean value will cause the pipeline to fail. Expression functions can be found here. Router vs. Filter The Router and Filter Snaps are similar, but the Filter Snap only handles a single stream. The Router Snap is designed to handle multiple output views. | |||||||
Prerequisites: | [None] | |||||||
Support and limitations: | Works in Ultra Task Pipelines. | |||||||
Account: | Accounts are not used with this Snap. | |||||||
Views: |
| |||||||
Settings | ||||||||
Label* | 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 | Select this checkbox to consider the missing data or empty value as null when accessing the source path. If you deselect this checkbox, the Snap fails and displays error in case there is missing data or empty value when accessing the source path. Default Value: Deselected | |||||||
Filter Expression | The expression to evaluate. If this expression evaluates to true, then the document will be passed through. Otherwise, the document will be dropped. If the expression does not evaluate to a boolean, then the pipeline will fail. $first_name == "Joe" startsWith($description, "Snap") && $quantity < 100
| |||||||
Snap Execution | Select one of the three modes in which the Snap executes. Available options are:
Default Value: Validate & Execute Example: Execute Only |
Example
Enabling the Null-safe Access Option to
This example Pipeline demonstrates how you can enable the Null-safe access option in the Filter Snap to filter data even based missing data or empty value. When this option is not enabled, the Filter Snap fails and displays an error in case there is missing data or empty value when accessing the source path.
Consider a scenario where we have the following data configured in the JSON Generator Snap. Each of the records have both location and salary except ID102 which does not have the location.
Now, if we configure the Filter expression in the Filter Snap as $location=="Hyderabad" || $salary>=20000 that means the Snap should filter and display the records in the output that has the location as Hyderabad OR the salary at least INR 20000.
If we select the Null-safe access checkbox, then even if the Snap finds any missing data while accessing the source path ( such as record#102 which does not have location), it still treats it as null and considers as a valid filter criteria.
As we validate the Pipeline, the Filter Snap returns the output as follows:
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|