prql
prql copied to clipboard
feat: Better error message for missing args
Addresses #1171
Hi! Are there any methods for pasting the output into the test program?
Here's my current code snippet for testing:
#[test]
fn test_hint_missing_args(){
assert_display_snapshot!(compile(r###"
from film
select [film_id, lag film_id]
"###).unwrap_err(), @r###"
Error:
╭─[:3:22]
│
2 │ select [film_id, lag film_id]
· ─────┬─────
· ╰─────── function std.select, param `columns` expected type `column`, but found type `func infer -> column`
·
· Help: Have you forgot an argument to function `lag`
───╯
"###)
}
Result of the test:
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0 0 │ Error:␊
1 1 │ ╭─[:3:22]␊
2 2 │ │␊
3 │- 2 │ select [film_id, lag film_id]␊
4 │- · ─────┬─────␊
5 │- · ╰─────── function std.select, param `columns` expected type `column`, but found type `func infer -> column`␊
3 │+ 3 │ select [film_id, lag film_id]␊
4 │+ · ─────┬─────␊
5 │+ · ╰─────── function std.select, param `columns` expected type `column`, but found type `func infer -> column`␊
6 6 │ ·␊
7 7 │ · Help: Have you forgot an argument to function `lag`␊
8 │-───╯
8 │+───╯␊
────────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I have tried directly copy and pasting from terminal, as well as piping the results to an external file.
Yes there are. We are using cargo-insta. In your case, you need:
$ cargo install cargo-insta
$ cargo insta review
Thanks @JettChenT ! Great first PR!
Re accepting the snapshots — the lines that @aljazerzen wrote are the closest way. There are also some pre-written tasks if you want to use those, as discussed in https://github.com/PRQL/prql/blob/main/DEVELOPMENT.md
@aljazerzen @max-sixty Thanks for the help! I have updated the test file and fixed the grammar issue.
Thanks a lot @JettChenT ! And welcome to PRQL!