fix(statistics): qualify profile backfill target columns
This commit is contained in:
parent
93395f01d0
commit
4fb1a69353
@ -56,12 +56,14 @@ WHERE event.app_code IN ('lalu', 'huwaa', 'fami')
|
|||||||
AND event.occurred_at_ms >= @profile_start_from_ms
|
AND event.occurred_at_ms >= @profile_start_from_ms
|
||||||
AND event.occurred_at_ms < @profile_start_to_ms
|
AND event.occurred_at_ms < @profile_start_to_ms
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
user_id = CASE WHEN VALUES(user_id) > 0 THEN VALUES(user_id) ELSE user_id END,
|
-- INSERT ... SELECT 的源表和目标表拥有同名列;目标旧值必须显式限定表名,
|
||||||
device_id = CASE WHEN VALUES(device_id) <> '' THEN VALUES(device_id) ELSE device_id END,
|
-- 否则 MySQL 会把未限定列判定为 ambiguous,并留下只加列、未回灌的半迁移状态。
|
||||||
country_id = CASE WHEN VALUES(country_id) > 0 THEN VALUES(country_id) ELSE country_id END,
|
user_id = CASE WHEN VALUES(user_id) > 0 THEN VALUES(user_id) ELSE stat_social_user_day.user_id END,
|
||||||
region_id = CASE WHEN VALUES(region_id) > 0 THEN VALUES(region_id) ELSE region_id END,
|
device_id = CASE WHEN VALUES(device_id) <> '' THEN VALUES(device_id) ELSE stat_social_user_day.device_id END,
|
||||||
profile_setup_view = GREATEST(profile_setup_view, VALUES(profile_setup_view)),
|
country_id = CASE WHEN VALUES(country_id) > 0 THEN VALUES(country_id) ELSE stat_social_user_day.country_id END,
|
||||||
updated_at_ms = GREATEST(updated_at_ms, VALUES(updated_at_ms));
|
region_id = CASE WHEN VALUES(region_id) > 0 THEN VALUES(region_id) ELSE stat_social_user_day.region_id END,
|
||||||
|
profile_setup_view = GREATEST(stat_social_user_day.profile_setup_view, VALUES(profile_setup_view)),
|
||||||
|
updated_at_ms = GREATEST(stat_social_user_day.updated_at_ms, VALUES(updated_at_ms));
|
||||||
|
|
||||||
SELECT ROW_COUNT() AS social_profile_setup_view_backfill_affected_rows;
|
SELECT ROW_COUNT() AS social_profile_setup_view_backfill_affected_rows;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user