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 Ord for DataType #4920

Closed
wants to merge 1 commit into from
Closed

Conversation

ch-sc
Copy link
Contributor

@ch-sc ch-sc commented Oct 11, 2023

Which issue does this PR close?

Closes #4919 (Compare DataType based on memory size).

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

These changes will alter the way DataType is ordered. Users who rely on the current ordering, which is just the basic derived implementation for Ord, might be affected.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 11, 2023
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

As this behaviour is extremely use-case specific, I think it might be better implemented in DataFusion, perhaps using the newtype pattern - https://doc.rust-lang.org/rust-by-example/generics/new_types.html

This would also resolve the issue with this PR where the implementation of Eq differs from Ord, which is prohibited by the traits

if a.is_primitive() && b.is_primitive() {
self.primitive_width()
.unwrap_or(0)
.cmp(&other.primitive_width().unwrap_or(0))
Copy link
Contributor

Choose a reason for hiding this comment

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

This is inconsistent with the implementation of Eq and is therefore ill-formed

@ch-sc
Copy link
Contributor Author

ch-sc commented Oct 11, 2023

Thanks for your feedback @tustvold. I'll do it in DataFusion

@ch-sc ch-sc closed this Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compare DataType based on memory size
2 participants