Query editor
WITH config AS (SELECT * FROM "query_8094634"), participants AS (SELECT * FROM "query_8094637"), checks AS (SELECTCOUNT(*) AS participant_rows,COUNT(DISTINCT participant) AS unique_participants,COUNT_IF(inferred_category = 'US') AS us_participants,COUNT_IF(inferred_category = 'non-US') AS non_us_participants,COUNT_IF(inferred_category = 'review') AS review_participants,SUM(allocation_xpl) AS total_sale_xpl,SUM(CASE WHEN inferred_category = 'US' THEN allocation_xpl ELSE 0 END) AS us_xpl,SUM(CASE WHEN inferred_category = 'non-US' THEN allocation_xpl ELSE 0 END) AS non_us_xpl,COUNT_IF(inferred_category = 'non-US' AND matching_trace_count = 1) AS exact_non_us_matches,COUNT_IF(inferred_category = 'US' AND matching_trace_count = 0) AS exact_us_residuals,COUNT_IF(allocation_xpl <= 0) AS non_positive_allocations,MIN(CASE WHEN inferred_category = 'non-US' THEN distribution_block END) AS first_distribution_block,MAX(CASE WHEN inferred_category = 'non-US' THEN distribution_block END) AS last_distribution_blockFROM participants)SELECTc.*,ABS(c.total_sale_xpl - cfg.public_sale_xpl) < 0.0001 AS sale_reconciles_to_1b,c.participant_rows = c.unique_participants AS participants_are_unique,c.review_participants = 0 AS no_review_rows,c.exact_non_us_matches = c.non_us_participantsAND c.exact_us_residuals = c.us_participants AS trace_match_is_one_to_one,c.non_positive_allocations = 0 AS all_allocations_positive,c.us_participants = 87AND ABS(c.us_xpl - 12671727.60794) < 0.0001 AS us_snapshot_pass,c.non_us_participants = 3021AND ABS(c.non_us_xpl - 987328272.39206) < 0.0001 AS non_us_snapshot_pass,c.participant_rows = 3108AND ABS(c.total_sale_xpl - cfg.public_sale_xpl) < 0.0001AND c.participant_rows = c.unique_participantsAND c.review_participants = 0AND c.exact_non_us_matches = c.non_us_participantsAND c.exact_us_residuals = c.us_participantsAND c.non_positive_allocations = 0AND c.us_participants = 87AND ABS(c.us_xpl - 12671727.60794) < 0.0001AND c.non_us_participants = 3021AND ABS(c.non_us_xpl - 987328272.39206) < 0.0001 AS validation_passFROM checks cCROSS JOIN config cfg