Skip to content

Maayan via Elementary: Fix: Convert historical_orders amounts from cents to dollars#895

Open
joostboon wants to merge 1 commit intomasterfrom
elementary-fix/historical-orders-cents-to-dollars-829471
Open

Maayan via Elementary: Fix: Convert historical_orders amounts from cents to dollars#895
joostboon wants to merge 1 commit intomasterfrom
elementary-fix/historical-orders-cents-to-dollars-829471

Conversation

@joostboon
Copy link
Copy Markdown
Collaborator

Problem

The historical_orders model outputs monetary amounts in cents while real_time_orders outputs them in dollars. Both are unioned in the orders model, causing a 100× mismatch that propagates through:

orderscustomer_conversionsattribution_touchescpa_and_roas

This triggered the column_anomalies (average) test on RETURN_ON_ADVERTISING_SPEND — incident JSO-1.

Fix

  • historical_orders.sql: Apply the cents_to_dollars() macro to all monetary columns (amount, credit_card_amount, coupon_amount, bank_transfer_amount, gift_card_amount), matching the pattern already used in real_time_orders.sql.
  • real_time_orders.sql: Add a clarifying comment noting amounts are in dollars (no logic change).

Validation

After merging, the column_anomalies test on cpa_and_roas.RETURN_ON_ADVERTISING_SPEND should return to normal within one detection period.

Created by: maayan+172@elementary-data.com

historical_orders.amount was in cents while real_time_orders.amount was
in dollars, causing a 100x mismatch in the UNION ALL inside orders.
This propagated up to cpa_and_roas.return_on_advertising_spend,
triggering the column_anomalies test.

Apply the cents_to_dollars() macro to all monetary columns in
historical_orders to match real_time_orders.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant