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

Exclude dict_id and dict_is_ordered from equality comparison of Field #1647

Merged
merged 5 commits into from
May 8, 2022

Conversation

viirya
Copy link
Member

@viirya viirya commented May 4, 2022

Which issue does this PR close?

Closes #1646.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label May 4, 2022
@codecov-commenter
Copy link

codecov-commenter commented May 4, 2022

Codecov Report

Merging #1647 (f691812) into master (22e9f95) will increase coverage by 0.06%.
The diff coverage is 73.33%.

@@            Coverage Diff             @@
##           master    #1647      +/-   ##
==========================================
+ Coverage   83.02%   83.09%   +0.06%     
==========================================
  Files         193      193              
  Lines       55612    55894     +282     
==========================================
+ Hits        46174    46447     +273     
- Misses       9438     9447       +9     
Impacted Files Coverage Δ
arrow/src/datatypes/field.rs 56.43% <73.33%> (+1.51%) ⬆️
parquet/src/encodings/encoding.rs 93.37% <0.00%> (-0.19%) ⬇️
arrow/src/array/transform/mod.rs 86.57% <0.00%> (-0.12%) ⬇️
arrow/src/ffi.rs 88.51% <0.00%> (ø)
arrow/src/array/mod.rs 100.00% <0.00%> (ø)
arrow/src/array/builder.rs 86.79% <0.00%> (ø)
arrow/src/array/iterator.rs 96.11% <0.00%> (ø)
arrow/src/array/equal/mod.rs 96.09% <0.00%> (ø)
arrow/src/array/equal_json.rs 89.70% <0.00%> (ø)
arrow/src/compute/kernels/concat.rs 100.00% <0.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 22e9f95...f691812. Read the comment docs.

@@ -27,7 +28,7 @@ use super::DataType;
/// Contains the meta-data for a single relative type.
///
/// The `Schema` object is an ordered collection of `Field` objects.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Serialize, Deserialize, Debug, Clone, PartialOrd, Ord)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to also implement PartialOrd??

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, okay, I just considered equality comparison case, I think it is mostly common. Not sure when exact order between Field would be needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there might be funkiness if PartialOrd and PartialEq have different ideas of equality?

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, make sense. Let me update this. Thanks.


impl Ord for Field {
fn cmp(&self, other: &Self) -> Ordering {
let mut ord = self.name.cmp(other.name());
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use https://doc.rust-lang.org/std/cmp/enum.Ordering.html#method.then to make this shorter, but this is also fine

@@ -39,6 +41,50 @@ pub struct Field {
metadata: Option<BTreeMap<String, String>>,
}

impl PartialEq for Field {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could probably do with a comment to say why we are implementing these instead of an auto-derive

self.metadata.hash(state);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a simple test?

@alamb
Copy link
Contributor

alamb commented May 6, 2022

cc @jhorstmann

@viirya viirya merged commit f74ad34 into apache:master May 8, 2022
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.

Exclude dict_id and dict_is_ordered from equality comparison of Field
4 participants