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

Minor: move resolve_overlap a method on OrderingEquivalenceClass #14138

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jan 15, 2025

Which issue does this PR close?

Rationale for this change

I am testing out a change to the internal representation of OrderingEquivalenceClass in #14136 and this method turns out to basically be an implementation detail.

To make the job easier, let's make it a method on OrderingEquivalenceClass

What changes are included in this PR?

  1. move resolve_overlap a method on OrderingEquivalenceClass

Are these changes tested?

By CI

Are there any user-facing changes?

No, this is entirely code movement

@github-actions github-actions bot added the physical-expr Physical Expressions label Jan 15, 2025
/// Trims `orderings[idx]` if some suffix of it overlaps with a prefix of
/// `orderings[pre_idx]`. Returns `true` if there is any overlap, `false` otherwise.
///
/// For example, if `orderings[idx]` is `[a ASC, b ASC, c DESC]` and
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also added a small example

@alamb alamb marked this pull request as ready for review January 15, 2025 20:49
Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

Thanks @alamb

@jayzhan211 jayzhan211 merged commit e58c27b into apache:main Jan 16, 2025
25 checks passed
@alamb alamb deleted the alamb/refactor_resolve_overlap branch January 16, 2025 10:40
fn resolve_overlap(&mut self, idx: usize, pre_idx: usize) -> bool {
let length = self.orderings[idx].len();
let other_length = self.orderings[pre_idx].len();
for overlap in 1..=length.min(other_length) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW I think this is a very hot path in the particular queries. as it is something like O(N^3) in the number of potential sort orders. I am still investigating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants