-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error location markers for SQL routines (functions) are off, may break CLI #21357
Comments
For inline functions we could modify For plugin-provided functions this wouldn't apply. For these, we probably need to disable error location markers, as the location markers are assumed to correspond to query text. Alternatively, we could erase error location markers for any functions used by the query. |
That would be ideal, but it probably won't work. The functions are added via this call. The formatted sql for the function and the locations may not match the locations in the original text.
|
Good point. So what else can we do? |
BTW is this reformatting important? if we abstained from that, would it be possible to produce good error messages for queries with functions? |
I put up a fix in #21815 For inline functions and function creation, we directly analyze the original AST. The formatting round-trip was an oversight due to using the same API for stored functions, which are stored as SQL and then formatted before analysis. For stored functions, we wrapper exceptions thrown during analysis of the stored function, which hides the location. Then query expression analyzer wraps it again with a location pointing at the function call for the function being analyzed. This is a much better user experience overall, as reporting a semantic exception for a stored function as if it is for the user's query is nonsensical. |
Location markers for functions are relative to function definition, not the query scope.
For inline functions this can be reproduced with:
Invalid error location markers cause Trino CLI to print exceptions (the first stacktrace printed is legit, but the second comes from the CLI itself)
The text was updated successfully, but these errors were encountered: