Skip to content

Michael Myaskovsky via Elementary: Fix monetary unit inconsistency causing ROAS anomaly #395

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

Problem

The anomaly detection test on RETURN_ON_ADVERTISING_SPEND is failing because of a unit inconsistency between the historical_orders and real_time_orders models.

  • The real_time_orders model properly converts monetary values from cents to dollars using the cents_to_dollars macro
  • The historical_orders model doesn't perform any conversion, keeping values in cents

When these models are unioned in the orders model, this creates inconsistent units that flow through the pipeline, causing ROAS calculations to be significantly off.

Solution

This PR:

  1. Modifies historical_orders.sql to convert monetary values from cents to dollars using the cents_to_dollars macro, just like real_time_orders does
  2. Adds a comment to real_time_orders.sql to make it explicit that monetary amounts are in dollars

Testing

After this change, the unit consistency should be fixed and the anomaly detection test should pass once the models are rerun.

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