-
Notifications
You must be signed in to change notification settings - Fork 225
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
Creating tables with aggregation with automatically named columns results in unnamed columns error. #2175
Comments
This is surprising, thanks a lot @cottrell ... Here's an even simpler example: let a = (
from invoices
group customer_id (
aggregate [count]
)
)
from a
|
I think this message is quite self-explanatory, but as its author, of course I'm biased. Let me elaborate: Definition of the table compiles to this:
If you try to write the main SELECT, you get something like:
... but because the second column doesn't have a name, you cannot reference it! (a partial solution would be to use a How should we change the error to make this more obvious? |
Just from the perspective of the result, without thinking at all about how it's built:
|
Ok, I must admit that for this specific case, it could produce a |
I can barely remember this one now but it seems to me like it might simplify to do away with the convenience of "nameless" or "implicitly named" aggregations? i.e. "count = count" not "count". I'm not sure if it was more complicated than that. More explicit and less surface area is usually better in the long run. |
Automatic name inference can be tricky. In this case it seems obvious that the inferred named should be
There is also an option to combine these two rules, but I'm hesitant to choose something that would be too complicated. I don't want something unpredictable that people would rely on, but would then change when the function definition is changed. SQL engines each have their own rules around this so there is no option to say "let's just do what most SQL engines do". (this is a bit off topic, let's create a new issue for more discussion) |
What happened?
This one compiles without error
But the below PRQL input does not.
Some minor name thing probably.
PRQL input
SQL output
Expected SQL output
MVCE confirmation
Anything else?
No response
The text was updated successfully, but these errors were encountered: