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
Compiler crash on from_text
with zero rows
#4421
Comments
I'm not sure that the provided SQL output is the best choice moving forward, but I'm making a PR that at least provides an error message for this situation and prevents a crash |
@kgutwin What is your use case for this?
For case 2. @KaeporaGaebora should help (and is greatly appreciated 🙏). For case 1., this kind of thing should be handled by the type system once implemented. Please note that the following works: from_text "col_a,col_b\n," You can produce the SQL you provided with the following: from [{col_a=null, col_b=null}] HTH |
Thanks - the use case might be a little uncommon, but our team is working on code that takes user input and generates PRQL documents. As part of that process, it's typical for users to generate empty relations with known columns. It's not very useful to them -- they will typically immediately begin adding rows -- but since our app generates and executes the PRQL "live", having a compiler error on an empty relation isn't something we want the users to need to deal with. We can, of course, catch the compiler error and smoothly handle it, so the solution proposed by @KaeporaGaebora is indeed plausible; but I do wonder whether an error is the right solution, given that it is definitely not a SQL error to have an empty relation. As of now, we don't have a specific need to be able to create an empty relation, but I suppose at some point in the future it might come up. I did want to note that the PRQL snippets you suggested produce subtly different output than what I had expected; in particular, the last one is missing the necessary |
I definitely think it should be possible to produce I'm not sure whether it should be possible to produce Thanks for adding the error @KaeporaGaebora , that's already better. |
What happened?
It should be possible (not very useful, perhaps, but still possible) to define a relation using
from_text
where it has known columns but no rows. At a minimum, such a definition ought not to crash...PRQL input
SQL output
n/a, crashes
Expected SQL output
MVCE confirmation
Anything else?
The message on crash is:
Tested with latest code, commit d642a30
The text was updated successfully, but these errors were encountered: