SELECT count(*) AS tot_rows
, sum(IF((category IS NULL OR category = '' OR category = ' '), 1, 0)) AS null_category_rows
, sum(IF((status IS NULL OR status = '' OR status = ' '), 1, 0)) AS null_status_rows
, sum(IF((txn_id IS NULL OR txn_id = '' OR txn_id = ' '), 1, 0)) AS null_txn_id_rows
FROM switch.txn_info_snapshot_v3
WHERE dl_last_updated BETWEEN DATE'2025-05-01' AND DATE'2025-05-31';
SELECT count(*) AS tot_rows
, sum(IF((amount IS NULL), 1, 0)) AS null_amount_rows
, sum(IF((participant_type IS NULL OR participant_type = '' OR participant_type = ' '), 1, 0)) AS null_participant_type_rows
, sum(IF((scope_cust_id IS NULL AND participant_type = 'PAYER'), 1, 0)) AS null_scope_cust_id_rows
, sum(IF((txn_id IS NULL OR txn_id = '' OR txn_id = ' '), 1, 0)) AS null_txn_id_rows
, sum(IF((vpa IS NULL OR vpa = '' OR vpa = ' '), 1, 0)) AS null_vpa_rows
FROM switch.txn_participants_snapshot_v3
WHERE dl_last_updated BETWEEN DATE'2025-05-01' AND DATE'2025-05-31';
SELECT count(*) AS tot_rows
, sum(IF((evaluationType IS NULL OR evaluationType = '' OR evaluationType = ' '), 1, 0)) AS null_evaluationType_rows
, sum(IF((latitude IS NULL OR latitude = '' OR latitude = ' '), 1, 0)) AS null_latitude_rows
, sum(IF((longitude IS NULL OR longitude = '' OR longitude = ' '), 1, 0)) AS null_longitude_rows
, sum(IF((osVersion IS NULL OR osVersion = '' OR osVersion = ' '), 1, 0)) AS null_osVersion_rows
, sum(IF((payeeType IS NULL OR payeeType = '' OR payeeType = ' '), 1, 0)) AS null_payeeType_rows
, sum(IF((payeeVpa IS NULL OR payeeVpa = '' OR payeeVpa = ' '), 1, 0)) AS null_payeeVpa_rows
, sum(IF((payerType IS NULL OR payerType = '' OR payerType = ' '), 1, 0)) AS null_payerType_rows
, sum(IF((payerVpa IS NULL OR payerVpa = '' OR payerVpa = ' '), 1, 0)) AS null_payerVpa_rows
, sum(IF((cst_risk_code IS NULL OR cst_risk_code = '' OR cst_risk_code = ' '), 1, 0)) AS null_cst_risk_code_rows
, sum(IF((action_recommended IS NULL OR action_recommended = '' OR action_recommended = ' '), 1, 0)) AS null_action_recommended_rows
FROM
(SELECT txnid
, lower(regexp_replace(cast(json_extract(request, '$.evaluationType') as varchar), '"', '')) AS evaluationType
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.latitude') as varchar), '"', '')) AS latitude
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.longitude') as varchar), '"', '')) AS longitude
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.osVersion') as varchar), '"', '')) AS osVersion
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.payeeType') as varchar), '"', '')) AS payeeType
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.payeeVpa') as varchar), '"', '')) AS payeeVpa
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.payerType') as varchar), '"', '')) AS payerType
, lower(regexp_replace(cast(json_extract(request, '$.requestPayload.payerVpa') as varchar), '"', '')) AS payerVpa
, regexp_replace(cast(json_extract(response, '$.messages.cst[0]') as varchar), '"', '') AS cst_risk_code
, json_extract_scalar(response, '$.action_recommended') AS action_recommended
FROM tpap_hss.upi_switchv2_dwh_risk_data_snapshot_v3
WHERE dl_last_updated BETWEEN DATE'2025-05-01' AND DATE'2025-05-31');