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

Robj to R choice #437

Merged
merged 20 commits into from
Nov 7, 2023
Merged

Robj to R choice #437

merged 20 commits into from
Nov 7, 2023

Conversation

sorhawell
Copy link
Collaborator

@sorhawell sorhawell commented Oct 20, 2023

This PR introduce internal conversion robj_to_rchoice() which takes any Robj and if char vec return first string value, other wise returning an Error explaining why this is not valid choice type.

The conversion is furthermore used to impl robj_to!(JoinType, how)? and robj_to!(ClosedWindow, closed_window)?. No match.arg(arg = ,choices = ,several.ok = ) will be needed on R side.

ok example
pl$LazyFrame()$join(pl$LazyFrame(), how = c("inner", "left", "outer", "semi", "anti", "cross"), on="tofu")

new err examples

> pl$LazyFrame()$join(pl$LazyFrame(), how = list(42), on="tofu")
Error: Execution halted with the following contexts
0: In R: in $join():
0: During function call [pl$LazyFrame()$join(pl$LazyFrame(), how = list(42), on = "tofu")]
1: The argument [how] caused an error
2: Got value [Rvalue: list!(42.0), Rsexp: List, Rclass: ["list"]]
3: Not a valid R choice because input is not a character vector

> pl$LazyFrame()$join(pl$LazyFrame(), how = "bob", on="tofu")
Error: Execution halted with the following contexts
0: In R: in $join():
0: During function call [pl$LazyFrame()$join(pl$LazyFrame(), how = "bob", on = "tofu")]
1: The argument [how] caused an error
2: Got value [JoinType choice ['bob'] is not any of 'cross', 'inner', 'left', 'outer', 'semi', 'anti']

@sorhawell sorhawell changed the title WIP: Robj to roption Robj to R choice Nov 5, 2023
@sorhawell sorhawell marked this pull request as ready for review November 5, 2023 23:15
src/rust/src/rdatatype.rs Outdated Show resolved Hide resolved
src/rust/src/rdatatype.rs Outdated Show resolved Hide resolved
tests/testthat/test-datatype.R Outdated Show resolved Hide resolved
tests/testthat/test-joins.R Outdated Show resolved Hide resolved
tests/testthat/test-joins.R Outdated Show resolved Hide resolved
@etiennebacher etiennebacher mentioned this pull request Nov 6, 2023
3 tasks
Copy link
Collaborator

@etiennebacher etiennebacher 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 @sorhawell !

@etiennebacher etiennebacher merged commit 6322b56 into main Nov 7, 2023
22 of 23 checks passed
@etiennebacher etiennebacher deleted the robj_to_roption branch November 7, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants