Unique Rows (HashSet) transform Icon Unique Rows (HashSet)

Description

The Unique Rows (HashSet) transform removes duplicate rows and filters only the unique rows as input data for the transform.

This transform differs from the Unique Rows pipeline transform by keeping track of the duplicate rows in memory and does not require a sorted input to process duplicate rows.

When using this transform on larger sets of data there is a risk of hash collisions unless "Compare using stored row values" is enabled.

The hash set this transform uses to spot duplicates lives in the memory of a single worker, and the distributed pipeline engines spread the rows over many workers.

  • The Beam engines give this transform all the rows of its input at once, on one worker, so it sees every duplicate. That worker holds the rows in memory, and the transform is not available in a streaming pipeline. See Transforms that need the whole stream.

  • On the native Spark engine the rows with the same values in the fields to compare (all fields when none are set) are brought to one partition first, in the order they came in. Each partition then keeps its own hash set, which sees every row of its keys: the first row of a key is the one kept, as on the local engine, and redirected duplicates go to the error hop.

Options

Option Description

Transform Name

Name of the transform this name has to be unique in a single pipeline.

Compare using stored row values

Select this option to store values for the selected fields in memory for every record. Storing row values requires more memory, but it prevents possible false positives if there are hash collisions.

Redirect duplicate row

Select this option to process duplicate rows as an error and redirect them to the error stream of the transform. If you do not select this option, the duplicate rows are deleted.

Error description

Specify the error handling description that displays when the transform detects duplicate rows. This description is only available when Redirect duplicate row is selected.

Fields to compare table

Specify the field names for which you want to find unique values.

-OR-

Select Get to insert all the fields from the input stream.

Samples

The samples project has transforms/unique-rows-hashset.hpl, which keeps the first row of each name and city of 6 rows from a Data grid: 4 rows are left.