Skip to content

Commit 1e26cc1

Browse files
thisisnicnealrichardson
authored andcommitted
ARROW-13037: [R] Incorrect param when creating Expression crashes R
Closes apache#10584 from thisisnic/ARROW_13037-expression_crash Authored-by: Nic Crane <thisisnic@gmail.com> Signed-off-by: Neal Richardson <neal.p.richardson@gmail.com>
1 parent ad5dc82 commit 1e26cc1

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

r/R/expression.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ Expression$create <- function(function_name,
104104
args = list(...),
105105
options = empty_named_list()) {
106106
assert_that(is.string(function_name))
107+
assert_that(is_list_of(args, "Expression"), msg = "Expression arguments must be Expression objects")
107108
compute___expr__call(function_name, args, options)
108109
}
110+
109111
Expression$field_ref <- function(name) {
110112
assert_that(is.string(name))
111113
compute___expr__field_ref(name)

r/tests/testthat/test-expression.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ test_that("C++ expressions", {
5858
)
5959
# Interprets that as a list type
6060
expect_r6_class(f == c(1L, 2L), "Expression")
61+
62+
expect_error(
63+
Expression$create("add", 1, 2),
64+
"Expression arguments must be Expression objects"
65+
)
66+
6167
})

0 commit comments

Comments
 (0)