lauraa169 commited on
Commit
b19dd0d
·
verified ·
1 Parent(s): 61b7811

Upload dataset_base.jsonl with huggingface_hub

Browse files
Files changed (1) hide show
  1. dataset_base.jsonl +85 -21
dataset_base.jsonl CHANGED
@@ -1,6 +1,6 @@
1
  {"id":"base_java_01","dataset_type":"base","language":"Java","task_category":"scaffolding",
2
- "prompt_en":"write a method createScaffold in java that creates a basic project structure for maven. Don't include imports",
3
- "prompt_nl":"schrijf een method createScaffold in java die een basisprojectstructuur voor maven creëert. Voeg geen imports toe.",
4
  "code_snippet_input":"",
5
  "canonical_solution":"public static void createScaffold() throws IOException {\n Files.createDirectories(Paths.get(\"src/main/java/\"));\n Files.createDirectories(Paths.get(\"src/test/java/\"));\n}",
6
  "unit_test_setup":"import org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.AfterEach;\nimport java.io.File;\nimport java.io.IOException;\nimport java.nio.file.*;\nimport java.util.Comparator;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class ScaffoldTest {\n\n\n @AfterEach\n void tearDown() throws IOException {\n Path root = Paths.get(\"src\");\n if (Files.exists(root)) {\n Files.walk(root)\n .sorted(Comparator.reverseOrder())\n .map(Path::toFile)\n .forEach(File::delete);\n }\n }\n",
@@ -86,25 +86,25 @@
86
  "canonical_solution":"public static boolean isOverdue(LocalDate deadlineDate) {\n LocalDateTime currentDateTime = LocalDateTime.now();\n LocalDateTime deadlineTimestamp = deadlineDate.atStartOfDay();\n return currentDateTime.isAfter(deadlineTimestamp);\n}",
87
  "unit_test_setup":"import java.time.LocalDate;\nimport java.time.LocalDateTime;\nimport org.junit.jupiter.api.Test;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class DateTest {\n\n",
88
  "unit_test_assertion":"@Test\n public void testYesterdayIsOverdue() {\nassertTrue(isOverdue(LocalDate.now().minusDays(1)), \"Yesterday should be overdue\");\n }\n\n @Test\n public void testTomorrowIsNotOverdue() {\n assertFalse(isOverdue(LocalDate.now().plusDays(1)), \"Tomorrow should not be overdue\");\n }\n\n @Test\n public void testTodayIsOverdue() {\nassertTrue(isOverdue(LocalDate.now()), \"Today (current time) should be considered after Today (start of day)\");\n }\n}",
89
- "comment":"the original method ignores time of day so assignments due on the same day are not overdue, the solution MUST set the deadline to the start of the day and compare with current date and time, so that assignemnts due on the same day are overdue."
90
  }
91
  {"id":"base_java_11","dataset_type":"base","language":"Java","task_category":"refactoring",
92
  "prompt_en":"this method groups transaction over 1000 by currency. refactor it to use streams and dont include imports",
93
  "prompt_nl":"deze methode groepeert transacties van meer dan 1000 per valuta. Refactor deze om streams te gebruiken en neem geen imports op.",
94
  "code_snippet_input":"public Map<String, List<Transaction>> groupHighValueTransactions(List<Transaction> transactions) {\nMap<String, List<Transaction>> result = new HashMap<>();\nfor (Transaction t : transactions) {\nif (t.getAmount() > 1000) {\nString currency = t.getCurrency();\nif (!result.containsKey(currency)) {\nresult.put(currency, new ArrayList<>());\n}\nresult.get(currency).add(t);\n}\n}\nreturn result;\n}",
95
  "canonical_solution":"public Map<String, List<Transaction>> groupHighValueTransactions(List<Transaction> transactions) {\nreturn transactions.stream()\n.filter(t -> t.getAmount() > 1000)\n.collect(Collectors.groupingBy(Transaction::getCurrency));\n}",
96
- "unit_test_setup":"import org.junit.jupiter.api.Test;\nimport java.util.*;\nimport java.util.stream.Collectors;\nimport static org.junit.jupiter.api.Assertions.*;\n\n\nclass Transaction {\n private String currency;\n private double amount;\n public Transaction(String currency, double amount) { \n this.currency = currency; \n this.amount = amount; \n }\n public String getCurrency() { return currency; }\n public double getAmount() { return amount; }\n}\n\npublic class Solution {\n\n",
97
- "unit_test_assertion":" @Test\n public void testGrouping() {\n List<Transaction> data = Arrays.asList(\n new Transaction(\"USD\", 500),\n new Transaction(\"USD\", 1500), // Keep\n new Transaction(\"EUR\", 2000),\n new Transaction(\"USD\", 3000) // Keep\n );\n \n Map<String, List<Transaction>> result = groupHighValueTransactions(data);\n \n assertEquals(2, result.size(), \"Should have keys for USD and EUR\");\n assertEquals(2, result.get(\"USD\").size(), \"USD should have 2 transactions\");\n assertEquals(1, result.get(\"EUR\").size(), \"EUR should have 1 transaction\");\n }\n}",
98
- "comment":"the old method uses for loops conditionals and maps to group transactions, the solution MUST use java streams to filter and group the transactions effectively in a more concise way."
99
  }
