Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions prqlc/prqlc/src/semantic/resolver/transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Resolver<'_> {
let span = side.span;
let ident = side.clone().try_cast(
ExprKind::into_literal,
Some("side"),
Some("`side`"),
"inner, left, right or full",
)?;

Expand Down Expand Up @@ -242,7 +242,7 @@ impl Resolver<'_> {
let span = by.span;
let ident = by.clone().try_cast(
ExprKind::into_literal,
Some("by"),
Some("`by`"),
"position or name",
)?;

Expand Down Expand Up @@ -431,7 +431,7 @@ impl Resolver<'_> {
let span = take.span;
let ident = take.clone().try_cast(
ExprKind::into_literal,
Some("take"),
Some("`take`"),
"early or late",
)?;

Expand Down Expand Up @@ -526,7 +526,7 @@ impl Resolver<'_> {
let res = {
let span = format.span;
let format = format
.try_cast(ExprKind::into_literal, Some("format"), "csv or json")?
.try_cast(ExprKind::into_literal, Some("`format`"), "csv or json")?
.to_string();
match format.as_str() {
"\"csv\"" => from_text::parse_csv(&text)
Expand Down
46 changes: 45 additions & 1 deletion prqlc/prqlc/tests/integration/error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,55 @@ fn tuple_uniq_take_wrong() {
3 │ select (tuple_uniq take:bar this)
│ ─┬─
│ ╰─── take expected early or late, but found `this.foo.bar`
│ ╰─── `take` expected early or late, but found `this.foo.bar`
───╯
");
}

/// The other three transforms that resolve a parameter to a literal report the
/// parameter name the same way. An s-string reaches the cast without being a
/// literal, which is the path that produces these.
#[test]
fn transform_param_not_a_literal() {
assert_snapshot!(compile(r###"
from x
join y (==id) side:s"left"
"###).unwrap_err(), @r#"
Error:
╭─[ :3:24 ]
3 │ join y (==id) side:s"left"
│ ───┬───
│ ╰───── `side` expected inner, left, right or full, but found `s"left"`
───╯
"#);

assert_snapshot!(compile(r###"
from foo
append by:s"name" baz
"###).unwrap_err(), @r#"
Error:
╭─[ :3:15 ]
3 │ append by:s"name" baz
│ ───┬───
│ ╰───── `by` expected position or name, but found `s"name"`
───╯
"#);

assert_snapshot!(compile(r###"
from_text format:s"csv" "a,b"
"###).unwrap_err(), @r#"
Error:
╭─[ :2:22 ]
2 │ from_text format:s"csv" "a,b"
│ ───┬──
│ ╰──── `format` expected csv or json, but found `s"csv"`
───╯
"#);
}

#[test]
fn append_by_name_wildcard() {
assert_snapshot!(compile(r"from foo | append by:name (from bar)").unwrap_err(), @"
Expand Down
Loading