{"id":"table-count-distinct-check","version":"1.0.0","description":"Check a claimed COUNT(DISTINCT) and optional distinct-value list over JSON rows; returns the first mismatch.","supported_operations":["verify count distinct claim","check number of unique values in a column","did the agent count distinct customers correctly","validate list of distinct values claimed from table","check select distinct result over json rows","unique combination count of two columns check","בדיקת מספר ערכים ייחודיים בעמודה"],"unsupported_operations":["approximate distinct counting (HyperLogLog)","case-insensitive, trimmed or Unicode-normalized equality","producing the distinct list without a claim to check","floating-point cells"],"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 tuple is the listed columns of one row; an absent column is null. null_policy exclude follows COUNT(DISTINCT): a tuple with any null component is eliminated. null_policy include follows SELECT DISTINCT: nulls are not distinct from each other and form a value.","mode json compares typed scalars exactly (1, \"1\" and true differ; strings by exact code units, no normalization). mode numeric reads every non-null cell of the listed columns as an exact rational (safe integer or decimal string), so 1, \"1.0\" and \"1.00\" are one value; any other non-null cell is invalid_input.","claimed_count is a canonical non-negative integer string and is compared first (count_mismatch).","claimed_values (optional; omitted means only the count is checked) lists tuples; value_order (optional, only with claimed_values; omitted means unordered) is first_seen, ascending (null < false < true < integers < strings by code point in json mode; null < numbers by value in numeric mode) or unordered.","Then for each claimed tuple i in order: duplicate_value, unexpected_value (not a computed distinct tuple), value_order_mismatch (ordered modes); finally missing_value for the first computed tuple (first-seen order when unordered) not claimed. expected_value is the computed tuple: the first-seen scalars in json mode, reduced \"n\" or \"n/d\" strings in numeric mode."],"limits":{"max_input_bytes":1048576,"max_rows":10000,"max_columns_per_row":64,"max_distinct_columns":8,"max_claimed_values":10000,"max_numeric_chars":64,"max_value_chars":128},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["rows","columns","mode","null_policy","claimed_count"],"properties":{"rows":{"type":"array","maxItems":10000,"items":{"type":"object","maxProperties":64,"additionalProperties":{"type":["null","boolean","integer","string"]}}},"columns":{"type":"array","minItems":1,"maxItems":8,"items":{"type":"string","minLength":1}},"mode":{"type":"string","enum":["json","numeric"]},"null_policy":{"type":"string","enum":["exclude","include"]},"claimed_count":{"type":"string","pattern":"^(0|[1-9][0-9]*)$","maxLength":128},"claimed_values":{"type":"array","maxItems":10000,"items":{"type":"array","items":{"type":["null","boolean","integer","string"]}}},"value_order":{"type":"string","enum":["first_seen","ascending","unordered"]}}},"output_schema":{"type":"object","additionalProperties":false,"required":["valid","reason","first_discrepancy","reference_version"],"properties":{"valid":{"type":"boolean"},"reason":{"type":["string","null"],"enum":[null,"count_mismatch","duplicate_value","unexpected_value","value_order_mismatch","missing_value"]},"first_discrepancy":{"type":["object","null"],"additionalProperties":false,"required":["value_index","value","expected_value","claimed","computed"],"properties":{"value_index":{"type":["integer","null"],"minimum":0},"value":{"type":["array","null"],"items":{"type":["null","boolean","integer","string"]}},"expected_value":{"type":["array","null"],"items":{"type":["null","boolean","integer","string"]}},"claimed":{"type":["string","null"]},"computed":{"type":["string","null"]}}},"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"},{"city":"San Francisco"},{"city":"Hayward"}],"columns":["city"],"mode":"json","null_policy":"include","claimed_count":"2","claimed_values":[["Hayward"],["San Francisco"]],"value_order":"ascending"},"output":{"valid":true,"reason":null,"first_discrepancy":null,"reference_version":"ISO/IEC 9075-2:2023 (SQL:2023) set functions and grouping, r58 JSON-rows profile 1.0.0"}},{"input":{"rows":[{"price":"1.50"},{"price":"1.5"},{"price":2},{"price":null}],"columns":["price"],"mode":"numeric","null_policy":"exclude","claimed_count":"3"},"output":{"valid":false,"reason":"count_mismatch","first_discrepancy":{"value_index":null,"value":null,"expected_value":null,"claimed":"3","computed":"2"},"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-count-distinct-check/versions/1.0.0/execute"}