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

Clean the code in field.rs and add more tests #2345

Merged
merged 4 commits into from
Aug 10, 2022

Conversation

HaoYang670
Copy link
Contributor

@HaoYang670 HaoYang670 commented Aug 7, 2022

Signed-off-by: remzi 13716567376yh@gmail.com

Which issue does this PR close?

None.

Rationale for this change

  1. Make the code clearer
  2. Improve the test coverage

What changes are included in this PR?

  1. Rewrite some code of fn _field, fn to_json, fn try_merge and fn contains
  2. Add tests for fn contains

Are there any user-facing changes?

No.

Signed-off-by: remzi <13716567376yh@gmail.com>
@github-actions github-actions bot added the arrow Changes to the arrow crate label Aug 7, 2022
@@ -698,41 +684,25 @@ impl Field {
/// * self.metadata is a superset of other.metadata
/// * all other fields are equal
Copy link
Contributor Author

@HaoYang670 HaoYang670 Aug 7, 2022

Choose a reason for hiding this comment

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

I am not sure whether this is reasonable. For example,

let child_field1 = ...;
let child_field2 = ...;
let field1 = Struct(&child_field1);
let mut field2 = Struct(&child_field2);
field2.try_merge(field1).unwrap();
assert_eq!(false, field2.contains(field1))

As field2 has merged field1 into itself, I expect the field2 to contain field1.
However, you will find that the answer is false because field1 contains child_field1
but field2 contains child_field1 and child_field2.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure either -- can you possibly add this as a test (so that at least the behavior is documented and if we change it in the future we will also have to change the test)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

@HaoYang670
Copy link
Contributor Author

@alamb Please help to review if you have time. 😁

@alamb alamb changed the title Clean the code in field.rs and add more tests Clean the code in Field::contains and add more tests Aug 9, 2022
@alamb alamb changed the title Clean the code in Field::contains and add more tests Clean the code in field.rs and add more tests Aug 9, 2022
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 -- thanks @HaoYang670

}

#[test]
fn test_contains_nullable() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good check

}
if is_new_field {
nested_fields.push(from_field.clone());
match nested_fields
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree this is easier to read 👍

@@ -698,41 +684,25 @@ impl Field {
/// * self.metadata is a superset of other.metadata
/// * all other fields are equal
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure either -- can you possibly add this as a test (so that at least the behavior is documented and if we change it in the future we will also have to change the test)?

@HaoYang670
Copy link
Contributor Author

I am not sure either -- can you possibly add this as a test (so that at least the behavior is documented and if we change it in the future we will also have to change the test)?

Good concern. I will add. Please don't merge this now. Thank you.

@alamb
Copy link
Contributor

alamb commented Aug 9, 2022

marking as draft so we don't accidentally merge this until it is updated

@alamb alamb marked this pull request as draft August 9, 2022 13:15
Signed-off-by: remzi <13716567376yh@gmail.com>
@HaoYang670 HaoYang670 marked this pull request as ready for review August 9, 2022 13:17
Signed-off-by: remzi <13716567376yh@gmail.com>
Signed-off-by: remzi <13716567376yh@gmail.com>
@alamb alamb merged commit d4ad4b7 into apache:master Aug 10, 2022
@ursabot
Copy link

ursabot commented Aug 10, 2022

Benchmark runs are scheduled for baseline = 195d9c5 and contender = d4ad4b7. d4ad4b7 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

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.

3 participants