Skip to content

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

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

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

Conversation

@joostboon
Copy link
Copy Markdown
Collaborator

Problem

The historical_orders model outputs monetary amounts (amount, credit_card_amount, etc.) in cents, while real_time_orders converts them to dollars using the cents_to_dollars() macro. When these are UNION ALL'd in the orders model, the mixed units cause a ~100× inflation in revenue that propagates through:

orderscustomer_conversionsattribution_touchescpa_and_roas

This is the root cause of the persistent RETURN_ON_ADVERTISING_SPEND anomaly incident (HIGH severity, ongoing since Oct 2025).

Fix

  • historical_orders.sql: Apply cents_to_dollars() to all monetary columns, matching real_time_orders.
  • real_time_orders.sql: Add clarifying comment (no logic change).

Impact

Once merged and rebuilt, the ROAS metric in cpa_and_roas will return to normal values and the anomaly incident should resolve.

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

historical_orders.amount was still in cents while real_time_orders.amount
was already converted to dollars via cents_to_dollars(). This caused a
~100x inflation in revenue flowing into cpa_and_roas, triggering the
ROAS anomaly detection test.
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