100
  {"id":"base_java_12","dataset_type":"base","language":"Java","task_category":"refactoring",
101
  "prompt_en":"This is a method that returns a discount code based on the day of the week, refactor the method to use a modern switch expression. Keep the same functionality and don't include imports",
102
  "prompt_nl":"Dit is een methode die een kortingscode retourneert op basis van de dag van de week. Herstructureer de methode om een moderne switch-expressie te gebruiken. Behoud dezelfde functionaliteit en neem geen imports op.",
103
  "code_snippet_input":"public String getDiscountCode(String dayOfWeek) {\nString discount;\nswitch (dayOfWeek) {\ncase \"Monday\":\ndiscount = \"MANIC_MONDAY_15\";\nbreak;\ncase \"Wednesday\":\ndiscount = \"WACKY_WED_10\";\nbreak;\ncase \"Friday\":\ndiscount = \"TGIF_25\";\nbreak;\ncase \"Saturday\":\ncase \"Sunday\":\ndiscount = \"WEEKEND_SAVER_20\";\nbreak;\ndefault:\ndiscount = \"STANDARD_PRICING\";\nbreak;\n}\nreturn discount;\n}",
104
  "canonical_solution":"public String getDiscountCode(String dayOfWeek) {\nreturn switch (dayOfWeek) {\ncase \"Monday\" -> \"MANIC_MONDAY_15\";\ncase \"Wednesday\" -> \"WACKY_WED_10\";\ncase \"Friday\" -> \"TGIF_25\";\ncase \"Saturday\", \"Sunday\" -> \"WEEKEND_SAVER_20\";\ndefault -> \"STANDARD_PRICING\";\n};\n}",
105
- "unit_test_setup":"import org.junit.jupiter.api.Test;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class Solution {\n \n",
106
- "unit_test_assertion":" @Test\n public void testDiscounts() {\n assertEquals(\"MANIC_MONDAY_15\", getDiscountCode(\"Monday\"));\n assertEquals(\"TGIF_25\", getDiscountCode(\"Friday\"));\n assertEquals(\"WEEKEND_SAVER_20\", getDiscountCode(\"Saturday\"), \"Should match first weekend day\");\n assertEquals(\"WEEKEND_SAVER_20\", getDiscountCode(\"Sunday\"), \"Should match second weekend day\");\n assertEquals(\"STANDARD_PRICING\", getDiscountCode(\"Tuesday\"), \"Default case check\");\n }\n}",
107
- "comment":"the old method uses the old switch statement with multiple breaks and variable assignments, the solution MUST use the modern switch expression syntax introduced in Java 14 while keeping the same functionality."
108
  }
109
 
