Skip to content

Commit

Permalink
row_number is hybridifyed on empty indices set. closes #3454
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Mar 26, 2018
1 parent da8d54e commit 71b8b54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hybrid_window.cpp
Expand Up @@ -35,10 +35,10 @@ Result* row_number(const RObject& data, const bool ascending) {
}

Result* row_number_prototype(SEXP call, const ILazySubsets& subsets, int nargs) {
if (nargs > 1 || subsets.size() == 0) return 0;

if (nargs == 0) return new RowNumber_0();

if (nargs > 1) return 0;

RObject data(CADR(call));
bool ascending = true;
if (TYPEOF(data) == LANGSXP && CAR(data) == Rf_install("desc")) {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-filter.r
Expand Up @@ -220,6 +220,13 @@ test_that("row_number does not segfault with example from #781", {
expect_equal(nrow(res), 0L)
})

test_that("row_number works on 0 length columns (#3454)", {
expect_identical(
mutate( tibble(), a = row_number()),
tibble(a=integer())
)
})

test_that("filter does not alter expression (#971)", {
my_filter <- ~ am == 1
expect_equal(my_filter[[2]][[2]], as.name("am"))
Expand Down

0 comments on commit 71b8b54

Please sign in to comment.