Skip to content

Comments

error_if_null: Lazily evaluate error#32019

Merged
antiguru merged 1 commit intoMaterializeInc:mainfrom
antiguru:error_if_null
Mar 26, 2025
Merged

error_if_null: Lazily evaluate error#32019
antiguru merged 1 commit intoMaterializeInc:mainfrom
antiguru:error_if_null

Conversation

@antiguru
Copy link
Member

At the moment, error_if_null evaluates both its input, and in most cases discards the error input. This causes us to do a lot of unnecessary work in the common case.

Instead, only evaluate the error expression (second input) if the first one evaluates to null.

Related: MaterializeInc/database-issues#9125

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

At the moment, `error_if_null` evaluates both its input, and in most cases
discards the error input. This causes us to do a lot of unnecessary work in
the common case.

Instead, only evaluate the error expression (second input) if the first one
evaluates to null.

Related: MaterializeInc/database-issues#9125

Signed-off-by: Moritz Hoffmann <mh@materialize.com>
@antiguru antiguru requested a review from a team as a code owner March 26, 2025 13:09
@ggevay ggevay self-requested a review March 26, 2025 13:25
Copy link
Contributor

@mgree mgree left a comment

Choose a reason for hiding this comment

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

Looks good to me. It would make sense to change it to BinaryFunc in this PR, but also if it ain't broke...

@antiguru
Copy link
Member Author

Thanks for the review. I'll file an issue to change it to a binary function separately.

@antiguru antiguru enabled auto-merge (squash) March 26, 2025 13:32
@antiguru
Copy link
Member Author

Here it is: MaterializeInc/database-issues/issues/9126

@antiguru antiguru merged commit 67a02b2 into MaterializeInc:main Mar 26, 2025
83 checks passed
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