Code RoomQuery rewrite claims identical results
HardPrep Room Coding #4190

Query rewrite claims identical results

Vibe & agenticDatabases & SQLSenior–Staff~20 min

An AI agent rewrote a slow analytics query and a backing SQL migration, claiming the new query "returns identical results, just faster" by replacing a correlated subquery with a window function and adding an index. The numbers in a spot-check on staging matched. How do you verify 'identical results' rigorously before this replaces a query that feeds finance dashboards, and what's the failure mode you're specifically guarding against?

Implement
diff_result_sets(old_rows: list[str], new_rows: list[str]) → list[str]
Examples
in[["a|10","b|20"],["a|10","b|20"]]out[]
in[["m|1","m|1","z|9"],["m|1","z|9"]]out["-m|1 x1"]
in[["a"],["a","b"]]out["+b x1"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 20 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.