Skip to content

add ok() / is_ok() and replace error("missing") with none handling - #7288

Merged
mccanne merged 3 commits into
mainfrom
no-error-missing
Sep 8, 2026
Merged

add ok() / is_ok() and replace error("missing") with none handling#7288
mccanne merged 3 commits into
mainfrom
no-error-missing

Conversation

@mccanne

@mccanne mccanne commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

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.

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.
Comment thread compiler/ztests/udf-implied-where.yaml
Comment thread compiler/semantic/expr.go Outdated
Comment thread runtime/vam/expr/function/function.go Outdated
Comment thread runtime/vam/expr/function/ok.go Outdated
Comment thread runtime/vam/expr/function/ok.go Outdated
Comment thread runtime/vam/expr/compare.go Outdated
Comment thread runtime/vam/expr/dot.go Outdated

@nwt nwt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall nit: Having seen X.is_ok() in action, I prefer is_ok(X) because I find it clearer.

Comment thread runtime/ztests/expr/type-map.yaml Outdated
Comment thread runtime/ztests/expr/optional-fields.yaml Outdated
Comment thread runtime/vam/expr/slice.go Outdated
Comment thread runtime/vam/expr/eval.go
// 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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread runtime/vam/expr/dot.go Outdated
@mccanne
mccanne merged commit 8741fcf into main Sep 8, 2026
4 checks passed
@mccanne
mccanne deleted the no-error-missing branch September 8, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants