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): fix SOME/ALL/ANY expression #14221

Merged
merged 6 commits into from
Dec 27, 2023
Merged

fix(expr): fix SOME/ALL/ANY expression #14221

merged 6 commits into from
Dec 27, 2023

Conversation

wangrunji0408
Copy link
Contributor

@wangrunji0408 wangrunji0408 commented Dec 26, 2023

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

What's changed and what's your intention?

fix #14214, which was introduced by #13402.

 dev=> select a = any(b) from (values (1, array[1,2]), (1, array[2,1])) as t(a, b);
  ?column? 
 ----------
  t
- f
+ t
 (2 rows)

 dev=> select a = all(b) from (values (1, array[2,3]), (1, array[1])) as t(a, b);
  ?column? 
 ----------
  f
- f
+ t
 (2 rows)

When short-circuit occurred, the resolve_bools function did not consume all items in the input iterator, causing subsequent booleans to be misaligned.

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

Fixes the correctness of SOME/ALL/ANY expressions. The fix introduces a breaking change for versions from v1.5.0 to v1.5.3. It is recommended to drop and recreate any materialized views that contain SOME/ALL/ANY expressions.

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

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@wangrunji0408 wangrunji0408 added this pull request to the merge queue Dec 27, 2023
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.

I'm worrying that the fix will lead to similar compatibility issue like #13890. 😕

Comment on lines -168 to +173
Some(num) => self.resolve_bools(func_results_iter.by_ref().take(num)),
Some(num) => {
let range = offset..offset + num;
offset += num;
self.resolve_bools(range.map(|i| bools.value_at(i)))
}
Copy link
Member

Choose a reason for hiding this comment

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

So the actual bug is that we mistakenly expect resolve_bools to exhaust the passed-in iterator, right? This is quite subtle. 🤣 Could you please add some comments to elaborate this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I didn't realize the passed-in iterator is actually a reference. This is a bad practice. 🤪

@BugenZhao BugenZhao removed this pull request from the merge queue due to a manual request Dec 27, 2023
@wangrunji0408
Copy link
Contributor Author

CI found a bug in EOWC. Looks like unrelated to this PR. cc @stdrc

https://buildkite.com/risingwavelabs/pull-request/builds/38146#018ca931-39a8-44af-8d77-40cb0b2cc022/261-550

failed to run `e2e_test/streaming/temporal_join/temporal_join_watermark.slt`
Caused by:
    query result mismatch:
    [SQL] select * from eowc_mv;
    [Diff] (-expected|+actual)
    -   2023-09-14 06:00:00+00:00 1
    at e2e_test/streaming/temporal_join/temporal_join_watermark.slt:42

Signed-off-by: Runji Wang <[email protected]>
@wangrunji0408 wangrunji0408 added this pull request to the merge queue Dec 27, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 27, 2023
@wangrunji0408 wangrunji0408 added this pull request to the merge queue Dec 27, 2023
Merged via the queue into main with commit 4695ad1 Dec 27, 2023
28 of 29 checks passed
@wangrunji0408 wangrunji0408 deleted the wrj/fix-some branch December 27, 2023 10:25
github-actions bot pushed a commit that referenced this pull request Dec 27, 2023
lmatz pushed a commit that referenced this pull request Dec 27, 2023
Signed-off-by: Runji Wang <[email protected]>
Co-authored-by: Runji Wang <[email protected]>
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: ANY expression give a wrong result.
4 participants