Skip to content

Joost Boonzajer Flaes via Elementary: Fix unit mismatch between historical_orders and real_time_orders #414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joostboon
Copy link
Collaborator

Description

This PR fixes a critical unit mismatch between the historical_orders and real_time_orders models that was causing anomalies in the RETURN_ON_ADVERTISING_SPEND metric.

Problem

  • real_time_orders: Uses the cents_to_dollars macro to convert amounts to dollars
  • historical_orders: Passes through amounts in cents without conversion

This resulted in a ~100× scale difference in the data feeding into downstream models, causing the ROAS calculation to be inconsistent.

Changes

  1. Modified historical_orders.sql to:

    • Rename the amount column to amount_cents for clarity
    • Apply the cents_to_dollars macro to all monetary values
    • Use consistent formatting with real_time_orders
  2. Added documentation comment to real_time_orders.sql to clarify that all monetary values are in dollars

Impact

This fix will normalize all monetary values across the pipeline, ensuring that calculations like ROAS are consistent regardless of whether the data comes from historical or real-time sources.

Created by: [email protected]

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