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(udf): eval_row panic due to misuse of input row as arg row #9240

Merged
merged 2 commits into from
Apr 17, 2023

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Apr 17, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

Fixes #9066

    async fn eval_row(&self, input: &OwnedRow) -> Result<Datum> {
        let chunk = DataChunk::from_rows(std::slice::from_ref(input), &self.arg_types);
        let output_array = self.eval(&chunk).await?;

In this previous implementation, it converts an input row to an input chunk and reuses eval. However, the data types of columns are not arg_types. We have to evaluate children expressions to get arrays / datums of arg_types.

This always fails, but the eval_row code path executes rarely, mostly only during stream error tolerating, hash join condition, and frontend constant folding. Similar issues: #8115 (review) #7777

Checklist For Contributors

  • 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 DOES NOT contain user-facing changes.

@github-actions github-actions bot added the type/fix Bug fix label Apr 17, 2023
Comment on lines +134 to +138
statement ok
create materialized view mv as select dummy, hex_to_dec(v) from t;

statement ok
insert into t values ('2023-01-01', '1z');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the dummy column, it triggers panic:

thread 'risingwave-streaming-actor' panicked at 'Failed to append datum, array builder type: Utf8, scalar type: Date', src/common/src/array/mod.rs:562:1

Without the dummy column, it triggers panic:

thread 'risingwave-streaming-actor' panicked at 'itertools: .zip_eq() reached end of one iterator before the other', /Users/xiangjin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.10.5/src/zip_eq_impl.rs:48:13

Copy link
Contributor

@lmatz lmatz left a comment

Choose a reason for hiding this comment

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

thanks!

It's really a problem that eval_row() can be hardly covered in normal SLT tests.

😢

@lmatz lmatz enabled auto-merge April 17, 2023 14:34
@lmatz lmatz added this pull request to the merge queue Apr 17, 2023
@codecov
Copy link

codecov bot commented Apr 17, 2023

Codecov Report

Merging #9240 (c047556) into main (ff8de5c) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #9240      +/-   ##
==========================================
- Coverage   70.83%   70.82%   -0.02%     
==========================================
  Files        1201     1201              
  Lines      200454   200472      +18     
==========================================
- Hits       141992   141976      -16     
- Misses      58462    58496      +34     
Flag Coverage Δ
rust 70.82% <0.00%> (-0.02%) ⬇️

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

Impacted Files Coverage Δ
src/expr/src/expr/expr_udf.rs 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

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

Merged via the queue into main with commit 49b06e8 Apr 17, 2023
@lmatz lmatz deleted the fix-expr-udf-eval-row branch April 17, 2023 15:15
Copy link
Contributor

@wangrunji0408 wangrunji0408 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. 🥵

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.

bug(UdfExpression): panic on unequal zip_eq
3 participants