Skip to content
6 changes: 6 additions & 0 deletions r/R/dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ open_dataset <- function(sources,
partitioning = hive_partition(),
unify_schemas = NULL,
...) {
# If you aren't explicit with the argument names it looks like everything
# works but it will create a segfault and crash the R session, this fixes it
if (any(class(schema) %in% "HivePartitioning")) {
partitioning <- schema
schema <- NULL
}
Comment thread
pachadotdev marked this conversation as resolved.
Outdated
if (is_list_of(sources, "Dataset")) {
if (is.null(schema)) {
if (is.null(unify_schemas) || isTRUE(unify_schemas)) {
Expand Down
14 changes: 14 additions & 0 deletions r/tests/testthat/test-dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ test_that("Hive partitioning", {
)
})

test_that("Hive partitioning without explicit argument name", {
Comment thread
pachadotdev marked this conversation as resolved.
Outdated
ds <- open_dataset(hive_dir, hive_partition(other = utf8(), group = uint8()))
expect_is(ds, "Dataset")
expect_equivalent(
ds %>%
filter(group == 2) %>%
select(chr, dbl) %>%
filter(dbl > 7 & dbl < 53) %>%
collect() %>%
arrange(dbl),
df2[1:2, c("chr", "dbl")]
)
})

test_that("Partitioning inference", {
# These are the same tests as above, just using the *PartitioningFactory
ds1 <- open_dataset(dataset_dir, partitioning = "part")
Expand Down