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

Add hash support for PhysicalExpr and PhysicalSortExpr #6625

Merged
merged 17 commits into from
Jun 13, 2023
Merged

Add hash support for PhysicalExpr and PhysicalSortExpr #6625

merged 17 commits into from
Jun 13, 2023

Conversation

mustafasrepo
Copy link
Contributor

@mustafasrepo mustafasrepo commented Jun 10, 2023

Which issue does this PR close?

Closes #.

Rationale for this change

In the discussion @alamb suggested to implement dyn_hash method so that we can add support for hashing to traits. In this PR by using his suggestions we added support for hashing to PhysicalExpr and PhysicalSortExpr . This enables us to use HashSet inside EquivalentClass . Hence logic is simplified a bit in EquivalentClass and EquivalenceProperties implementation.

What changes are included in this PR?

Are these changes tested?

This is a refactor, existing tests should be sufficient.

Are there any user-facing changes?

We add fn dyn_hash(&self, _state: &mut dyn Hasher); method to the PhysicalExpr trait.

mustafasrepo and others added 16 commits May 26, 2023 14:24
# Conflicts:
#	datafusion/core/src/physical_plan/windows/mod.rs
#	datafusion/physical-expr/src/equivalence.rs
# Conflicts:
#	datafusion/physical-expr/src/equivalence.rs
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
# Conflicts:
#	datafusion/physical-expr/src/equivalence.rs
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.

Thank you @mustafasrepo -- this looks really neat. I think it would be best if we could remove the panic's (via unimplemented) if possible

@@ -39,7 +40,7 @@ pub struct EquivalenceProperties<T = Column> {
schema: SchemaRef,
}

impl<T: PartialEq + Clone> EquivalenceProperties<T> {
impl<T: Eq + Clone + Hash> EquivalenceProperties<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

datafusion/physical-expr/src/expressions/cast.rs Outdated Show resolved Hide resolved
datafusion/physical-expr/src/expressions/cast.rs Outdated Show resolved Hide resolved
datafusion/physical-expr/src/expressions/in_list.rs Outdated Show resolved Hide resolved
datafusion/physical-expr/src/scalar_function.rs Outdated Show resolved Hide resolved
datafusion/physical-expr/src/physical_expr.rs Show resolved Hide resolved
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.

LGTM -- thank you @mustafasrepo. This is a nice change I think

@alamb alamb merged commit 065dba7 into apache:main Jun 13, 2023
@mustafasrepo mustafasrepo deleted the feature/remove_ordered_column branch June 13, 2023 05:39
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.

3 participants