add ok() / is_ok() and replace error("missing") with none handling - #7288
Merged
Conversation
This commit is the first step toward getting rid of error("missing")
and handling these conditions with proper none expressions. There are
still quite a few instances of missing values being created but they
will be removed in a subsequent PR where we take out vector.NewMissing().
We introduced the Rust idioms ok() and is_ok(). We removed the has()
and missing() functions and replaced has() with is_ok(). We replaced
quiet() with ok().
There are currently some problems with SQL errors since we relied upon
error("missing") semantics to avoid reporting errors based on the
hidden paths representing SQL relations. We disabled some problematic
tests and will fix the problem and re-enabled the tests in a subsequent PR.
We also wired up rungen to generate path references that use the
field.Chain noneish parameters so the "?." dereferencing operator
works correctly.
mattnibs
reviewed
Sep 7, 2026
nwt
reviewed
Sep 8, 2026
nwt
reviewed
Sep 8, 2026
nwt
left a comment
Member
There was a problem hiding this comment.
Overall nit: Having seen X.is_ok() in action, I prefer is_ok(X) because I find it clearer.
| // CheckForErrorThenNull returns the first element of vecs with an error | ||
| // type. If no element has an error type, it returns the first element with the | ||
| // null type. | ||
| func CheckForErrorThenNull(sctx *super.Context, vecs []vector.Any, msg string) (vector.Any, bool) { |
Member
There was a problem hiding this comment.
The existing implementation intentionally checks for null before error so that we get SQL null semantics (i.e. if any expression input is null, the result is null, with a few exceptions).
I think we should stick with that for simplicity from the user's perspective.
Collaborator
Author
There was a problem hiding this comment.
As we discussed, we'll head in this new direction since SQL doesn't have first class errors so this shouldn't be an issue for backward compat. Ans since nulls otherwise would hide errors, better to propagate them for good DX.
nwt
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit is the first step toward getting rid of error("missing") and handling these conditions with proper none expressions. There are still quite a few instances of missing values being created but they will be removed in a subsequent PR where we take out vector.NewMissing().
We introduced the Rust idioms ok() and is_ok(). We removed the has() and missing() functions and replaced has() with is_ok(). We replaced quiet() with ok().
There are currently some problems with SQL errors since we relied upon error("missing") semantics to avoid reporting errors based on the hidden paths representing SQL relations. We disabled some problematic tests and will fix the problem and re-enabled the tests in a subsequent PR.
We also wired up rungen to generate path references that use the field.Chain noneish parameters so the "?." dereferencing operator works correctly.