diff --git a/R/dim_names.R b/R/dim_names.R index b11ceef..12cabbe 100644 --- a/R/dim_names.R +++ b/R/dim_names.R @@ -69,14 +69,14 @@ union_dim_names <- function(x) { } intersect_dim_names <- function(x) { - purrr::modify(purrr::list_transpose(x), + purrr::modify(purrr::list_transpose(x, simplify = FALSE), function(x) { purrr::reduce(x, set_intersect) }) } diff_dim_names <- function(x) { - purrr::modify(purrr::list_transpose(x), + purrr::modify(purrr::list_transpose(x, simplify = FALSE), function(x) { purrr::reduce(x, set_diff) }) diff --git a/tests/testthat/test-rbind.R b/tests/testthat/test-rbind.R index f851e21..edea894 100644 --- a/tests/testthat/test-rbind.R +++ b/tests/testthat/test-rbind.R @@ -33,4 +33,30 @@ test_that("rbind.ddf_col() and rbind.tbl_ddf() work", { filter(axis1 %in% dimnames(ddf_col2)[["axis1"]], axis2 %in% dimnames(ddf_col2)[["axis2"]]), ddf_col2) + + # works when the number of key rows is 1 (#23) + data_1 <- tidyr::expand_grid(key = tibble::tibble(col_1 = 1, + col_2 = 1)) |> + tibble::add_column(value = 1) |> + dibble_by("key") + + data_2 <- tidyr::expand_grid(key = tibble::tibble(col_1 = 2:3, + col_2 = 2:3)) |> + tibble::add_column(value = 2) |> + dibble_by("key") + + data_3 <- tidyr::expand_grid(key = tibble::tibble(col_1 = 2, + col_2 = 2)) |> + tibble::add_column(value = 2) |> + dibble_by("key") + + data_4 <- tidyr::expand_grid(key = tibble::tibble(col_1 = 2, + col_2 = 2), + key_2 = tibble::tibble(col_1 = 2)) |> + tibble::add_column(value = 2) |> + dibble_by("key", "key_2") + + expect_no_error(broadcast(rbind(data_1, data_2), "key")) + expect_no_error(broadcast(rbind(data_1, data_3), "key")) + expect_no_error(broadcast(rbind(data_1, data_4), c("key", "key_2"))) })