Commit 18a6169
feat(parser,runner): add
* feat(parser,runner): add `let` record for binding query results to variables
Add a new `let` record type that executes a SQL query and binds the
results to variables for use in subsequent queries. This is useful for
capturing dynamic values like auto-generated IDs.
Syntax: `let (var1, var2, ...) \n SQL`
Features:
- Binds query results to named variables stored in RunnerLocals
- Requires exactly 1 row with N columns matching N variables
- Supports conditions (skipif/onlyif) and connection directives
- Variables can be used with substitution syntax ($var, ${var:default})
- Clear error messages for row/column count mismatches
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
* fix: remove redundant trim() before split_whitespace()
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
* fmt
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
* refactor: consolidate let record errors into `LetError` enum
Replace duplicated inline error structs (RowCountError, ColumnCountError)
and unused TestErrorKind variants (LetRowCountMismatch,
LetColumnCountMismatch) with a single `LetError` enum.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
* refactor: simplify `let` record syntax by removing parentheses
Change `let (var1, var2)` to `let var1, var2` for consistency with
other sqllogictest record syntax and reduced visual noise.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
* fmt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
---------
Signed-off-by: Yuhao Su <yuhaosu@outlook.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>let record for binding query results to variables (#279)1 parent 492c9e3 commit 18a6169
6 files changed
Lines changed: 571 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
222 | 251 | | |
223 | 252 | | |
224 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
199 | 210 | | |
200 | 211 | | |
201 | 212 | | |
| |||
357 | 368 | | |
358 | 369 | | |
359 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
360 | 380 | | |
361 | 381 | | |
362 | 382 | | |
| |||
700 | 720 | | |
701 | 721 | | |
702 | 722 | | |
| 723 | + | |
| 724 | + | |
703 | 725 | | |
704 | 726 | | |
705 | 727 | | |
| |||
976 | 998 | | |
977 | 999 | | |
978 | 1000 | | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
979 | 1040 | | |
980 | 1041 | | |
981 | 1042 | | |
| |||
1029 | 1090 | | |
1030 | 1091 | | |
1031 | 1092 | | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1032 | 1108 | | |
1033 | 1109 | | |
1034 | 1110 | | |
| |||
1336 | 1412 | | |
1337 | 1413 | | |
1338 | 1414 | | |
| 1415 | + | |
1339 | 1416 | | |
1340 | 1417 | | |
1341 | 1418 | | |
| |||
1389 | 1466 | | |
1390 | 1467 | | |
1391 | 1468 | | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
1392 | 1568 | | |
0 commit comments