Skip to content

Commit 5bbba8b

Browse files
authored
fix(SubPlat): Guard against zero-length SubPlat consolidated reporting history records (DENG-9771). (#8177)
1 parent 195308d commit 5bbba8b

File tree

6 files changed

+7
-0
lines changed
  • sql/moz-fx-data-shared-prod/subscription_platform_derived
    • apple_logical_subscriptions_history_v1
    • google_logical_subscriptions_history_v1
    • stripe_logical_subscriptions_attribution_v2
    • stripe_logical_subscriptions_history_v1
    • stripe_service_subscriptions_attribution_v2
    • stripe_subscriptions_history_v2

6 files changed

+7
-0
lines changed

sql/moz-fx-data-shared-prod/subscription_platform_derived/apple_logical_subscriptions_history_v1/query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ WITH subscriptions_history AS (
5252
`moz-fx-data-shared-prod.subscription_platform_derived.apple_subscriptions_history_v1`
5353
WHERE
5454
subscription.last_transaction.in_app_ownership_type = 'PURCHASED'
55+
AND valid_to > valid_from
5556
WINDOW
5657
subscription_changes_asc AS (
5758
PARTITION BY

sql/moz-fx-data-shared-prod/subscription_platform_derived/google_logical_subscriptions_history_v1/query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ WITH subscriptions_history AS (
7272
`moz-fx-data-shared-prod.subscription_platform_derived.google_subscriptions_history_v1`
7373
WHERE
7474
subscription.purchase_type IS DISTINCT FROM 0 -- 0 = Test
75+
AND valid_to > valid_from
7576
),
7677
subscription_starts AS (
7778
SELECT

sql/moz-fx-data-shared-prod/subscription_platform_derived/stripe_logical_subscriptions_attribution_v2/query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ FROM
3333
JOIN
3434
`moz-fx-data-shared-prod.subscription_platform_derived.stripe_subscriptions_history_v2` AS history
3535
ON subscription_starts.stripe_subscriptions_history_id = history.id
36+
AND history.valid_to > history.valid_from
3637
WHERE
3738
history.subscription.metadata.session_flow_id IS NOT NULL
3839
OR history.subscription.metadata.session_entrypoint IS NOT NULL

sql/moz-fx-data-shared-prod/subscription_platform_derived/stripe_logical_subscriptions_history_v1/query.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ WITH subscriptions_history AS (
3636
subscription.status IN ('active', 'past_due', 'trialing') AS subscription_is_active
3737
FROM
3838
`moz-fx-data-shared-prod.subscription_platform_derived.stripe_subscriptions_history_v2`
39+
WHERE
40+
valid_to > valid_from
3941
),
4042
active_subscriptions_history AS (
4143
-- Only include a subscription's history once it becomes active.

sql/moz-fx-data-shared-prod/subscription_platform_derived/stripe_service_subscriptions_attribution_v2/query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ FROM
5151
JOIN
5252
`moz-fx-data-shared-prod.subscription_platform_derived.stripe_subscriptions_history_v2` AS history
5353
ON subscription_starts.stripe_subscriptions_history_id = history.id
54+
AND history.valid_to > history.valid_from
5455
WHERE
5556
history.subscription.metadata.session_flow_id IS NOT NULL
5657
OR history.subscription.metadata.session_entrypoint IS NOT NULL

sql/moz-fx-data-shared-prod/subscription_platform_derived/stripe_subscriptions_history_v2/query.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ subscriptions_customers_history AS (
6060
ON subscriptions_history.subscription.customer_id = customers_history.customer.id
6161
AND subscriptions_history.valid_from < customers_history.valid_from
6262
AND subscriptions_history.valid_to > customers_history.valid_from
63+
AND customers_history.valid_to > customers_history.valid_from
6364
WHERE
6465
subscriptions_history.subscription.ended_at IS NULL
6566
)

0 commit comments

Comments
 (0)