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: window in scalar subquery returns wrong results #16567

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

xudong963
Copy link
Member

@xudong963 xudong963 commented Oct 8, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Because we introduced single to inner join optimization, so we don't need to maintain the method rewrite_uncorrelated_scalar_subquery instead of rewriting to single join directly.

Then we can solve the issue15977.

Note: select count(distinct a) over (partition by 1) from t1; PARTITION BY 1 is a special syntax that actually means no partitioning, i.e., all rows are treated as a partition. So partition by (select b from t2) is not semantic if it returns more than one row but if returns only one row, it's valid, meaning no partitioning.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@xudong963 xudong963 marked this pull request as draft October 8, 2024 08:47
@github-actions github-actions bot added the pr-bugfix this PR patches a bug in codebase label Oct 8, 2024
@databendlabs databendlabs deleted a comment from github-actions bot Oct 8, 2024
@databendlabs databendlabs deleted a comment from github-actions bot Oct 8, 2024
@xudong963 xudong963 force-pushed the fix_subquery_in_partition branch from 6f13914 to 092a5ab Compare October 9, 2024 08:34
@xudong963 xudong963 marked this pull request as ready for review October 9, 2024 08:56
@xudong963 xudong963 requested review from Dousir9 and sundy-li October 9, 2024 08:57
@Dousir9 Dousir9 added this pull request to the merge queue Oct 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 9, 2024
@xudong963 xudong963 added this pull request to the merge queue Oct 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 9, 2024
@xudong963 xudong963 added this pull request to the merge queue Oct 9, 2024
Merged via the queue into databendlabs:main with commit 530de62 Oct 9, 2024
77 checks passed
@xudong963 xudong963 deleted the fix_subquery_in_partition branch October 9, 2024 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: subquery in partition by clause return wrong result
2 participants