Skip to content
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

expr: propagate errors through evaluation and optimization #2234

Merged
merged 2 commits into from
Mar 11, 2020

Conversation

benesch
Copy link
Member

@benesch benesch commented Mar 5, 2020

Builds on #2233 to propagate errors that occur at optimization time to the client.


This patch allows scalar expressions evaluation to return an error. As
optimization might involve evaluating the constituent scalar
expressions, optimization can now return errors as well. If such an
error is discovered during optimization (i.e., somewhere between plan
time and run time), it will be returned to the client.

Errors that truly occur at runtime are still replaced with NULLs, as
before. A future commit will wire up a separate error pathway for
runtime errors.

benesch added a commit to benesch/materialize that referenced this pull request Mar 9, 2020
This converts the non-converging fixpoint panic into a graceful error
(MaterializeInc#1177). It also tees us up nicely for runtime errors (MaterializeInc#489).

This PR is mostly extracted from MaterializeInc#2234, which has already been approved.
@benesch benesch force-pushed the expr-errors branch 3 times, most recently from 2fc1e0e to 490080c Compare March 10, 2020 22:42
AND, OR, and coalesce all want to evaluate their arguments lazily rather
than eagerly. This has semantic implications when evaluation can error.
For example

    coalesce(1, 1 / 0)

does not result in an error, because `1 / 0` is not evaluated,

    coalesce(NULL, 1 / 0)

does result in an error, because the `1 / 0` will be evaluated.

This patch installs the necessary plumbing to allow functions to opt-in
to lazy evaluation, and then teaches AND, OR, and coalesce to do so.
This patch allows scalar expressions evaluation to return an error. As
optimization might involve evaluating the constituent scalar
expressions, optimization can now return errors as well. If such an
error is discovered during optimization (i.e., somewhere between plan
time and run time), it will be returned to the client.

Errors that truly occur at runtime are still replaced with NULLs, as
before. A future commit will wire up a separate error pathway for
runtime errors.
@benesch benesch merged commit 27b7d03 into MaterializeInc:master Mar 11, 2020
@benesch benesch deleted the expr-errors branch March 11, 2020 02:32
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.

2 participants