-
Notifications
You must be signed in to change notification settings - Fork 71
Add back 0-based indexes #6348
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
Add back 0-based indexes #6348
Conversation
f2f64bc to
c235113
Compare
c235113 to
3f17849
Compare
3f17849 to
13c3a9a
Compare
9634d87 to
35d381b
Compare
eb51434 to
ba97cea
Compare
This commit adds back 0-based index/slice expressions to the language. It also institutes pragmas declarations that allow users to specify 1-based or 0-based indexes for a given scope. # Conflicts: # compiler/parser/parser.go
ba97cea to
c64512f
Compare
|
👍🏻 I like this much more than the prior PR (#6327) |
|
I am still curious what this behavior will look like when pragma is set to 1?
|
|
@chrismo: I suspect you may have already done some of your own testing between the merge of this PR and the related #6351. But the answer to the question in your comment is that for this specific example the result is the same regardless of the pragma setting: That happens to match what traditional SQL systems do as well. I think this makes sense since, as it's used here, the concept of "index base" doesn't really come into play, since the query is just asking for the first three characters of the string. In this regard, I think you were certainly correct to call out that unexpected 4-character Where the pragma still has some impact is if we include the "start position" (to use the term from the SQL spec) since it behaves like an index base. Per #6351, we made the decision for now to let that be affected by the pragma setting. That means the default behavior does diverge from SQL, but strict backward compatibility with SQL is why we added the pragma. Since you showed an interest in this topic and your feedback has been helpful, I'll flag you down on community Slack to give you a bit more detail about the approaches we considered here and see if you have any other reactions. |
Yeah, that clearly seemed to be a bug. Glad to see that it didn't propagate into this PR :) |
Yeah, I dunno if I agree. 🤔 I guess this is the sort of scenario that led y'all to attempt "1-based in SQL, 0-based elsewhere" ... It seems inconsistent as just |
This commit adds back 0-based index/slice expressions to the language. It also institutes pragmas declarations that allow users to specify 1-based or 0-based indexes for a given scope.