Query editor
WITHr AS (SELECT *FROM dune.propeller_heads.result_tycho_router_call_raw_v3_tailWHERE call_class = 'swap'AND parser_status = 'parsed_declared_input'),m AS (SELECT *FROM dune.propeller_heads.result_tycho_movement_modern_v3_history_20260723UNION ALLSELECT *FROM dune.propeller_heads.result_tycho_movement_legacy_router3_v3_history_20260723UNION ALLSELECT *FROM dune.propeller_heads.result_tycho_movement_legacy_router12_v3_history_20260723UNION ALLSELECT * FROM dune.propeller_heads.result_tycho_movement_modern_v3_tailUNION ALLSELECT *FROM dune.propeller_heads.result_tycho_movement_legacy_router3_v3_tailUNION ALLSELECT *FROM dune.propeller_heads.result_tycho_movement_legacy_router12_v3_tail),checks AS (SELECT 'movement_duplicate_key' AS check_name, COUNT(*) AS failing_rowsFROM (SELECT router_call_key FROM m GROUP BY 1 HAVING COUNT(*) > 1)UNION ALLSELECT 'raw_tail_missing_movement_key', COUNT(*)FROM rLEFT JOIN mON m.router_call_key = r.router_call_keyWHERE m.router_call_key IS NULLUNION ALLSELECT 'verified_tail_value_null', COUNT(*)FROM rINNER JOIN mON m.router_call_key = r.router_call_keyWHERE m.economic_input_status LIKE 'verified_%'AND m.economic_amount_in_atomic IS NULLUNION ALLSELECT 'unresolved_tail_movement', COUNT(*)FROM rINNER JOIN mON m.router_call_key = r.router_call_keyWHERE m.economic_input_status NOT LIKE 'verified_%'AND m.economic_input_status<> 'excluded_source_proven_empty_sequential_no_executor_non_dex')SELECTcheck_name,failing_rows,CASE WHEN failing_rows = 0 THEN 'pass' ELSE 'error' END AS statusFROM checks;