Skip to content

Commit 77dd20d

Browse files
authored
fix(SubPlat): Handle plan_change_date values with milliseconds (bug 2005610). (#8594)
1 parent 5b193db commit 77dd20d

File tree

1 file changed

+5
-2
lines changed
  • sql/moz-fx-data-shared-prod/subscription_platform_derived/nonprod_stripe_subscriptions_history_v1

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ WITH base_subscriptions_history AS (
1616
JSON_VALUE(metadata, "$.cancelled_for_customer_at") AS canceled_for_customer_at,
1717
ended_at,
1818
status,
19-
TIMESTAMP_SECONDS(
20-
CAST(JSON_VALUE(metadata, "$.plan_change_date") AS INT64)
19+
-- SubPlat ran a test script for PAY-3440 which accidentally set `plan_change_date` using milliseconds for some records.
20+
IF(
21+
LENGTH(JSON_VALUE(metadata, "$.plan_change_date")) > 12,
22+
TIMESTAMP_MILLIS(CAST(JSON_VALUE(metadata, "$.plan_change_date") AS INT64)),
23+
TIMESTAMP_SECONDS(CAST(JSON_VALUE(metadata, "$.plan_change_date") AS INT64))
2124
) AS plan_change_date,
2225
JSON_VALUE(metadata, "$.previous_plan_id") AS previous_plan_id,
2326
FROM

0 commit comments

Comments
 (0)