Skip to content

Conversation

@iamcxa
Copy link

@iamcxa iamcxa commented Oct 30, 2025

No description provided.

@DataRecce DataRecce deleted a comment from claude bot Oct 30, 2025
@DataRecce DataRecce deleted a comment from claude bot Oct 30, 2025
@DataRecce DataRecce deleted a comment from claude bot Oct 30, 2025
@DataRecce DataRecce deleted a comment from claude bot Oct 30, 2025
@DataRecce DataRecce deleted a comment from recce-cloud bot Oct 30, 2025
@DataRecce DataRecce deleted a comment from claude bot Oct 30, 2025
@iamcxa
Copy link
Author

iamcxa commented Oct 30, 2025

@claude

@claude
Copy link

claude bot commented Oct 30, 2025

Claude finished @iamcxa's task —— View job


PR Validation Summary

⚠ Anomalies Detected

🔴 Schema Changes Detected - New columns added to core models:

  • customers model: Added 1 new column (net_customer_lifetime_value)
  • customer_segments model: Added 2 new columns (net_customer_lifetime_value, net_value_segment)
  • stg_payments model: Added 1 new column (coupon_amount)

Business Logic Changes - CLV calculation methodology modified:

  • Changed from single CLV metric to dual CLV tracking (gross vs. net)
  • Added filtering for completed orders only (orders.status = 'completed')
  • Added data quality filters (non-null, positive amounts only)
  • New coupon tracking in staging layer

Unable to Validate Data Quality - Runtime errors encountered:

  • Row count validation failed: finance_revenue table not built in current environment
  • Value diff validation failed: Models need to be rebuilt before comparison
  • Profile diff validation failed: No data available for comparison

Changes Overview

  • Models: 3 modified, 1 new, 0 removed
  • Schema Changes: 4 columns added across 3 models
  • New Model: finance_revenue (revenue tracking with gross/net metrics)

Modified Models & Columns

customers (modified)

  • ✅ Renamed: total_amountcustomer_lifetime_value (gross CLV)
  • ➕ Added: net_customer_lifetime_value (net CLV excluding coupons)
  • 🔧 Logic change: Now filters for completed orders only
  • 🔧 Logic change: Added data quality filters (non-null, positive amounts)

customer_segments (modified)

  • ➕ Added: net_customer_lifetime_value column
  • ➕ Added: net_value_segment column (segmentation based on net CLV)

stg_payments (modified)

  • ➕ Added: coupon_amount column (extracted from payment_method)

finance_revenue (new)

  • New revenue tracking model with gross/net revenue metrics per order
  • Columns: order_id, customer_id, order_date, status, gross_revenue, net_revenue

Downstream Impact

The changes to customers model impact:

  • customer_segments (direct dependency - updated to use new column)
  • customer_order_pattern (indirect dependency - may need review)

✅ Test Status

  • Schema validation: Successfully retrieved lineage diff showing 3 modified models + 1 new model
  • Row count validation: Failed - models not built in current environment
  • Value diff validation: Failed - customers table not available for comparison
  • Query diff validation: Failed - customers table not available for comparison

Note: The preset checks could not complete due to models not being built in the current (dev) environment. The data has been built in the base (prod) environment but not in the current branch's environment.


📊 Schema Changes Analysis

stg_payments Schema Change

Added column: coupon_amount

-- NEW: Line 20
(payment_method = 'coupon')::int * (amount / 100) as coupon_amount

This creates a new metric to track coupon amounts separately, enabling net revenue calculations.

customers Schema & Logic Changes

Column changes:

  • total_amount renamed to customer_lifetime_value (gross)
  • Added net_customer_lifetime_value (net of coupons)

Business logic changes:

-- BEFORE
sum(amount)::bigint as total_amount

-- AFTER
sum(amount)::bigint as gross_amount, -- Includes coupon amount
sum(amount - coupon_amount)::bigint as net_amount, -- Excludes coupon amount

New filtering logic:

-- Added: Only completed orders
and orders.status = 'completed'

-- Added: Data quality filters
where payments.amount is not null
  and payments.amount > 0

customer_segments Schema Changes

Added columns:

  • net_customer_lifetime_value (passes through from customers)
  • net_value_segment (new segmentation based on net CLV)

🔍 Suggested Checks

Critical validations needed before merge:

  1. Build & Test Current Environment: Run dbt build in the dev environment to ensure all models compile and execute successfully

  2. Row Count Validation: After building, verify row counts match expectations

    • Check: customers, orders, customer_segments, finance_revenue
  3. CLV Metric Validation: Verify the impact of business logic changes

    • Completed orders filter: Confirm expected reduction in CLV values due to filtering out non-completed orders
    • Data quality filters: Validate that null/negative amounts exclusion doesn't drop legitimate records
    • Coupon logic: Verify coupon_amount calculation is correct and net CLV = gross CLV - coupons
  4. Downstream Impact: Validate dependent models

    • Check: customer_order_pattern still works with new customers schema
    • Check: Any BI dashboards or reports using customer_lifetime_value need updates?
  5. Query Diff Validation (after build):

  6. Value Diff Validation (after build):

    • Run preset check [bad example] fac_orders #3: 100% match validation for customer_id and customer_lifetime_value
    • Expect differences due to business logic changes - verify they're intentional
  7. Finance Revenue Model: Validate the new finance_revenue model

    • Verify gross vs net revenue calculations are correct
    • Check for any unexpected NULL values in revenue columns

📝 Summary

This PR introduces a significant enhancement to financial metrics tracking by:

  1. Splitting CLV into gross and net metrics to account for coupon impacts
  2. Improving data quality with filters for completed orders and valid payment amounts
  3. Adding a new revenue model (finance_revenue) for centralized revenue tracking
  4. Extending customer segmentation with net value segments

⚠️ Important Notes:

  • The preset validation checks could not fully execute because models need to be built in the current environment
  • The business logic changes will impact CLV values (likely decrease due to completed-orders-only filter)
  • This is a breaking change for any downstream consumers expecting the old total_amount column name
  • Recommend thorough validation of CLV calculations before merging, especially the impact of the completed orders filter

Recommended Next Steps:

  1. Build models in dev environment: dbt build --select state:modified+
  2. Run full Recce validation suite after build
  3. Validate CLV changes are as expected
  4. Update any documentation or BI dashboards referencing the old column names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants