-
Notifications
You must be signed in to change notification settings - Fork 3.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
sql/parser: support nullable arguments in builtin functions #17264
Conversation
Hold off on reviewing this for now, actually, I have some stuff to figure out. |
02bbf54
to
f63d0e1
Compare
OK, after sleeping on this a bit and discussing it with Jordan, I have a better understanding and I've updated it a bit, please take a look when you get a chance. |
f63d0e1
to
25890c4
Compare
Review status: 0 of 8 files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. pkg/sql/parser/overload.go, line 541 at r2 (raw file):
Hmm I'm surprised this works. Although this function doesn't mutate Comments from Reviewable |
LGTM modulo resolution of the open question Reviewed 8 of 8 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 2 of 2 files at r4. pkg/sql/parser/overload.go, line 541 at r2 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
same question here Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. pkg/sql/parser/overload.go, line 541 at r2 (raw file): Previously, knz (kena) wrote…
Any time One option might be to do the switch outside the calls to this function and then it can be clearer in which cases it's causing a return and in which cases it's not, but this would make the calling function a bit noisy. I don't want to revert this to pass Comments from Reviewable |
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. pkg/sql/parser/overload.go, line 541 at r2 (raw file): Previously, justinj (Justin Jaffray) wrote…
Can you extend the comment of this function with your explanation, then we're probably good to go. Comments from Reviewable |
c907da2
to
e5c046b
Compare
Review status: 5 of 8 files reviewed at latest revision, 1 unresolved discussion. pkg/sql/parser/overload.go, line 541 at r2 (raw file): Previously, knz (kena) wrote…
Ok, done. I spent some time yesterday trying to figure out a more holistic change, but I think this will do for now. Comments from Reviewable |
Reviewed 5 of 8 files at r1, 3 of 3 files at r5, 1 of 1 files at r6, 2 of 2 files at r7. Comments from Reviewable |
Fixes cockroachdb#12968. Fixes cockroachdb#9920. This change reworks how NULL arguments are handled during type checking for `FuncExprs`, `UnaryOps`, `CmpOps`, and `BinOps`. In doing so, it also fixes a latent bug we had where the latter two expressions would return NULL when given a NULL argument even when no candidate overload would be possible. For instance: `'hello' + NULL` returned NULL, even though we had no `<string> + <T>` operator. We were actually testing this behavior in `TestTypeCheck`, so those tests had to change. It does addresses this by returning all compatible candidate functions from `typeCheckOverloadedExprs`. This improvement to the function's interface allows us to distinguish impossible overload resolution from ambiguous resolution. We then return NULL if **1 or more** candidates are possible and there is a NULL argument. To compliment this, we add a `nullableArgs` flag on the `Builtin` struct so that the few implementations that want a chance to see the NULL values can. This means that we can selectively disable the NULL fast-path for certain builtins. Please note that I'm not currently satisfied with the structure of `typeCheckOverloadedExprs` or its conflation of the terms `overload` and `candidate`. I plan to address these in a later change though that will pull the operations of `typeCheckOverloadedExprs` into an `overloadResolver` type.
This change cleans up `TestTypeCheckOverloadedExprs`, testing the different error cases: - returning an ambiguous candidates result - returning an unsupported candidates result - returning an error This also gets rid of the `PlaceholderTypes` field in the `testData` struct, which was never used.
e5c046b
to
3273f77
Compare
Thanks for the reviews! |
Was a mostly mechanical rebase of #13031. Healthy amounts of 🔬🐶 here.
Also simplified
checkReturn
a little to return thetypedExprs
instead ofs
.