110
  {"id":"base_javascript_01","dataset_type":"base","language":"JavaScript","task_category":"scaffolding","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
@@ -211,17 +211,81 @@
211
  {"id":"base_sql_07","dataset_type":"base","language":"SQL","dialect":"mssql","task_category":"id_bug",
212
  "prompt_en":"I want to collect all of the 2023 transactions for the annual report but this query returns 4 additional transactions from 2024. Fix the query.",
213
  "prompt_nl":"Ik wil alle transacties van 2023 verzamelen voor het jaarverslag, maar deze query geeft 4 extra transacties uit 2024 weer. Corrigeer de query.",
214
- "code_snippet_input":"DECLARE @Start DATETIME = '2023-12-31 00:00:00.000';\nDECLARE @End DATETIME = '2023-12-31 23:59:59.999';\nSELECT *\nFROM transactions\nWHERE transaction_date BETWEEN @Start AND @End;",
215
- "canonical_solution":"SELECT *\nFROM transactions\nWHERE transaction_date >= '2023-12-31 00:00:00'\nAND transaction_date < '2024-01-01 00:00:00';",
216
  "unit_test_setup": "CREATE TABLE transactions (id INT, transaction_date DATETIME);\n\nINSERT INTO transactions VALUES (1, '2023-06-15 12:00:00');\n\n\nINSERT INTO transactions VALUES (2, '2023-12-31 23:59:59.990');\n\nINSERT INTO transactions VALUES (3, '2024-01-01 00:00:00.000');",
217
  "unit_test_assertion": " @Test\n public void testDateRounding(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n int count = 0;\n while(rs.next()) {\n count++;\n Timestamp ts = rs.getTimestamp(\"transaction_date\");\n // Assert we did NOT pick up the 2024 date\n assertFalse(ts.toLocalDateTime().getYear() == 2024, \"Query incorrectly included a 2024 transaction due to rounding.\");\n }\n assertEquals(2, count, \"Should return exactly 2 rows from 2023.\");\n }\n }",
218
- "comment": "The solution MUST use a half-open interval (< '2024-01-01') to safely capture all 2023 data without hitting MSSQL's 3ms rounding issue on .999 milliseconds."
219
- }
220
- {"id":"base_sql_08","dataset_type":"base","language":"SQL","task_category":"fix_bug","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
221
- {"id":"base_sql_09","dataset_type":"base","language":"SQL","task_category":"fix_bug","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
222
- {"id":"base_sql_10","dataset_type":"base","language":"SQL","task_category":"fix_bug","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
223
- {"id":"base_sql_11","dataset_type":"base","language":"SQL","task_category":"fix_bug","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
224
- {"id":"base_sql_12","dataset_type":"base","language":"SQL","task_category":"refactoring","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
225
- {"id":"base_sql_13","dataset_type":"base","language":"SQL","task_category":"refactoring","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
226
- {"id":"base_sql_14","dataset_type":"base","language":"SQL","task_category":"refactoring","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
227
- {"id":"base_sql_15","dataset_type":"base","language":"SQL","task_category":"refactoring","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  {"id":"base_java_01","dataset_type":"base","language":"Java","task_category":"scaffolding",
2
+ "prompt_en":"write a method createScaffold in java that creates a basic project structure for maven. Return ONLY the method",
3
+ "prompt_nl":"schrijf een method createScaffold in java die een basisprojectstructuur voor maven creëert. ALLEEN de methode retourneren.",
4
  "code_snippet_input":"",
5
  "canonical_solution":"public static void createScaffold() throws IOException {\n Files.createDirectories(Paths.get(\"src/main/java/\"));\n Files.createDirectories(Paths.get(\"src/test/java/\"));\n}",
6
  "unit_test_setup":"import org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.AfterEach;\nimport java.io.File;\nimport java.io.IOException;\nimport java.nio.file.*;\nimport java.util.Comparator;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class ScaffoldTest {\n\n\n @AfterEach\n void tearDown() throws IOException {\n Path root = Paths.get(\"src\");\n if (Files.exists(root)) {\n Files.walk(root)\n .sorted(Comparator.reverseOrder())\n .map(Path::toFile)\n .forEach(File::delete);\n }\n }\n",
 
86
  "canonical_solution":"public static boolean isOverdue(LocalDate deadlineDate) {\n LocalDateTime currentDateTime = LocalDateTime.now();\n LocalDateTime deadlineTimestamp = deadlineDate.atStartOfDay();\n return currentDateTime.isAfter(deadlineTimestamp);\n}",
87
  "unit_test_setup":"import java.time.LocalDate;\nimport java.time.LocalDateTime;\nimport org.junit.jupiter.api.Test;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class DateTest {\n\n",
88
  "unit_test_assertion":"@Test\n public void testYesterdayIsOverdue() {\nassertTrue(isOverdue(LocalDate.now().minusDays(1)), \"Yesterday should be overdue\");\n }\n\n @Test\n public void testTomorrowIsNotOverdue() {\n assertFalse(isOverdue(LocalDate.now().plusDays(1)), \"Tomorrow should not be overdue\");\n }\n\n @Test\n public void testTodayIsOverdue() {\nassertTrue(isOverdue(LocalDate.now()), \"Today (current time) should be considered after Today (start of day)\");\n }\n}",
89
+ "comment":"the original method ignores time of day so assignments due on the same day are not overdue, the solution MUST set the deadline to the start of the day and compare with current date and time, so that assignemnts due on the same day are overdue. The unit test includes structural checks (as well as functional checks) to ensure refactoring."
90
  }
91
  {"id":"base_java_11","dataset_type":"base","language":"Java","task_category":"refactoring",
92
  "prompt_en":"this method groups transaction over 1000 by currency. refactor it to use streams and dont include imports",
93
  "prompt_nl":"deze methode groepeert transacties van meer dan 1000 per valuta. Refactor deze om streams te gebruiken en neem geen imports op.",
94
  "code_snippet_input":"public Map<String, List<Transaction>> groupHighValueTransactions(List<Transaction> transactions) {\nMap<String, List<Transaction>> result = new HashMap<>();\nfor (Transaction t : transactions) {\nif (t.getAmount() > 1000) {\nString currency = t.getCurrency();\nif (!result.containsKey(currency)) {\nresult.put(currency, new ArrayList<>());\n}\nresult.get(currency).add(t);\n}\n}\nreturn result;\n}",
95
  "canonical_solution":"public Map<String, List<Transaction>> groupHighValueTransactions(List<Transaction> transactions) {\nreturn transactions.stream()\n.filter(t -> t.getAmount() > 1000)\n.collect(Collectors.groupingBy(Transaction::getCurrency));\n}",
96
+ "unit_test_setup":"import org.junit.jupiter.api.Test;\nimport java.util.*;\nimport java.util.stream.Collectors;\nimport java.nio.file.*;\nimport java.io.IOException;\nimport static org.junit.jupiter.api.Assertions.*;\n\nclass Transaction {\n private String currency;\n private double amount;\n public Transaction(String currency, double amount) { \n this.currency = currency; \n this.amount = amount; \n }\n public String getCurrency() { return currency; }\n public double getAmount() { return amount; }\n}\n\npublic class Solution {\n",
97
+ "unit_test_assertion": " @Test\n public void testGrouping() {\n List<Transaction> data = Arrays.asList(\n new Transaction(\"USD\", 500),\n new Transaction(\"USD\", 1500),\n new Transaction(\"EUR\", 2000),\n new Transaction(\"USD\", 3000)\n );\n \n Map<String, List<Transaction>> result = groupHighValueTransactions(data);\n \n assertEquals(2, result.size());\n assertEquals(2, result.get(\"USD\").size());\n }\n\n @Test\n public void testRefactoringCompliance() throws IOException {\n \n String source = Files.readString(Path.of(\"Solution.java\"));\n \n assertTrue(source.contains(\".stream(\"), \"LLM failed to use Stream API\");\n assertTrue(source.contains(\".collect(\"), \"LLM failed to use Collector\");\n assertFalse(source.contains(\"for (\"), \"LLM failed to remove 'for' loop\");\n }\n}",
98
+ "comment": "RUNNER MUST SAVE SOLUTION IN Solution.java Includes a structural check to ensure the LLM actually followed the instruction to use Streams. The unit test includes structural checks (as well as functional checks) to ensure refactoring."
99
  }
100
  {"id":"base_java_12","dataset_type":"base","language":"Java","task_category":"refactoring",
101
  "prompt_en":"This is a method that returns a discount code based on the day of the week, refactor the method to use a modern switch expression. Keep the same functionality and don't include imports",
102
  "prompt_nl":"Dit is een methode die een kortingscode retourneert op basis van de dag van de week. Herstructureer de methode om een moderne switch-expressie te gebruiken. Behoud dezelfde functionaliteit en neem geen imports op.",
103
  "code_snippet_input":"public String getDiscountCode(String dayOfWeek) {\nString discount;\nswitch (dayOfWeek) {\ncase \"Monday\":\ndiscount = \"MANIC_MONDAY_15\";\nbreak;\ncase \"Wednesday\":\ndiscount = \"WACKY_WED_10\";\nbreak;\ncase \"Friday\":\ndiscount = \"TGIF_25\";\nbreak;\ncase \"Saturday\":\ncase \"Sunday\":\ndiscount = \"WEEKEND_SAVER_20\";\nbreak;\ndefault:\ndiscount = \"STANDARD_PRICING\";\nbreak;\n}\nreturn discount;\n}",
104
  "canonical_solution":"public String getDiscountCode(String dayOfWeek) {\nreturn switch (dayOfWeek) {\ncase \"Monday\" -> \"MANIC_MONDAY_15\";\ncase \"Wednesday\" -> \"WACKY_WED_10\";\ncase \"Friday\" -> \"TGIF_25\";\ncase \"Saturday\", \"Sunday\" -> \"WEEKEND_SAVER_20\";\ndefault -> \"STANDARD_PRICING\";\n};\n}",
105
+ "unit_test_setup": "import org.junit.jupiter.api.Test;\nimport java.nio.file.*;\nimport java.io.IOException;\nimport static org.junit.jupiter.api.Assertions.*;\n\npublic class Solution {\n",
106
+ "unit_test_assertion": " @Test\n public void testDiscounts() {\n assertEquals(\"MANIC_MONDAY_15\", getDiscountCode(\"Monday\"));\n assertEquals(\"WEEKEND_SAVER_20\", getDiscountCode(\"Sunday\"));\n assertEquals(\"STANDARD_PRICING\", getDiscountCode(\"Tuesday\"));\n }\n\n @Test\n public void testModernSyntax() throws IOException {\n String source = Files.readString(Path.of(\"Solution.java\"));\n \n assertTrue(source.contains(\"->\"), \"LLM failed to use modern arrow syntax '->'\");\n assertFalse(source.contains(\"break;\"), \"LLM failed to remove legacy 'break' statements\");\n }\n}",
107
+ "comment":"RUNNER MUST SAVE SOLUTION IN Solution.java the old method uses the old switch statement with multiple breaks and variable assignments, the solution MUST use the modern switch expression syntax introduced in Java 14 while keeping the same functionality. The unit test includes structural checks (as well as functional checks) to ensure refactoring."
108
  }
109
 
110
  {"id":"base_javascript_01","dataset_type":"base","language":"JavaScript","task_category":"scaffolding","prompt_en":"","prompt_nl":"","code_snippet_input":"","canonical_solution":"","unit_test_setup":"","unit_test_assertion":""}
 
211
  {"id":"base_sql_07","dataset_type":"base","language":"SQL","dialect":"mssql","task_category":"id_bug",
212
  "prompt_en":"I want to collect all of the 2023 transactions for the annual report but this query returns 4 additional transactions from 2024. Fix the query.",
213
  "prompt_nl":"Ik wil alle transacties van 2023 verzamelen voor het jaarverslag, maar deze query geeft 4 extra transacties uit 2024 weer. Corrigeer de query.",
214
+ "code_snippet_input":"DECLARE @Start DATETIME = '2023-1-1 00:00:00.000';\nDECLARE @End DATETIME = '2023-12-31 23:59:59.999';\nSELECT *\nFROM transactions\nWHERE transaction_date BETWEEN @Start AND @End;",
215
+ "canonical_solution":"SELECT *\nFROM transactions\nWHERE transaction_date >= '2023-1-1 00:00:00'\nAND transaction_date < '2024-1-1 00:00:00';",
216
  "unit_test_setup": "CREATE TABLE transactions (id INT, transaction_date DATETIME);\n\nINSERT INTO transactions VALUES (1, '2023-06-15 12:00:00');\n\n\nINSERT INTO transactions VALUES (2, '2023-12-31 23:59:59.990');\n\nINSERT INTO transactions VALUES (3, '2024-01-01 00:00:00.000');",
217
  "unit_test_assertion": " @Test\n public void testDateRounding(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n int count = 0;\n while(rs.next()) {\n count++;\n Timestamp ts = rs.getTimestamp(\"transaction_date\");\n // Assert we did NOT pick up the 2024 date\n assertFalse(ts.toLocalDateTime().getYear() == 2024, \"Query incorrectly included a 2024 transaction due to rounding.\");\n }\n assertEquals(2, count, \"Should return exactly 2 rows from 2023.\");\n }\n }",
218
+ "comment": "The solution MUST use a half-open interval (< '2024-1-1') to safely capture all 2023 data without hitting MSSQL's 3ms rounding issue on .999 milliseconds."
219
+ }
220
+ {"id":"base_sql_08","dataset_type":"base","language":"SQL","dialect":"mssql","task_category":"fix_bug",
221
+ "prompt_en":"I want a query to get the logging time and ip address of the last time each user logged in to my website, but i get an error. Fix this query.",
222
+ "prompt_nl":"Ik wil een query om de inlogtijd en het IP adres te achterhalen van de laatste keer dat elke gebruiker zich op mijn website heeft aangemeld, maar ik krijg een foutmelding. Los deze query op.",
223
+ "code_snippet_input":"--Column 'user_logins.ip_address' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.\nSELECT \nuser_id, \nMAX(login_time) as last_seen,\nip_address\nFROM user_logins\nGROUP BY user_id;",
224
+ "canonical_solution":"SELECT \noriginal.user_id, \noriginal.login_time as last_seen,\noriginal.ip_address\nFROM user_logins original\nINNER JOIN (\nSELECT user_id, MAX(login_time) as max_time\nFROM user_logins\nGROUP BY user_id\n) filtered\nON original.user_id = filtered.user_id \nAND original.login_time = filtered.max_time;",
225
+ "unit_test_setup": "CREATE TABLE user_logins (\n user_id INT,\n login_time DATETIME,\n ip_address VARCHAR(50)\n);\n\nINSERT INTO user_logins VALUES (1, '2023-01-01 10:00:00', '1.1.1.1');\nINSERT INTO user_logins VALUES (1, '2023-01-02 10:00:00', '2.2.2.2');\n\nINSERT INTO user_logins VALUES (2, '2023-01-05 10:00:00', '3.3.3.3');",
226
+ "unit_test_assertion": " @Test\n public void testGroupByLogic(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n boolean foundUser1 = false;\n while(rs.next()) {\n if(rs.getInt(\"user_id\") == 1) {\n foundUser1 = true;\n assertEquals(\"2.2.2.2\", rs.getString(\"ip_address\"), \"Should return the IP of the LATEST login, not a random one.\");\n }\n }\n assertTrue(foundUser1, \"User 1 should be in the results.\");\n }\n }",
227
+ "comment": "The solution MUST resolve the aggregation error and return latest login ip for each user, either by joining the table to a subquery on itself (Self-Join), or using Window Functions (ROW_NUMBER)."
228
+ }
229
+ {"id":"base_sql_09","dataset_type":"base","language":"SQL","dialect":"mysql","task_category":"fix_bug",
230
+ "prompt_en":"I want this query to return all of the patients that have visited the radiology department more than 10 times, but I get an error. Fix the query.",
231
+ "prompt_nl":"Ik wil dat deze query alle patiënten weergeeft die meer dan 10 keer de afdeling radiologie hebben bezocht, maar ik krijg een foutmelding. Corrigeer de query.",
232
+ "code_snippet_input":"--ERROR 1111 (HY000): Invalid use of group function\nSELECT \np.patient_name, \nCOUNT(r.log_id) as visit_count\nFROM patients p\nJOIN radiology_log r \nON p.patient_id = r.patient_id\nWHERE COUNT(r.log_id) > 10\nGROUP BY p.patient_name;",
233
+ "canonical_solution":"SELECT \np.patient_name, \nCOUNT(r.log_id) as visit_count\nFROM patients p\nJOIN radiology_log r \nON p.patient_id = r.patient_id\nGROUP BY p.patient_name\nHAVING COUNT(r.log_id) > 10; -- <--- Correct",
234
+ "unit_test_setup": "CREATE TABLE patients (patient_id INT, patient_name VARCHAR(50));\nCREATE TABLE radiology_log (log_id INT AUTO_INCREMENT, patient_id INT, PRIMARY KEY(log_id));\n\nINSERT INTO patients VALUES (1, 'Alice');\nINSERT INTO radiology_log (patient_id) VALUES (1), (1), (1), (1), (1), (1), (1), (1), (1), (1), (1);\n\nINSERT INTO patients VALUES (2, 'Bob');\nINSERT INTO radiology_log (patient_id) VALUES (2);",
235
+ "unit_test_assertion": " @Test\n public void testHavingClause(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n assertTrue(rs.next(), \"Should return at least one patient with > 10 visits\");\n assertEquals(\"Alice\", rs.getString(\"patient_name\"));\n assertEquals(11, rs.getInt(\"visit_count\"));\n assertFalse(rs.next(), \"Should filter out patients with <= 10 visits\");\n }\n }",
236
+ "comment": "The solution MUST replace the WHERE clause with HAVING for filtering aggregate fields."
237
+ }
238
+ {"id":"base_sql_10","dataset_type":"base","language":"SQL","dialect":"mysql","task_category":"fix_bug",
239
+ "prompt_en":"I want a query that returns all of the patients in the system and the date they were admitted to the hospital, but I get an error. Fix the query.",
240
+ "prompt_nl":"Ik wil een query die alle patiënten in het systeem en de datum waarop ze in het ziekenhuis zijn opgenomen weergeeft, maar ik krijg een foutmelding. Los de query op.",
241
+ "code_snippet_input":"--Error Code: 1052. Column 'patient_id' in field list is ambiguous\nSELECT \npatient_id,\nname,\nadmission_date\nFROM patients p\nJOIN admissions a \nON p.patient_id = a.patient_id;",
242
+ "canonical_solution":"SELECT \np.patient_id,\nname,\nadmission_date\nFROM patients p\nJOIN admissions a \nON p.patient_id = a.patient_id;",
243
+ "unit_test_setup": "CREATE TABLE patients (patient_id INT, name VARCHAR(50));\nCREATE TABLE admissions (admission_id INT, patient_id INT, admission_date DATE);\n\nINSERT INTO patients VALUES (1, 'John Doe');\nINSERT INTO admissions VALUES (100, 1, '2023-01-01');",
244
+ "unit_test_assertion": " @Test\n public void testAmbiguousColumn(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n assertTrue(rs.next(), \"Query should return results once the ambiguity is fixed.\");\n assertEquals(1, rs.getInt(\"patient_id\"));\n assertEquals(\"John Doe\", rs.getString(\"name\"));\n assertNotNull(rs.getDate(\"admission_date\"));\n }\n }",
245
+ "comment": "The solution MUST solve the ambiguity in 'patient_id' column with a table alias, either p.patient_id or a.patient_id (doesn't matter because they're identical, hence the JOIN)."
246
+ }
247
+ {"id":"base_sql_11","dataset_type":"base","language":"SQL","dialect":"mssql","task_category":"fix_bug",
248
+ "prompt_en":"I want to retrieve all patients who have lab results greater than 100, but I get a conversion error because some results are not numeric even though I'm filtering them out. FIx the error.",
249
+ "prompt_nl":"Ik wil alle patiënten ophalen met laboratoriumresultaten hoger dan 100, maar ik krijg een conversiefout omdat sommige resultaten niet numeriek zijn, ook al filter ik ze eruit. Los de fout op.",
250
+ "code_snippet_input":"--Conversion failed when converting the varchar value 'Pending' to data type int\nSELECT \npatient_id, \nresult_value\nFROM lab_results\nWHERE result_value NOT LIKE '%[^0-9]%'\nAND CAST(result_value AS INT) > 100;",
251
+ "canonical_solution":"SELECT \npatient_id, \nresult_value\nFROM lab_results\nWHERE TRY_CAST(result_value AS INT) > 100;",
252
+ "unit_test_setup":"CREATE TABLE lab_results (patient_id INT, result_value VARCHAR(50));\n\nINSERT INTO lab_results VALUES (1, '150');\n\nINSERT INTO lab_results VALUES (2, '50');\n\nINSERT INTO lab_results VALUES (3, 'Pending');",
253
+ "unit_test_assertion": " @Test\n public void testSafeCast(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n assertTrue(rs.next(), \"Should return the valid numeric row > 100\");\n assertEquals(\"150\", rs.getString(\"result_value\"));\n \n assertFalse(rs.next(), \"Should filter out low numbers and non-numeric strings without crashing.\");\n }\n }",
254
+ "comment":"The solution MUST use TRY_CAST (or similar) to attemp conversion safely, otherwise the conversion will raise an error because SQL is not procedural so order of operations can't be controlled"
255
+ }
256
+ {"id":"base_sql_12","dataset_type":"base","language":"SQL","task_category":"refactoring",
257
+ "prompt_en":"This query retrieves the names, the total spend and the date of the most recent order of out top buyers (spent more than 1000$ total). Refactor this query to make it more efficient and readable without changing functionality.",
258
+ "prompt_nl":"Deze query haalt de namen, het totale bedrag en de datum van de meest recente bestelling van onze topkopers (die in totaal meer dan 1000$ hebben uitgegeven) op. Herstructureer deze query om hem efficiënter en leesbaarder te maken zonder de functionaliteit te wijzigen.",
259
+ "code_snippet_input":"SELECT \nc.customer_name,\n(SELECT SUM(amount) FROM orders o WHERE o.customer_id = c.id) as total_spend,\n(SELECT MAX(order_date) FROM orders o WHERE o.customer_id = c.id) as last_order_date\nFROM customers c\nWHERE (SELECT SUM(amount) FROM orders o WHERE o.customer_id = c.id) > 1000;",
260
+ "canonical_solution":"WITH CustomerStats AS (\nSELECT \ncustomer_id,\nSUM(amount) as total_spend,\nMAX(order_date) as last_order_date\nFROM orders\nGROUP BY customer_id\n),\nHighValueCustomers AS (\nSELECT \ncustomer_id,\ntotal_spend,\nlast_order_date\nFROM CustomerStats\nWHERE total_spend > 1000\n)\nSELECT \nc.customer_name,\nhvc.total_spend,\nhvc.last_order_date\nFROM customers c\nINNER JOIN HighValueCustomers hvc \nON c.id = hvc.customer_id;",
261
+ "unit_test_setup":"CREATE TABLE customers (id INT PRIMARY KEY, customer_name VARCHAR(50));\nCREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, amount INT, order_date DATE);\n\nINSERT INTO customers VALUES (1, 'Alice');\nINSERT INTO orders VALUES (101, 1, 600, '2023-01-01');\nINSERT INTO orders VALUES (102, 1, 500, '2023-01-05');\n\nINSERT INTO customers VALUES (2, 'Bob');\nINSERT INTO orders VALUES (201, 2, 900, '2023-02-01');\n\n-- 3. Edge Case (Charlie): 1000 total (Should be filtered out)\nINSERT INTO customers VALUES (3, 'Charlie');\nINSERT INTO orders VALUES (301, 3, 1000, '2023-03-01');",
262
+ "unit_test_assertion":" @Test\n public void testRefactoring(Connection conn) throws SQLException {\n String sql = generatedSqlQuery.toUpperCase().replaceAll(\"\\\\s+\", \" \");\n \n boolean usesCTE = sql.contains(\"WITH \");\n boolean usesJoin = sql.contains(\"JOIN \");\n \n assertTrue(usesCTE || usesJoin, \"Refactoring failed: You must optimize the query using a CTE (WITH) or JOINs instead of correlated subqueries.\");\n\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n assertTrue(rs.next(), \"Should return high value customers.\");\n assertEquals(\"Alice\", rs.getString(\"customer_name\"));\n assertEquals(1100, rs.getInt(\"total_spend\"));\n assertEquals(Date.valueOf(\"2023-01-05\"), rs.getDate(\"last_order_date\"));\n \n assertFalse(rs.next(), \"Should strictly filter > 1000 (Bob and Charlie should not appear).\");\n }\n }",
263
+ "comment":"the solution MUST separate the big query with redundant subqueries into multiple queries with sepration of concerns (i.e. one for the math, one for the filtering, and one for the display), this makes the code mre efficient (less redundancy), more readable, and more maintainable (easier to debug). The unit test includes structural checks (as well as functional checks) to ensure refactoring."
264
+ }
265
+ {"id":"base_sql_13","dataset_type":"base","language":"SQL","dialect":"postgresql","task_category":"refactoring",
266
+ "prompt_en":"Refactor this code use a CTE, keep the same functionality.",
267
+ "prompt_nl":"Herstructureer deze code met behulp van een CTE, behoud dezelfde functionaliteit.",
268
+ "code_snippet_input":"SELECT \npatient_name,\nweight_kg,\nheight_m,\nCASE \nWHEN (weight_kg / (height_m * height_m)) < 18.5 THEN 'Underweight'\nWHEN (weight_kg / (height_m * height_m)) >= 18.5 AND (weight_kg / (height_m * height_m)) < 25 THEN 'Healthy'\nWHEN (weight_kg / (height_m * height_m)) >= 25 AND (weight_kg / (height_m * height_m)) < 30 THEN 'Overweight'\nWHEN (weight_kg / (height_m * height_m)) >= 30 THEN 'Obese'\nEND as bmi_category\nFROM patients;",
269
+ "canonical_solution":"WITH PatientBMI AS (\nSELECT \npatient_name,\n(weight_kg / (height_m * height_m)) as bmi_score\nFROM patients\n)\nSELECT \npatient_name,\nbmi_score,\nCASE \nWHEN bmi_score < 18.5 THEN 'Underweight'\nWHEN bmi_score < 25 THEN 'Healthy' -- Implicitly means \">= 18.5 AND < 25\"\nWHEN bmi_score < 30 THEN 'Overweight' -- Implicitly means \">= 25 AND < 30\"\nELSE 'Obese'\nEND as bmi_category\nFROM PatientBMI;",
270
+ "unit_test_setup": "CREATE TABLE patients (\n patient_name VARCHAR(50),\n weight_kg DECIMAL(10, 2),\n height_m DECIMAL(10, 2)\n);\n\nINSERT INTO patients VALUES ('Alice', 50.0, 1.80);\n\nINSERT INTO patients VALUES ('Bob', 70.0, 1.75);\n\nINSERT INTO patients VALUES ('Charlie', 85.0, 1.75);\n\nINSERT INTO patients VALUES ('Diana', 100.0, 1.70);",
271
+ "unit_test_assertion": " @Test\n public void testBMIRefactoring(Connection conn) throws SQLException {\n String sql = generatedSqlQuery.toUpperCase();\n assertTrue(sql.contains(\"WITH \"), \"Refactoring failed: You must use a Common Table Expression (WITH clause).\");\n\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n int count = 0;\n while(rs.next()) {\n count++;\n String name = rs.getString(\"patient_name\");\n String category = rs.getString(\"bmi_category\");\n \n if (name.equals(\"Alice\")) assertEquals(\"Underweight\", category);\n else if (name.equals(\"Bob\")) assertEquals(\"Healthy\", category);\n else if (name.equals(\"Charlie\")) assertEquals(\"Overweight\", category);\n else if (name.equals(\"Diana\")) assertEquals(\"Obese\", category);\n }\n assertEquals(4, count, \"Should return all 4 patients\");\n }\n }",
272
+ "comment":"the solution MUST use a CTE to calculate BMI just once, then reference that in the main query to assign a category. The unit test includes structural checks (as well as functional checks) to ensure refactoring and specific use of CTE as the prompt requires. The unit test includes structural checks (as well as functional checks) to ensure refactoring."
273
+ }
274
+ {"id":"base_sql_14","dataset_type":"base","language":"SQL","dialect":"postgresql","task_category":"refactoring",
275
+ "prompt_en":"These are two queries that have similar calculations, one returns the gpa of all students, the other returns the gpa of cum laude students. Make a view called student_gpa_view to refactor this code to reduce redundancy.",
276
+ "prompt_nl":"Dit zijn twee query's met vergelijkbare berekeningen: de ene retourneert het gemiddelde cijfer van alle studenten, de andere retourneert het gemiddelde cijfer van cum laude-studenten. Maak een weergave met de naam student_gpa_view om deze code te herstructureren en redundantie te verminderen.",
277
+ "code_snippet_input":"SELECT \ns.student_name,\nSUM(g.score * c.credits) * 1.0 / SUM(c.credits) as gpa\nFROM students s\nJOIN grades g ON s.id = g.student_id\nJOIN courses c ON g.course_id = c.id\nWHERE s.id = 101\nGROUP BY s.student_name;\n\n SELECT \ns.student_name,\nSUM(g.score * c.credits) * 1.0 / SUM(c.credits) as gpa\nFROM students s\nJOIN grades g ON s.id = g.student_id\nJOIN courses c ON g.course_id = c.id\nGROUP BY s.student_name\nHAVING SUM(g.score * c.credits) * 1.0 / SUM(c.credits) > 8.0;",
278
+ "canonical_solution":"CREATE VIEW student_gpa_view AS\nSELECT \ns.id as student_id,\ns.student_name,\nCOUNT(g.course_id) as total_classes,\nCAST(SUM(g.score * c.credits) * 1.0 / SUM(c.credits) AS DECIMAL(10,2)) as gpa\nFROM students s\nJOIN grades g ON s.id = g.student_id\nJOIN courses c ON g.course_id = c.id\nGROUP BY s.id, s.student_name;",
279
+ "unit_test_setup": "CREATE TABLE students (id INT PRIMARY KEY, student_name VARCHAR(50));\nCREATE TABLE courses (id INT PRIMARY KEY, credits INT);\nCREATE TABLE grades (student_id INT, course_id INT, score INT);\n\nINSERT INTO students VALUES (1, 'Felipe');\nINSERT INTO courses VALUES (101, 5), (102, 5);\nINSERT INTO grades VALUES (1, 101, 9), (1, 102, 8);\n\nINSERT INTO students VALUES (2, 'Bob');\nINSERT INTO grades VALUES (2, 101, 6), (2, 102, 7);",
280
+ "unit_test_assertion": " @Test\n public void testViewCreation(Connection conn) throws SQLException {\n try (Statement stmt = conn.createStatement()) {\n stmt.execute(generatedSqlQuery);\n }\n\n String verifySql = \"SELECT student_name, gpa FROM student_gpa_view ORDER BY student_name DESC\";\n \n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(verifySql)) {\n \n assertTrue(rs.next(), \"The view should return rows.\");\n assertEquals(\"Felipe\", rs.getString(\"student_name\"));\n assertEquals(8.5, rs.getDouble(\"gpa\"), 0.01, \"Felipe's GPA should be 8.5\");\n \n assertTrue(rs.next());\n assertEquals(\"Bob\", rs.getString(\"student_name\"));\n assertEquals(6.5, rs.getDouble(\"gpa\"), 0.01, \"Bob's GPA should be 6.5\");\n }\n }",
281
+ "comment":"the solution MUST create a view called student_gpa_view that encapsulates the GPA calculation logic, so that both original queries can be simplified to select from this view with appropriate filtering (by student_id for the first, and by gpa for the second). This reduces redundancy and improves maintainability. The unit test includes structural checks (as well as functional checks) to ensure refactoring."
282
+ }
283
+ {"id":"base_sql_15","dataset_type":"base","language":"SQL","dialect":"postgresql","task_category":"refactoring",
284
+ "prompt_en":"This query retrieves the name, last order date and last product ordered for all customers, but it has repeated subqueries. Refactor the query using a lateral join to make it more efficient and readable without changing functionality.",
285
+ "prompt_nl":"Deze query haalt de naam, laatste besteldatum en laatst bestelde producten voor alle klanten op, maar bevat herhaalde subquery's. Herstructureer de query met behulp van een lateral join om deze efficiënter en leesbaarder te maken zonder de functionaliteit te wijzigen.",
286
+ "code_snippet_input":"SELECT \nc.name,\n(SELECT order_date FROM orders o WHERE o.customer_id = c.id ORDER BY order_date DESC LIMIT 1) as order_date,\n(SELECT product_name FROM orders o WHERE o.customer_id = c.id ORDER BY order_date DESC LIMIT 1) as product_name,\n(SELECT amount FROM orders o WHERE o.customer_id = c.id ORDER BY order_date DESC LIMIT 1) as amount\nFROM customers c;",
287
+ "canonical_solution":"SELECT \nc.name,\nlast_o.order_date,\nlast_o.product_name,\nlast_o.amount\nFROM customers c\nLEFT JOIN LATERAL (\nSELECT order_date, product_name, amount\nFROM orders o\nWHERE o.customer_id = c.id\nORDER BY order_date DESC\nLIMIT 1\n) last_o ON TRUE;",
288
+ "unit_test_setup": "CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(50));\nCREATE TABLE orders (id INT, customer_id INT, product_name VARCHAR(50), amount INT, order_date DATE);\n\nINSERT INTO customers VALUES (1, 'Alice');\nINSERT INTO orders VALUES (101, 1, 'Phone', 500, '2023-01-01');\nINSERT INTO orders VALUES (102, 1, 'Laptop', 1000, '2023-01-02');\nINSERT INTO orders VALUES (103, 1, 'Tablet', 300, '2023-01-03');\n\nINSERT INTO customers VALUES (2, 'Bob');",
289
+ "unit_test_assertion": " @Test\n public void testLateralJoin(Connection conn) throws SQLException {\n String sql = generatedSqlQuery.toUpperCase();\n assertTrue(sql.contains(\"LATERAL\"), \"Refactoring failed: The model ignored the instruction to use LATERAL JOIN.\");\n\n try (Statement stmt = conn.createStatement();\n ResultSet rs = stmt.executeQuery(generatedSqlQuery)) {\n \n assertTrue(rs.next());\n assertEquals(\"Alice\", rs.getString(\"name\"));\n assertEquals(\"Tablet\", rs.getString(\"product_name\"));\n \n assertTrue(rs.next());\n assertEquals(\"Bob\", rs.getString(\"name\"));\n assertNull(rs.getString(\"product_name\"), \"Bob was filtered out or data is wrong. Did you use LEFT JOIN LATERAL?\");\n }\n }",
290
+ "comment":"the solution MUST use a LATERAL JOIN to fetch the last order details in a single subquery per customer. The unit test includes structural checks (as well as functional checks) to ensure refactoring."
291
+ }