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

feat(expr): expression node level non-strict evaluation #12461

Merged
merged 22 commits into from
Sep 27, 2023

Conversation

BugenZhao
Copy link
Member

@BugenZhao BugenZhao commented Sep 20, 2023

Signed-off-by: Bugen Zhao i@bugenzhao.comI hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

See #4625 for the background.

Follow-up of #12426, this PR introduces a new NonStrict wrapper that reports the evaluation error and pads with NULL for the inner expression. The wrapper will be attached to every node in the expression tree, unlike the previous eval_infallible function which only handles errors in the root node. This is more reasonable as the optimizer may transform the expression tree arbitrarily after #10812.

As a result, the context for reporting errors will be passed in during the build phase.

Resolves #11586.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

@BugenZhao BugenZhao force-pushed the bz/non-strict-expr-wrapper branch 2 times, most recently from 1228c9d to 53e13dc Compare September 20, 2023 11:09
Base automatically changed from bz/checked-expr-wrapper to main September 20, 2023 12:06
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao force-pushed the bz/non-strict-expr-wrapper branch from 53e13dc to f6c468b Compare September 21, 2023 03:47
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao force-pushed the bz/non-strict-expr-wrapper branch from a24495a to 00a22aa Compare September 21, 2023 05:22
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao marked this pull request as ready for review September 21, 2023 06:26
@BugenZhao BugenZhao requested a review from a team as a code owner September 21, 2023 06:26
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
…apper

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
…apper

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #12461 (a597f2c) into main (590faea) will decrease coverage by 0.01%.
Report is 6 commits behind head on main.
The diff coverage is 63.38%.

@@            Coverage Diff             @@
##             main   #12461      +/-   ##
==========================================
- Coverage   69.35%   69.35%   -0.01%     
==========================================
  Files        1438     1439       +1     
  Lines      238668   238751      +83     
==========================================
+ Hits       165535   165586      +51     
- Misses      73133    73165      +32     
Flag Coverage Δ
rust 69.35% <63.38%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/expr/core/src/expr/expr_case.rs 95.68% <100.00%> (+0.09%) ⬆️
src/expr/core/src/expr/expr_coalesce.rs 96.00% <100.00%> (+0.09%) ⬆️
src/expr/core/src/expr/expr_field.rs 84.68% <100.00%> (+0.42%) ⬆️
src/expr/core/src/expr/expr_in.rs 98.46% <100.00%> (+0.02%) ⬆️
src/expr/core/src/expr/expr_input_ref.rs 90.69% <100.00%> (+1.50%) ⬆️
src/expr/core/src/expr/expr_literal.rs 99.35% <100.00%> (+0.01%) ⬆️
src/expr/core/src/expr/expr_udf.rs 0.00% <ø> (ø)
src/expr/core/src/expr/expr_vnode.rs 94.73% <100.00%> (+0.23%) ⬆️
src/expr/core/src/expr/mod.rs 76.08% <100.00%> (+17.26%) ⬆️
src/expr/core/src/table_function/user_defined.rs 0.00% <ø> (ø)
... and 29 more

... and 5 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@BugenZhao BugenZhao requested a review from fuyufjh September 26, 2023 06:53
Copy link
Member

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 35 to 40
/// A dummy implementation that panics when called.
impl EvalErrorReport for ! {
fn report(&self, _error: ExprError) {
unreachable!()
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you explain a little bit on this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 63 to 64
_ctx: &ActorContextRef,
_identity: &str,
Copy link
Member

Choose a reason for hiding this comment

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

What about just removing these arguments? Also elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay. I'll remove all function parameters but keep the existing ones in the executor body for potential future use. 😄

Comment on lines +115 to +118
let eval_error_report = ActorEvalErrorReport {
actor_context: ctx.clone(),
identity: info.identity.into(),
};
Copy link
Member

Choose a reason for hiding this comment

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

Since we are providing identity and eval_error_report etc in params, what about passing in eval_error_report when new?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that the fields here are somehow redundant. Either LGTM. 🥹

Comment on lines 58 to 63
impl ExprBuilder<!> {
/// Create a new builder in strict mode.
fn new_strict() -> Self {
Self { error_report: None }
}
}
Copy link
Member

@stdrc stdrc Sep 26, 2023

Choose a reason for hiding this comment

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

What does impl ExprBuilder<!> mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

We need to specify the generic type R: EvalErrorReport even if we use None for error_report. However, since the concrete type does not matter in this case, we can simply use the "never type" !.

fn build_inner(&self, prost: &ExprNode) -> Result<BoxedExpression> {
use PbType as E;

let build_child = |prost: &'_ ExprNode| self.build(prost);
Copy link
Member

Choose a reason for hiding this comment

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

Interesting

Comment on lines 109 to 114
async fn eval(&self, input: &DataChunk) -> Result<ArrayRef> {
Ok(match self.inner.eval(input).await {
Ok(array) => array,
Err(_e) => self.eval_chunk_infallible_by_row(input).await,
})
}
Copy link
Member

Choose a reason for hiding this comment

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

So this function tries inner.eval chunk, if failed, eval it row by row again? Is there a better option?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

Is there a better option?

Maybe. Assuming the evaluation error is rare, the current implementation works fine, so I didn't make any changes in this PR.

…apper

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao enabled auto-merge September 27, 2023 06:30
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao added this pull request to the merge queue Sep 27, 2023
Merged via the queue into main with commit 0126304 Sep 27, 2023
9 of 10 checks passed
@BugenZhao BugenZhao deleted the bz/non-strict-expr-wrapper branch September 27, 2023 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(expr): coalesce doesn't work as expected in streaming
3 participants