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

fix(expr): tolerate table function errors on streams #17156

Merged
merged 9 commits into from
Jun 7, 2024

Conversation

wangrunji0408
Copy link
Contributor

@wangrunji0408 wangrunji0408 commented Jun 6, 2024

Signed-off-by: Runji Wang [email protected]I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

partially fix_ #11915

Currently, when an error occurs in a table function call, the returned stream stops and the streaming actor will exit. This PR makes streaming tolerant to table function errors. When an error occurs, an error column will be appended to the returned chunk. (see the example in arrow-udf) The batch side will raise error immediately when seeing this column, while the streaming side will report errors and keep going. If some rows have been output when the error occurs, these rows will not be reverted.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

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.

@wangrunji0408 wangrunji0408 requested review from BugenZhao and xxchan June 6, 2024 09:55
@github-actions github-actions bot added the type/fix Bug fix label Jun 6, 2024
Signed-off-by: Runji Wang <[email protected]>
src/expr/macro/src/gen.rs Outdated Show resolved Hide resolved
src/expr/macro/src/gen.rs Show resolved Hide resolved
statement ok
flush;

# Output 0 row when the set-returning function returns error.
Copy link
Member

Choose a reason for hiding this comment

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

There was an discussion on the behavior in this case. #12474 (comment) cc @fuyufjh

Not sure which one we should adopt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default behavior for a table function not being called (e.g. with null input) is returning no rows. So I vote for this for the sake of consistency.

Copy link
Member

Choose a reason for hiding this comment

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

The default behavior for a table function not being called (e.g. with null input) is returning no rows. So I vote for this for the sake of consistency.

I agree that these 2 cases should be consistent

Copy link
Contributor

Choose a reason for hiding this comment

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

This is Option 1 in the original issue. And I agree it is consistent with null input. In other words, the table function returns null (which is similar to {} but not {null}) on error.

Related edges cases on the differences among null, {} and {null}:

^ Just mentioning these cases. Not suggesting any value is always preferred than the other 2.

Signed-off-by: Runji Wang <[email protected]>
Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

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

LGTM!

@wangrunji0408 wangrunji0408 force-pushed the wrj/fix-table-function-error branch from 2c52ee3 to 9b350e9 Compare June 7, 2024 05:37
Signed-off-by: Runji Wang <[email protected]>
@wangrunji0408 wangrunji0408 enabled auto-merge June 7, 2024 06:52
Signed-off-by: Runji Wang <[email protected]>
@wangrunji0408 wangrunji0408 added this pull request to the merge queue Jun 7, 2024
Merged via the queue into main with commit 9d5df04 Jun 7, 2024
28 of 29 checks passed
@wangrunji0408 wangrunji0408 deleted the wrj/fix-table-function-error branch June 7, 2024 12:56
Copy link
Member

@xxchan xxchan left a comment

Choose a reason for hiding this comment

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

Thanks. Cool idea 👍

What I don't fully understand is where is the line leading to panic before? 🤣

When an error occurs, an error column will be appended to the returned chunk. (see the example in arrow-udf)

To clarify, arrow_udf::function and risingwave_expr::function don't have strict relationship, but share similar ideas. Do I understand it correctly?

@BugenZhao
Copy link
Member

What I don't fully understand is where is the line leading to panic before? 🤣

I think there won't be any panic. We'll just enter a recovery loop where the expression error gets thrown out of the actor.

@wangrunji0408 wangrunji0408 changed the title fix(expr): don't panic on table function errors fix(expr): tolerate table function errors on streams Jun 11, 2024
@wangrunji0408
Copy link
Contributor Author

When an error occurs, an error column will be appended to the returned chunk. (see the example in arrow-udf)

To clarify, arrow_udf::function and risingwave_expr::function don't have strict relationship, but share similar ideas. Do I understand it correctly?

Yes. They share the same behavior behind the interface so that we don't need to write additional adapters for UDFs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/fix Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants