diff --git a/r/R/dataset-factory.R b/r/R/dataset-factory.R index 30622b8a6d0..a772be544b0 100644 --- a/r/R/dataset-factory.R +++ b/r/R/dataset-factory.R @@ -27,6 +27,7 @@ DatasetFactory <- R6Class("DatasetFactory", inherit = ArrowObject, if (is.null(schema)) { dataset___DatasetFactory__Finish1(self, unify_schemas) } else { + assert_is(schema, "Schema") dataset___DatasetFactory__Finish2(self, schema) } }, diff --git a/r/R/dataset.R b/r/R/dataset.R index e990ff3cb86..3f7d117d6f6 100644 --- a/r/R/dataset.R +++ b/r/R/dataset.R @@ -75,6 +75,7 @@ open_dataset <- function(sources, } } # Enforce that all datasets have the same schema + assert_is(schema, "Schema") sources <- lapply(sources, function(x) { x$schema <- schema x diff --git a/r/tests/testthat/test-dataset.R b/r/tests/testthat/test-dataset.R index e84eb12b08a..2dbf9c5cbbb 100644 --- a/r/tests/testthat/test-dataset.R +++ b/r/tests/testthat/test-dataset.R @@ -194,6 +194,12 @@ test_that("Hive partitioning", { ) }) +test_that("input validation", { + expect_error( + open_dataset(hive_dir, hive_partition(other = utf8(), group = uint8())) + ) +}) + test_that("Partitioning inference", { # These are the same tests as above, just using the *PartitioningFactory ds1 <- open_dataset(dataset_dir, partitioning = "part")