> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prophecy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Wipe and Replace Rows Per Predicate

> Replace all the rows in a partition that match a predicate

Update records that match conditions defined in the **Use Predicate** parameter. Instead of updating individual rows, it replaces the entire partition of the table that matches the given predicate. The predicate defines which rows in the target table should be fully replaced with the incoming data.

## Parameters

| Parameter                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Use Predicate                                      | Lets you add conditions that specify when to apply the merge.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Use a condition to filter data or incremental runs | Enables applying conditions for filtering the incoming data into the table.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| (Advanced) On Schema Change                        | Specifies how schema changes should be handled during the merge process.<ul><li><strong>ignore</strong>: Newly added columns will not be written to the model. This is the default option.</li><li><strong>fail</strong>: Triggers an error message when the source and target schemas diverge.</li><li><strong>append\_new\_columns</strong>: Append new columns to the existing table.</li><li><strong>sync\_all\_columns</strong>: Adds any new columns to the existing table, and removes any columns that are now missing. Includes data type changes. This option uses the output of the previous gem.</li></ul> |

## Example: Replace sales from January 5 onward

A sales table uses the predicate `sale_date >= '2024-01-05'`. When a corrected dataset arrives, Prophecy removes all rows that satisfy the predicate and replaces them with the incoming dataset. Rows that do not satisfy the predicate remain unchanged.

**Predicate**: `sale_date >= '2024-01-05'`

<div class="table-example">
  **Existing target table**

  | ORDER\_ID | PRODUCT  | SALE\_DATE | STATUS |
  | --------- | -------- | ---------- | ------ |
  | 101       | Laptop   | 2023-12-20 | Open   |
  | 201       | Mouse    | 2024-01-05 | Open   |
  | 202       | Monitor  | 2024-01-10 | Open   |
  | 203       | Keyboard | 2024-01-15 | Open   |

  **Incoming dataset**

  | ORDER\_ID | PRODUCT | SALE\_DATE | STATUS |
  | --------- | ------- | ---------- | ------ |
  | 201       | Mouse   | 2024-01-05 | Closed |
  | 202       | Monitor | 2024-01-10 | Closed |

  **Resulting target table**

  | ORDER\_ID | PRODUCT | SALE\_DATE | STATUS |
  | --------- | ------- | ---------- | ------ |
  | 101       | Laptop  | 2023-12-20 | Open   |
  | 201       | Mouse   | 2024-01-05 | Closed |
  | 202       | Monitor | 2024-01-10 | Closed |

  Because this write mode replaces all rows that satisfy the predicate, Prophecy removes every existing row that matches the predicate before writing the incoming dataset. Rows that do not satisfy the predicate remain unchanged. In this example, the row for `2024-01-15` (`ORDER_ID` `203`) is removed because it matches the predicate but is not included in the incoming dataset, while the row from `2023-12-20` remains unchanged.
</div>
