-
Notifications
You must be signed in to change notification settings - Fork 221
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
Column named timestamp
escapes backticks
#2155
Comments
Thanks a lot for the report. Agree that the error messages should be much better. Does surrounding the name with backticks work? (Can look more tomorrow) |
For |
Great, confirmed on
But it's important for consistency that the backticks always work; they should take priority over any keyword. |
Re the solution — this is happening because after parsing, we match on keywords: prql/prql-compiler/src/semantic/context.rs Line 388 in 2d6e986
Possibly we should be matching for keyword during parsing, because that's when we know whether a term is escaped with backticks or not. If you have thoughts @aljazerzen ... |
timestamp
escapes backticks
And possible https://prql-lang.org/book/syntax.html#keywords is not accurate, and |
Yes I added Re the timestamp: the dot prefix from #1619 would make this unambitious here: Also, you can use |
Another thing that broke in 0.6.0 and looks related to this
Gives an error
Same goes for column named Is this just a bug that gets fixed or shall we escape all these fields going forward? I'd say that Thanks for the confirmation on |
I wouldn't promise that we will just fix this, but we do need to find a way for adding things to std without breaking existing queries. |
WDYM by this? (not disagreeing at all, just trying to understand the literal meaning) |
I meant that we want to have As I wrote, the overarching problem we will have to solve is the fact that currently any new declarations in |
I'm less worried about this. I think for the moment they'll be small breaking changes, and then when we get to 1.0, we'll have versioning; same as rust... It depends on how widespread this is — if we're adding lots of keywords like Also
(to some extent these priorities are opposing — the first is easier if we parse keywords in the parser, the second is easier if we wait to resolve keywords at resolve time. Though atm we get neither correct :) )
FWIW I agree that this is one of the costs of using bare words like we do. It has benefits (I'd argue large ones, on net), but this is a cost. |
Rust does not make breaking changes. That's why all releases are 1.x and not 2.0, 3.0 and so on. If we also want that (I strongly feel that we do), we won't be able to add, for example, That's my concern.
I agree, but this only works for |
OK yes, I hadn't understood that distinction; I do now. One possibility is to resolve
It does add new keywords though. I get there's a subtle difference from adding things to |
That's true, but editions are not the same as versions. A new version or rustc must support all editions from 1.0 onwards - i'm not sure exactly how we will handle versioning post 1.0, so I guess we don't have to bother with this problem now. |
How do we think most SQL compilers handle this? Because we can write: (edit: updated from below)
...i.e. it works in both places (and with any caps). Maybe they resolve the idents later in the compilation pipeline? (Not saying this is better or worse, just trying to understand the options) |
You probably mean:
or
The answer is that SQL has context-dependent name resolution rules - the thing that I try to avoid. I advocate that ident |
Yeah, I def agree with this impulse... This issue boosts the status of #1619, or something similar to it. Possibly it's a trilemma:
..pick two |
I'm coming back to this. I wonder whether we can handle From the perspective of the language, I think this would work, and would provide a way of forcing an item to be interpreted as a column. From the perspective of the compiler, I think It would require having a new PL type. An alternative would be some form of #1619. I found the semantics in the original proposal quite confusing. I do find the |
Would this also apply to other things in std? Like This would be similar to how Rust also has special name resolution rules for handling types ( Alternatively, we could formalize the |
No, it would be tagged as a column. Same as my comments in #1619 — the difference between a) columns vs. b) function&types is the difficulty, rather than between stdlib & others. |
Ok, so let me get this cleared up. This is what you propose:
I think it would work. A bit unconventional to tangle name resolution with quoting, but it would work. What if I have:
|
These are good cases... I'm thinking about jq also has variables, which it doesn't prefix with
The cases are good, I'm slowing my enthusiasm a tiny bit on this, particularly when I think about name resolution. Maybe this is the price we pay for the life we choose (trilemma above). But I'm hesitant to jump all the way to using
|
That's very limiting... imagine someone is using PRQL as a target for their UI, which allows defining tables. You would not be able to define tables with spaces in their names. How do you feel about this?
|
Yes, fair point. I've been thinking about it more as the query lang — same as
I think it's a nice error message! It's maybe better than the It's still not great. But possibly that's the price we pay for the life we choose! Do you have thoughts on the modified |
Hmmm. So when referring to types and functions, there is no leading I don't like that very much, on top of the reasons for which we abolished #1619 in the first place.
I do feel the same way here - it's quite verbose. All in all, I'm:
|
I see what you mean about treating these differently from the perspective of the compiler. I do think it's an simple mental model for users, though — that data goes into a namespace which is queried with (Possibly I should either really propose it or drop it — rather than being on the fence but continuing discussion...) |
Apparently we have a bit different mental models and the feeling of what people find "simple". My reasoning may be influenced by compiler's perspective, but this is how I think of our semantics - and I'm sure I'm not the only one. But this does show that such feature would divide PRQL users depending on how they think about variables. And we don't want that. |
Sooo... |
I hear that. Arguably
Yes I like it! 😁 |
This is done. Timestamp can now be referenced with |
What's up?
Version 0.6.0 seems to be more restrictive regarding column names. I have two examples that stopped working:
gives error
and
gives error
Is there an easy way to fix the PRQL code? If yes, then maybe the error message should include a hint for the fix, since the column names
type
andtimestamp
are probably common?The text was updated successfully, but these errors were encountered: