{"id":"table-aggregate-check","version":"1.0.0","description":"Check claimed COUNT/SUM/AVG/MIN/MAX results over JSON rows exactly (SQL nulls); returns the first mismatch.","supported_operations":["check claimed sum of a table column","verify count and total over json rows","check average min max claims against table data","did the agent compute the column total correctly","verify sql aggregate results with null semantics","exact rational sum check for decimal column","בדיקת סכום וממוצע של עמודה בטבלה"],"unsupported_operations":["producing a report or chart of the aggregates","GROUP BY results (use table-groupby-check)","COUNT(DISTINCT) claims (use table-count-distinct-check)","floating-point cells or approximate tolerance comparisons","string MIN/MAX under a collation"],"semantics":["Implements ISO/IEC 9075-2:2023 (SQL:2023) set functions and grouping, r58 JSON-rows profile 1.0.0; every result carries reference_version.","A row is a JSON object; a column absent from a row is the SQL null value. Cells are null, boolean, string or safe integer; non-integer JSON numbers are rejected (write decimals as strings).","count_star counts rows; count counts non-null cells; sum, avg, min and max ignore nulls and return null when no non-null cell exists (SQL:2023 10.9), so sum of an empty table is null, not 0.","sum, avg, min and max read safe integers and decimal strings (-?(0|[1-9][0-9]*)(.[0-9]+)?) as exact rationals; any other non-null cell (boolean, other string) is invalid_input non_numeric_value. avg is the exact rational sum/count.","A claimed value is null or a string: integer, p/q fraction or decimal; it is compared by exact value, so \"0.5\", \"1/2\" and \"2/4\" are equal. computed is the reduced canonical form \"n\" or \"n/d\".","All claims are parsed and every referenced numeric column is type-checked over all rows before any comparison; then claims are compared in input order and the first mismatch is reported (reason <function>_mismatch).","claims_checked is the number of claims compared: all of them when valid, index + 1 of the first mismatch otherwise."],"limits":{"max_input_bytes":1048576,"max_rows":10000,"max_columns_per_row":64,"max_claims":64,"max_numeric_chars":64,"max_value_chars":128},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["rows","claims"],"properties":{"rows":{"type":"array","maxItems":10000,"items":{"type":"object","maxProperties":64,"additionalProperties":{"type":["null","boolean","integer","string"]}}},"claims":{"type":"array","minItems":1,"maxItems":64,"items":{"type":"object","additionalProperties":false,"required":["function","value"],"properties":{"function":{"type":"string","enum":["count_star","count","sum","avg","min","max"]},"column":{"type":"string","minLength":1},"value":{"type":["string","null"],"maxLength":128}}}}}},"output_schema":{"type":"object","additionalProperties":false,"required":["valid","reason","first_discrepancy","claims_checked","reference_version"],"properties":{"valid":{"type":"boolean"},"reason":{"type":["string","null"],"enum":[null,"count_star_mismatch","count_mismatch","sum_mismatch","avg_mismatch","min_mismatch","max_mismatch"]},"first_discrepancy":{"type":["object","null"],"additionalProperties":false,"required":["claim_index","function","column","claimed","computed"],"properties":{"claim_index":{"type":"integer","minimum":0},"function":{"type":"string"},"column":{"type":["string","null"]},"claimed":{"type":["string","null"]},"computed":{"type":["string","null"]}}},"claims_checked":{"type":"integer","minimum":0},"reference_version":{"type":"string","const":"ISO/IEC 9075-2:2023 (SQL:2023) set functions and grouping, r58 JSON-rows profile 1.0.0"}}},"examples":[{"input":{"rows":[{"city":"San Francisco","temp_lo":46},{"city":"San Francisco","temp_lo":43},{"city":"Hayward","temp_lo":37}],"claims":[{"function":"max","column":"temp_lo","value":"46"},{"function":"count_star","value":"3"}]},"output":{"valid":true,"reason":null,"first_discrepancy":null,"claims_checked":2,"reference_version":"ISO/IEC 9075-2:2023 (SQL:2023) set functions and grouping, r58 JSON-rows profile 1.0.0"}},{"input":{"rows":[{"amount":"0.10"},{"amount":"0.20"},{"amount":null},{}],"claims":[{"function":"count","column":"amount","value":"2"},{"function":"sum","column":"amount","value":"0.30000000000000004"}]},"output":{"valid":false,"reason":"sum_mismatch","first_discrepancy":{"claim_index":1,"function":"sum","column":"amount","claimed":"0.30000000000000004","computed":"3/10"},"claims_checked":2,"reference_version":"ISO/IEC 9075-2:2023 (SQL:2023) set functions and grouping, r58 JSON-rows profile 1.0.0"}},{"input":{"rows":[],"claims":[{"function":"sum","column":"x","value":"0"}]},"output":{"valid":false,"reason":"sum_mismatch","first_discrepancy":{"claim_index":0,"function":"sum","column":"x","claimed":"0","computed":null},"claims_checked":1,"reference_version":"ISO/IEC 9075-2:2023 (SQL:2023) set functions and grouping, r58 JSON-rows profile 1.0.0"}}],"execute_url":"/v1/tools/table-aggregate-check/versions/1.0.0/execute"}