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

GH-38033: [R] Allow code() to return package name prefix. #38144

Merged
merged 17 commits into from
Oct 19, 2023

Conversation

orgadish
Copy link
Contributor

@orgadish orgadish commented Oct 9, 2023

Rationale for this change

#38033

What changes are included in this PR?

  • Added get_pkg_ns() helper.
  • Added call_name private method to DataType class to store the string name used in the code call. Refactored code() public method to use call_name.
  • Converted all $code() call(...) to $code(namespace = FALSE) call2(..., .ns = if(namespace) "arrow") in DataType, Schema, and DictionaryType.
  • Added code to Schema docstring.
  • Updated expect_code_roundtrip to test roundtrip with and without namespace, and check match/no match for arrow:: depending on namespace argument.

Are these changes tested?

  • All tests pass, including lintr checks.

Are there any user-facing changes?

Yes, user-facing changes, but no breaking changes to any public APIs.

@github-actions
Copy link

github-actions bot commented Oct 9, 2023

⚠️ GitHub issue #38033 has been automatically assigned in GitHub to PR creator.

@orgadish orgadish marked this pull request as ready for review October 12, 2023 07:10
@orgadish
Copy link
Contributor Author

@paleolimbot @thisisnic I believe the PR is ready for final review -- it's passing all my tests, including the new ones. Two notes/questions:

  1. map_of does not do a roundtrip because it's represented as list_of(struct(key, value)) instead of map_of(key, value). Should I change that in this PR?
  2. explicit_pkg_name seems like a very long argument name -- any ideas of how to shorten? Perhaps use_ns or with_ns (bool) to match the .ns argument (string) in call2?

Copy link
Member

@thisisnic thisisnic left a comment

Choose a reason for hiding this comment

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

Thanks for making this PR! I've added a few initial suggestions - will have a look at the tests in the next round of reviewing!

r/R/type.R Outdated Show resolved Hide resolved
r/R/type.R Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Oct 12, 2023
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 13, 2023
@orgadish
Copy link
Contributor Author

Testing on e0c655f:

test-schema.R
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 84 ]

test-type.R
[ FAIL 0 | WARN 0 | SKIP 1 | PASS 245 ]

── Skipped tests (1) ──────────────────────────────────────────
• Work around masking of data type functions (ARROW-12322)
  (1): test-type.R:116:3

@orgadish
Copy link
Contributor Author

orgadish commented Oct 13, 2023

Ran all tests on c0a80a9

[ FAIL 0 | WARN 8 | SKIP 32 | PASS 8149 ]

@thisisnic
Copy link
Member

The CI job which is failing is the one which runs the linter. If you run styler:::style_active_file() on the files that have changed, this will fix it.

Copy link
Member

@thisisnic thisisnic left a comment

Choose a reason for hiding this comment

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

Thanks for implementing the suggestions there; I've now had a chance to look at the tests and my comments are below. Let me know if you have any questions!

I really appreciate how thorough you've been with these tests, and it looks like you have covered a lot of ground, which is great!

While thorough unit testing is super important, we also have to balance that with maintainability, and the tests here contain lots of lines of code and new functions, which ultimately means that if something does break, it will take a chunk of cognitive effort to engage with as it's harder to skim and immediately get to exactly what's going on.

There's also a lot of ground which is already covered by the tests in expect_code_roundtrip().

Would you mind giving these tests a bit of a refactor, so that the focus is testing that the namespace argument works? It would probably be sufficient testing to write a single test which takes a schema containing fields of a few different types, calls the $code() method with the namespace argument set to TRUE and just checks that the returned code contains the arrow:: prefix.

If there's anything you've covered in your tests here that you think should be added to expect_code_roundtrip(), then that could either be added in in this PR, or for the sake of keeping things simple here we could open an issue for it so it can be done in another PR.

Thanks again for making this PR!

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Oct 14, 2023
…dding $code(namespace=TRUE) test into `expect_code_roundtrip()`.
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Oct 14, 2023
@orgadish
Copy link
Contributor Author

@thisisnic This is my first PR for a major project like this, so I appreciate your patience with me!

I had totally missed that the tests in test-data-type.R already covered $code(), and per your recommendation I was able to cover almost all the new code by reverting all my changes to testing and adding some changes for namespace=TRUE. Let me know if you think that's stretching too far beyond what's appropriate for this PR.

Copy link
Member

@thisisnic thisisnic left a comment

Choose a reason for hiding this comment

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

