Flag Duplicate Keys

Start with four pinned order_id values. Read them in row order and remember which keys have already appeared. The output keeps the original rows and adds order_id_duplicate. This is a validation check, not a deduplication step.

Checking whether a pinned key column is unique by adding a validation flag without dropping or changing rows.

highlighted = computed this step

Input key column

Start with 4 rows and one order_id column.

order id column\text{order id column}
Input Order IDsroworder_id1A0012A0023A0024A004

Row-by-row key check

Read rows in order: the first repeated key is OK, and the second repeated key is duplicate.

first seen versus duplicate\text{first seen versus duplicate}
Unique-Key Checkroworder_idseen before?status1A001noOK2A002noOK3A002yesduplicate4A004noOK

Add duplicate flag

Keep every row unchanged and add order_id_duplicate.

validation flag only\text{validation flag only}
Rows with Validation Flagroworder_idorder_id_duplicate1A001false2A002false3A002true4A004false