Skip to content

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

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

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

Conversation

@joostboon
Copy link
Copy Markdown
Collaborator

Problem\n\nThe historical_orders model was outputting monetary amounts in cents while real_time_orders outputs them in dollars. Since the orders model unions both via UNION ALL, this created a ~100× mismatch in the amount column for historical records.\n\nThis propagated through the pipeline:\nhistorical_ordersorderscustomer_conversionsattribution_touchescpa_and_roas\n\n...causing the RETURN_ON_ADVERTISING_SPEND anomaly test to fail with inflated ROAS values (incident has been failing for 69 consecutive runs).\n\n## Fix\n\n- historical_orders.sql: Apply the cents_to_dollars macro to all monetary columns, matching the pattern already used in real_time_orders.sql\n- real_time_orders.sql: Add a clarifying comment that amounts are in dollars (no logic changes)\n\n## Impact\n\nThis fix will normalize all monetary values to dollars across both order sources, resolving the ROAS anomaly on cpa_and_roas.

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

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