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 combine_join util to under equivalence.rs #7917

Merged
merged 3 commits into from
Oct 24, 2023
Merged

[Minor] Move combine_join util to under equivalence.rs #7917

merged 3 commits into from
Oct 24, 2023

Conversation

mustafasrepo
Copy link
Contributor

Which issue does this PR close?

Closes #.

Rationale for this change

Utils to construct join_equivalence and join_ordering_equivalence are move under equivalence.rs file. Computations regarding the equivalence and ordering equivalence are gathered in the equivalence.rs file. With this change code organization is bit better.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the physical-expr Physical Expressions label Oct 24, 2023
@@ -885,6 +885,240 @@ fn req_satisfied(given: LexOrderingRef, req: &[PhysicalSortRequirement]) -> bool
true
}

/// Combine equivalence properties of the given join inputs.
pub fn combine_join_equivalence_properties(
Copy link
Contributor Author

@mustafasrepo mustafasrepo Oct 24, 2023

Choose a reason for hiding this comment

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

This function is copy-pasted

}

/// Calculate equivalence properties for the given cross join operation.
pub fn cross_join_equivalence_properties(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is copy-pasted

///
/// This way; once we normalize an expression according to equivalence properties,
/// it can thereafter safely be used for ordering equivalence normalization.
fn get_updated_right_ordering_equivalent_class(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is copy pasted

Comment on lines +1048 to +1056
for left_ordering in left_oeq_class.iter() {
for right_ordering in updated_right_oeq.iter() {
let mut ordering = left_ordering.to_vec();
ordering.extend(right_ordering.to_vec());
let ordering_normalized =
join_eq_properties.normalize_sort_exprs(&ordering);
orderings.push(ordering_normalized);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously we were prefixing with left ordering. We now prefix with all of the orderings inside left equivalence. We no longer use left output_ordering. This is the only change. in this function.

Comment on lines +1099 to +1107
for right_ordering in right_oeg_class.iter() {
for left_ordering in left_oeq_class.iter() {
let mut ordering = right_ordering.to_vec();
ordering.extend(left_ordering.to_vec());
let ordering_normalized =
join_eq_properties.normalize_sort_exprs(&ordering);
orderings.push(ordering_normalized);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to above comment. However, in this case left orderings are prefixed with right orderings

@@ -1131,4 +1365,82 @@ mod tests {
}
Ok(())
}

#[test]
fn test_get_updated_right_ordering_equivalence_properties() -> Result<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test is copy-pasted

@github-actions github-actions bot added the core Core DataFusion crate label Oct 24, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

looks like a nice change to me -- thank you @mustafasrepo

@ozankabak ozankabak merged commit 8068d7f into apache:main Oct 24, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants