Skip to content

ARROW-9187: [R] Add bindings for arithmetic kernels - #8947

Closed
nealrichardson wants to merge 33 commits into
apache:masterfrom
nealrichardson:arithmetic-expressions
Closed

ARROW-9187: [R] Add bindings for arithmetic kernels#8947
nealrichardson wants to merge 33 commits into
apache:masterfrom
nealrichardson:arithmetic-expressions

Conversation

@nealrichardson

Copy link
Copy Markdown
Member

Based on ARROW-10322

@github-actions

Copy link
Copy Markdown

@nealrichardson
nealrichardson marked this pull request as ready for review December 29, 2020 18:34
Comment threadr/R/expression.R Outdated
Comment threadr/R/expression.R Outdated
Comment threadr/R/expression.R Outdated
Comment threadr/R/expression.R Outdated
Comment threadr/R/expression.R Outdated
Comment threadr/tests/testthat/test-dplyr.R Outdated

expect_dplyr_equal(
input %>%
filter(dbl %/% 2 > 3) %>%

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

All these test are with dbl; should we add some with int or other columns? Or do you think the other types are better tested elsewhere (test-compute-arith.R) and this is really just testing the dplyr NSE?

Comment threadr/tests/testthat/test-compute-arith.R Outdated
Comment threadr/tests/testthat/test-compute-arith.R Outdated
Comment threadr/R/expression.R Outdated
Comment threadr/R/expression.R Outdated
return(out)
}

# hack to use subtract instead of subtract_checked for timestamps

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Why only subtract?

And technically this could also be else if from above

Comment threadr/R/expression.R Outdated
b <- Scalar$create(Sys.time())
result <- a - b
expect_is(result$type, "DataType")
expect_identical(result$type$ToString(), "duration[us]")

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

(1) I don't think this is right. timestamp + integer = timestamp, but because integer is cast to timestamp, you get duration.
(1b) Maybe you could support that by casting the integer to duration (same units as the timestamp), but this is a bunch of stuff that should probably get handled in C++
(2) According to https://arrow.apache.org/docs/r/articles/arrow.html#arrow-to-r, we don't support converting duration types to R.

Given this, I think arithmetic with dates/times/timestamps should be punted to its own JIRA.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, I've made ARROW-11090 — I'm honestly not sure these tests are even worth keeping + skipping with that since we will almost certainly make better support for durations (and other time-related types that don't have as much support) arrow > R at that point.

Comment threadr/tests/testthat/test-dataset.R Outdated
Comment threadr/tests/testthat/test-dplyr.R Outdated
Comment threadr/R/expression.R Outdated
@nealrichardson

Copy link
Copy Markdown
MemberAuthor

Rebase wasn't clean so I opened #9117 with the commits cherry-picked.

nealrichardson added a commit that referenced this pull request Jan 7, 2021
Replaces #8947@jonkeaneCloses#9117 from nealrichardson/arith2
Lead-authored-by: Jonathan Keane <jkeane@gmail.com>
Co-authored-by: Neal Richardson <neal.p.richardson@gmail.com>
Signed-off-by: Neal Richardson <neal.p.richardson@gmail.com>
Sign up for freeto 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.

3 participants

@nealrichardson@jonkeane@bkietz