Looks good to me! I've pushed a couple of final changes to the branch to tweak phrasing and make sure the linter is happy, but otherwise, this is great. Thanks for making this change @orgadish!

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Oct 19, 2023
@thisisnic thisisnic merged commit a0e58f1 into apache:main Oct 19, 2023
10 checks passed
@thisisnic thisisnic removed the awaiting merge Awaiting merge label Oct 19, 2023
@orgadish orgadish deleted the OG_code_with_packagename branch October 19, 2023 19:04
@conbench-apache-arrow
Copy link

After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit a0e58f1.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.

JerAguilon pushed a commit to JerAguilon/arrow that referenced this pull request Oct 23, 2023
…ache#38144)

### Rationale for this change
apache#38033 

### What changes are included in this PR?
- ~~Added `get_pkg_ns()` helper.~~
- ~~Added `call_name` private method to `DataType` class to store the string name used in the code call. Refactored `code()` public method to use `call_name`.~~
- Converted all `$code() call(...)` to `$code(namespace = FALSE) call2(..., .ns = if(namespace) "arrow")` in `DataType`, `Schema`, and `DictionaryType`.
- Added `code` to `Schema` docstring.
- Updated `expect_code_roundtrip` to test roundtrip with and without namespace, and check match/no match for `arrow::` depending on namespace argument.

### Are these changes tested?
* All tests pass, including lintr checks.

### Are there any user-facing changes?
Yes, user-facing changes, but no breaking changes to any public APIs.
* Closes: apache#38033

Lead-authored-by: orgadish <48453207+orgadish@users.noreply.github.com>
Co-authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
JerAguilon pushed a commit to JerAguilon/arrow that referenced this pull request Oct 25, 2023
…ache#38144)

### Rationale for this change
apache#38033 

### What changes are included in this PR?
- ~~Added `get_pkg_ns()` helper.~~
- ~~Added `call_name` private method to `DataType` class to store the string name used in the code call. Refactored `code()` public method to use `call_name`.~~
- Converted all `$code() call(...)` to `$code(namespace = FALSE) call2(..., .ns = if(namespace) "arrow")` in `DataType`, `Schema`, and `DictionaryType`.
- Added `code` to `Schema` docstring.
- Updated `expect_code_roundtrip` to test roundtrip with and without namespace, and check match/no match for `arrow::` depending on namespace argument.

### Are these changes tested?
* All tests pass, including lintr checks.

### Are there any user-facing changes?
Yes, user-facing changes, but no breaking changes to any public APIs.
* Closes: apache#38033

Lead-authored-by: orgadish <48453207+orgadish@users.noreply.github.com>
Co-authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this pull request Nov 13, 2023
…ache#38144)

### Rationale for this change
apache#38033 

### What changes are included in this PR?
- ~~Added `get_pkg_ns()` helper.~~
- ~~Added `call_name` private method to `DataType` class to store the string name used in the code call. Refactored `code()` public method to use `call_name`.~~
- Converted all `$code() call(...)` to `$code(namespace = FALSE) call2(..., .ns = if(namespace) "arrow")` in `DataType`, `Schema`, and `DictionaryType`.
- Added `code` to `Schema` docstring.
- Updated `expect_code_roundtrip` to test roundtrip with and without namespace, and check match/no match for `arrow::` depending on namespace argument.

### Are these changes tested?
* All tests pass, including lintr checks.

### Are there any user-facing changes?
Yes, user-facing changes, but no breaking changes to any public APIs.
* Closes: apache#38033

Lead-authored-by: orgadish <48453207+orgadish@users.noreply.github.com>
Co-authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this pull request Feb 19, 2024
…ache#38144)

### Rationale for this change
apache#38033 

### What changes are included in this PR?
- ~~Added `get_pkg_ns()` helper.~~
- ~~Added `call_name` private method to `DataType` class to store the string name used in the code call. Refactored `code()` public method to use `call_name`.~~
- Converted all `$code() call(...)` to `$code(namespace = FALSE) call2(..., .ns = if(namespace) "arrow")` in `DataType`, `Schema`, and `DictionaryType`.
- Added `code` to `Schema` docstring.
- Updated `expect_code_roundtrip` to test roundtrip with and without namespace, and check match/no match for `arrow::` depending on namespace argument.

### Are these changes tested?
* All tests pass, including lintr checks.

### Are there any user-facing changes?
Yes, user-facing changes, but no breaking changes to any public APIs.
* Closes: apache#38033

Lead-authored-by: orgadish <48453207+orgadish@users.noreply.github.com>
Co-authored-by: Nic Crane <thisisnic@gmail.com>
Signed-off-by: Nic Crane <thisisnic@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[R] Option for $schema$code() to explicitly use package name
2 participants