Skip to content

fix: report a non-relation value passed as a transform's input instead of an internal error - #6585

Merged
max-sixty merged 2 commits into
mainfrom
fix/non-relation-input-error
Nov 20, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/non-relation-input-error

Conversation

@prql-bot

Copy link
Copy Markdown
Collaborator

A literal in a transform's relation position — 5 | select a, from t | derive x 5, from t | take 1 "a", from foo | select lower "mooo" — now reports "expected a table or query, but found 5" at the literal, instead of a location-less internal compiler error; tracked at https://github.com/PRQL/prql/issues/4317.

Error:
   ╭─[ :1:19 ]
   │
 1 │ from t | derive x 5
   │                   ┬
   │                   ╰── expected a table or query, but found `5`
───╯

Cause. Such a literal passes validate_type against the relation param (the "temporary hack" there lets any non-function value through when an array type is expected), so it reaches the lineage lookup in resolve_function_args. That lookup's fallback arm raised Error::new_bug(4317); #5564 had replaced it with a proper error only for the empty {} / [] cases. The fallback arm now returns the same Expected error, describing the argument with write_pl and spanned at the argument. The validate_type allowance itself is left alone, since it exists for window functions in derive/aggregate.

Tests. error_messages::non_relation_transform_input covers four of the forms above; task prqlc:test passes. The comment on bad_error_messages::select_with_extra_fstr, which compares against select lower "mooo", now names the error that case gives. No conflict with #6525, which handles the reverse case (a table used as a value) in lowering.rs.

…d of an internal error

A literal in a transform's relation position, such as `5 | select a` or
`from t | derive x 5`, passed type checking (the array-type allowance in
validate_type lets non-function values through) and reached the lineage
lookup in resolve_function_args, whose fallback arm raised a location-less
internal compiler error tracked at #4317. Report it as "expected a table or
query, but found `5`" at the argument's span, as the empty `{}`/`[]` arms
already do.
@max-sixty
max-sixty merged commit 078a8ef into main Nov 20, 2026
36 checks passed
@max-sixty
max-sixty deleted the fix/non-relation-input-error branch November 20, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants