Advertisement
kirzecy670

Untitled

Jun 27th, 2025 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH source_data AS (
  2.   SELECT user::Int64 AS user_id, value, ts
  3.   FROM wimc.mp_userSetting
  4.   WHERE name = 'circles_concept_enabled'
  5.     AND ts >= '2025-06-01'
  6. ),
  7. mart_data AS (
  8.   SELECT user_id, value, ts
  9.   FROM stat.user_setting_history
  10.   WHERE name = 'circles_concept_enabled'
  11.     AND ts >= '2025-06-01'
  12. ),
  13. joined AS (
  14.   SELECT
  15.     s.user_id,
  16.     s.value AS source_value,
  17.     m.value AS mart_value,
  18.     s.ts,
  19.     m.user_id AS matched_user
  20.   FROM source_data s
  21.   LEFT JOIN mart_data m
  22.     ON s.user_id = m.user_id AND s.ts = m.ts
  23. )
  24.  
  25. SELECT
  26.   countIf(matched_user = 0) AS missing_in_clickhouse,
  27.   countIf(matched_user != 0 AND source_value != mart_value) AS value_mismatch,
  28.   count() AS total_records_in_source
  29. FROM joined;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement