Clean orders before connecting customers
Run the order-cleaning pipeline and inspect the removal and replacement policies for missing identifiers.
Question for this chapter
Which rows can be trusted before orders are connected to customers?
Why this matters now
Customer segments group orders by customer_id. An order without an amount or customer ID cannot
represent a valid purchase. When only the product ID is missing, the order can be preserved under an
unknown-product identifier.
Try it
Open the orders_cleaning pipeline under analytics and select Run. The null_cleanup code
treats null and blank strings as missing across order_id, order_date, customer_id,
product_id, and amount. It replaces a missing product ID with PRD-UNKNOWN and removes rows
missing any other required value.

Success looks like this
The pipeline removes 12 of 100 source rows and replaces the product ID on two more, producing 88 clean orders.
| Source problem | Handling | Result |
|---|---|---|
Seven orders with a null amount | Remove because no valid purchase amount exists | 7 removed |
Five orders with a blank customer_id | Remove because no customer-purchase relation can be formed | 5 removed |
Two orders with a blank product_id | Replace with PRD-UNKNOWN | 2 retained |
There is no missing order_date in the current seed. No null or blank string remains in the five
required columns.

Interpret the result
null and "" have different storage representations, but both are missing values in this
pipeline. The result depends on the field's meaning. A row without a customer or order identity is
removed; a row missing only its product is grouped under the unknown product.
This contract produces 22 customer-analytics rows and a complete ontology with 22 customers, 88 orders, and 9 products. It also creates 88 customer-order relations and 88 order-product relations.
Next decision
You know the scope available for segmentation. Next, turn recency, frequency, and monetary value into plain customer-state questions.