Spaces:
Sleeping
Sleeping
Download data/hard.json from skillissue04/sql-repair-env: direct link, hf CLI and curl.
- Browser
- Download file 11.1 kB
-
https://huggingface.co/spaces/skillissue04/sql-repair-env/resolve/main/data/hard.json
- Command line
-
hf download hf://spaces/skillissue04/sql-repair-env/data/hard.json
-
curl -L -o hard.json https://huggingface.co/spaces/skillissue04/sql-repair-env/resolve/main/data/hard.json
11.1 kB
| [ | |
| { | |
| "id": "hard_001", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "Find users who bought a product and also reviewed it, show user name and product name", | |
| "broken_query": "SELECT u.name, p.name FROM users u JOIN orders o ON u.id = o.user_id JOIN reviews r ON u.id = r.user_id JOIN products p ON p.id = o.product_id", | |
| "correct_query": "SELECT DISTINCT u.name, p.name FROM users u JOIN orders o ON u.id = o.user_id JOIN reviews r ON u.id = r.user_id AND o.product_id = r.product_id JOIN products p ON p.id = o.product_id", | |
| "error_type": "join", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "how to match bought and reviewed same product": "join reviews on both user_id AND product_id", | |
| "reviews columns": "user_id, product_id, rating, body", | |
| "orders columns": "user_id, product_id, amount, status" | |
| } | |
| }, | |
| { | |
| "id": "hard_002", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "Get products with average rating above 4.0 that are also currently in stock, ordered by average rating descending", | |
| "broken_query": "SELECT p.name, AVG(r.rating) FROM products p JOIN reviews r ON p.id = r.product_id WHERE AVG(r.rating) > 4.0 AND stock > 0 ORDER BY AVG(r.rating) DESC", | |
| "correct_query": "SELECT p.name, AVG(r.rating) AS avg_rating FROM products p JOIN reviews r ON p.id = r.product_id WHERE p.stock > 0 GROUP BY p.id, p.name HAVING AVG(r.rating) > 4.0 ORDER BY avg_rating DESC", | |
| "error_type": "logic", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "stock column location": "stock is in the products table", | |
| "aggregate filter placement": "use HAVING for AVG filter, WHERE for stock filter" | |
| } | |
| }, | |
| { | |
| "id": "hard_003", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "tags(id, product_id, tag)" | |
| ] | |
| }, | |
| "intent": "Find users who ordered a product tagged as 'ergonomic', return unique user names", | |
| "broken_query": "SELECT u.name FROM users u JOIN orders o ON u.id = o.user_id JOIN tags t ON o.id = t.product_id WHERE t.tag = 'ergonomic'", | |
| "correct_query": "SELECT DISTINCT u.name FROM users u JOIN orders o ON u.id = o.user_id JOIN tags t ON o.product_id = t.product_id WHERE t.tag = 'ergonomic'", | |
| "error_type": "join", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "tags join key": "tags.product_id links to orders.product_id, not orders.id", | |
| "tag values": "office, writing, computer, accessories, ergonomic, lighting, mechanical", | |
| "orders to tags": "join on orders.product_id = tags.product_id" | |
| } | |
| }, | |
| { | |
| "id": "hard_004", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "Using a CTE, rank users by total amount spent, show top 3 with their rank", | |
| "broken_query": "WITH ranked AS (SELECT user_id, SUM(amount) spent FROM orders GROUP BY user_id) SELECT u.name, spent FROM ranked JOIN users u ON ranked.id = u.id ORDER BY spent DESC LIMIT 3", | |
| "correct_query": "WITH ranked AS (SELECT user_id, SUM(amount) AS spent FROM orders GROUP BY user_id) SELECT u.name, r.spent FROM ranked r JOIN users u ON r.user_id = u.id ORDER BY r.spent DESC LIMIT 3", | |
| "error_type": "subquery", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "CTE alias": "the CTE is aliased as ranked, access with r.user_id not ranked.id", | |
| "join column in CTE": "CTE exposes user_id column, not id" | |
| } | |
| }, | |
| { | |
| "id": "hard_005", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "Find the category with the highest average review rating", | |
| "broken_query": "SELECT category, AVG(rating) FROM products JOIN reviews ON products.id = reviews.id GROUP BY category ORDER BY AVG(rating) DESC LIMIT 1", | |
| "correct_query": "SELECT p.category, AVG(r.rating) AS avg_rating FROM products p JOIN reviews r ON p.id = r.product_id GROUP BY p.category ORDER BY avg_rating DESC LIMIT 1", | |
| "error_type": "join", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "join key for products and reviews": "reviews.product_id = products.id, not reviews.id" | |
| } | |
| }, | |
| { | |
| "id": "hard_006", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "Find products that have been ordered but have received no reviews", | |
| "broken_query": "SELECT DISTINCT p.name FROM products p JOIN orders o ON p.id = o.product_id WHERE p.id NOT IN (SELECT product_id FROM reviews WHERE product_id IS NOT NULL)", | |
| "correct_query": "SELECT DISTINCT p.name FROM products p JOIN orders o ON p.id = o.product_id WHERE p.id NOT IN (SELECT product_id FROM reviews)", | |
| "error_type": "logic", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "null in subquery NOT IN": "NOT IN with NULLs returns no rows; remove the IS NOT NULL filter or use NOT EXISTS", | |
| "reviews product_id nullable": "product_id in reviews is NOT NULL by design in this schema" | |
| } | |
| }, | |
| { | |
| "id": "hard_007", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "tags(id, product_id, tag)" | |
| ] | |
| }, | |
| "intent": "Get products that have BOTH the 'office' tag and the 'computer' tag", | |
| "broken_query": "SELECT p.name FROM products p JOIN tags t ON p.id = t.product_id WHERE t.tag = 'office' AND t.tag = 'computer'", | |
| "correct_query": "SELECT p.name FROM products p JOIN tags t1 ON p.id = t1.product_id AND t1.tag = 'office' JOIN tags t2 ON p.id = t2.product_id AND t2.tag = 'computer'", | |
| "error_type": "logic", | |
| "min_turns_expected": 4, | |
| "clarification_answers": { | |
| "why single join fails": "a single row cannot have two different tag values; join tags twice", | |
| "tags structure": "one row per tag per product" | |
| } | |
| }, | |
| { | |
| "id": "hard_008", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "For each city, find the most popular product category (by number of orders from users in that city)", | |
| "broken_query": "SELECT u.city, p.category, COUNT(*) FROM users u JOIN orders o ON u.id = o.user_id JOIN products p ON o.product_id = p.id GROUP BY u.city ORDER BY COUNT(*) DESC", | |
| "correct_query": "WITH city_cat AS (SELECT u.city, p.category, COUNT(*) AS cnt FROM users u JOIN orders o ON u.id = o.user_id JOIN products p ON o.product_id = p.id GROUP BY u.city, p.category) SELECT city, category, cnt FROM city_cat cc WHERE cnt = (SELECT MAX(cnt) FROM city_cat WHERE city = cc.city)", | |
| "error_type": "subquery", | |
| "min_turns_expected": 5, | |
| "clarification_answers": { | |
| "most popular means": "category with the highest order count for that city", | |
| "how to get top per group": "use a CTE with a correlated subquery to filter max per city", | |
| "products join key": "orders.product_id = products.id" | |
| } | |
| }, | |
| { | |
| "id": "hard_009", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)" | |
| ] | |
| }, | |
| "intent": "Find users who have spent more than the average total spending across all users", | |
| "broken_query": "SELECT u.name, SUM(o.amount) FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.id HAVING SUM(o.amount) > AVG(SUM(o.amount))", | |
| "correct_query": "WITH totals AS (SELECT user_id, SUM(amount) AS total FROM orders GROUP BY user_id) SELECT u.name, t.total FROM users u JOIN totals t ON u.id = t.user_id WHERE t.total > (SELECT AVG(total) FROM totals)", | |
| "error_type": "subquery", | |
| "min_turns_expected": 5, | |
| "clarification_answers": { | |
| "nested aggregate": "SQLite does not allow AVG(SUM()); use a CTE or subquery", | |
| "approach": "first compute per-user totals in a CTE, then compare against AVG of those totals" | |
| } | |
| }, | |
| { | |
| "id": "hard_010", | |
| "difficulty": "hard", | |
| "schema": { | |
| "tables": [ | |
| "users(id, name, email, age, city, active)", | |
| "orders(id, user_id, product_id, amount, status, created_at)", | |
| "products(id, name, category, price, stock)", | |
| "reviews(id, user_id, product_id, rating, body, created_at)", | |
| "tags(id, product_id, tag)" | |
| ] | |
| }, | |
| "intent": "Find active users from cities where the total order amount exceeds 300, who have also written at least one review", | |
| "broken_query": "SELECT u.name FROM users u JOIN orders o ON u.id = o.user_id JOIN reviews r ON u.id = r.user_id WHERE u.active = 1 AND SUM(o.amount) > 300 GROUP BY u.city", | |
| "correct_query": "SELECT DISTINCT u.name FROM users u JOIN orders o ON u.id = o.user_id JOIN reviews r ON u.id = r.user_id WHERE u.active = 1 AND u.city IN (SELECT u2.city FROM users u2 JOIN orders o2 ON u2.id = o2.user_id GROUP BY u2.city HAVING SUM(o2.amount) > 300)", | |
| "error_type": "subquery", | |
| "min_turns_expected": 5, | |
| "clarification_answers": { | |
| "city total vs user total": "SUM > 300 is per city, not per user", | |
| "active filter": "active = 1 in users table", | |
| "review requirement": "user must exist in reviews table at least once" | |
| } | |
| } | |
| ] | |