From 63cb4d0d56d918de103ac240e253db7b25239ed5 Mon Sep 17 00:00:00 2001 From: Dewey Dunnington Date: Tue, 12 Dec 2023 21:22:07 -0400 Subject: [PATCH] fix data frame dep --- r/geoarrow/DESCRIPTION | 3 +-- r/geoarrow/R/sf-compat.R | 3 ++- r/geoarrow/tests/testthat/test-sf-compat.R | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/r/geoarrow/DESCRIPTION b/r/geoarrow/DESCRIPTION index 27721b18..10525e46 100644 --- a/r/geoarrow/DESCRIPTION +++ b/r/geoarrow/DESCRIPTION @@ -27,7 +27,6 @@ Suggests: arrow, R6, sf, - testthat (>= 3.0.0), - tibble + testthat (>= 3.0.0) Remotes: nanoarrow=apache/arrow-nanoarrow/r diff --git a/r/geoarrow/R/sf-compat.R b/r/geoarrow/R/sf-compat.R index 8c752fad..f3282c6a 100644 --- a/r/geoarrow/R/sf-compat.R +++ b/r/geoarrow/R/sf-compat.R @@ -16,7 +16,8 @@ st_as_sfc.Array <- function(x, ..., promote_multi = FALSE) { } st_as_sf.ArrowTabular <- function(x, ..., promote_multi = FALSE) { - df <- tibble::as_tibble(x) + # Some Arrow as.data.frame() methods still return tibbles + df <- as.data.frame(as.data.frame(x)) is_geom <- vapply(df, inherits, logical(1), "geoarrow_vctr") df[is_geom] <- lapply(df[is_geom], sf::st_as_sfc, promote_multi = promote_multi) sf::st_as_sf(df, ...) diff --git a/r/geoarrow/tests/testthat/test-sf-compat.R b/r/geoarrow/tests/testthat/test-sf-compat.R index b26d2e15..2e398816 100644 --- a/r/geoarrow/tests/testthat/test-sf-compat.R +++ b/r/geoarrow/tests/testthat/test-sf-compat.R @@ -17,7 +17,7 @@ test_that("arrow package objects can be converted to and from sf objects", { skip_if_not_installed("arrow") sfc <- sf::st_sfc(sf::st_point(c(0, 1))) - sf <- sf::st_as_sf(tibble::tibble(geometry = sfc)) + sf <- sf::st_as_sf(data.frame(geometry = sfc)) vctr <- as_geoarrow_vctr(wk::wkt("POINT (0 1)")) array <- arrow::as_arrow_array(vctr) chunked <- arrow::as_chunked_array(array) @@ -30,19 +30,19 @@ test_that("arrow package objects can be converted to and from sf objects", { expect_identical(sf::st_as_sfc(chunked), sfc) expect_identical( sf::st_as_sf(table), - sf::st_as_sf(tibble::tibble(geometry = sfc)) + sf ) expect_identical( sf::st_as_sf(dataset), - sf::st_as_sf(tibble::tibble(geometry = sfc)) + sf ) expect_identical( sf::st_as_sf(scanner), - sf::st_as_sf(tibble::tibble(geometry = sfc)) + sf ) expect_identical( sf::st_as_sf(reader), - sf::st_as_sf(tibble::tibble(geometry = sfc)) + sf ) chunked2 <- arrow::as_chunked_array(sfc, type = arrow::as_data_type(na_extension_wkt()))