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

Implement PartialOrd or Expr #1014

Closed
alamb opened this issue Sep 17, 2021 · 2 comments · Fixed by #1015
Closed

Implement PartialOrd or Expr #1014

alamb opened this issue Sep 17, 2021 · 2 comments · Fixed by #1015
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Sep 17, 2021

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
We want to ordering Exprs in a consistent way in our tests. See details on https://github.com/influxdata/influxdb_iox/pull/2564 in https://github.com/influxdata/influxdb_iox/pull/2564#discussion_r710817261

This also is a necessary (but not sufficient) step towards being able to use Exprs in sets and maps (still need to implement Ord and Hash) which might have helped @waynexia in #792 with CSE and would help with other algebriac transformations in the future.

Describe the solution you'd like
impl PartialOrd for Expr

Describe alternatives you've considered
None

Additional context
None

@alamb alamb added the enhancement New feature or request label Sep 17, 2021
@waynexia
Copy link
Member

Thanks, @alamb. That's a good point to have PartialOrd on Expr.

For the CSE use case, it would be nice if we can compare and arrange Exprs in some kinds of order. By doing that we can recognize a+b and b+a are the same expression. And I think it can help other things too.

@alamb
Copy link
Contributor Author

alamb commented Sep 17, 2021

For the CSE use case, it would be nice if we can compare and arrange Exprs in some kinds of order. By doing that we can recognize a+b and b+a are the same expression. And I think it can help other things too.

That is a good point @waynexia -- I think one common approach is typically called "normalization" (aka rewrite all expressions so logically equivalent expressions like a+b and b+a end up with the same actual Expr form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants