diff --git a/DESCRIPTION b/DESCRIPTION index aea28ca..fcfd51f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: pysparklyr Title: Provides a 'PySpark' Back-End for the 'sparklyr' Package -Version: 0.1.4.9003 +Version: 0.1.4.9004 Authors@R: c( person("Edgar", "Ruiz", , "edgar@posit.co", role = c("aut", "cre")), person(given = "Posit Software, PBC", role = c("cph", "fnd")) diff --git a/NEWS.md b/NEWS.md index fadd9ab..27dbab4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pysparklyr (dev) +* Adds support for `I()` in `tbl()` + * Fixes issues with having multiple line functions in `spark_apply()` * Ensures `arrow` is installed by adding it to Imports (#116) diff --git a/R/dplyr.R b/R/dplyr.R index 21cf7ba..77d91c3 100644 --- a/R/dplyr.R +++ b/R/dplyr.R @@ -122,7 +122,11 @@ sdf_copy_to.pyspark_connection <- function(sc, #' @export tbl.pyspark_connection <- function(src, from, ...) { - sql_from <- as.sql(from, con = src$con) + if(inherits(from, "AsIs")) { + sql_from <- from + } else { + sql_from <- as.sql(from, con = src$con) + } con <- python_conn(src) pyspark_obj <- con$table(sql_from) vars <- as.character(pyspark_obj$columns) diff --git a/tests/testthat/test-dplyr.R b/tests/testthat/test-dplyr.R index 41c3f67..6f0f18b 100644 --- a/tests/testthat/test-dplyr.R +++ b/tests/testthat/test-dplyr.R @@ -95,3 +95,13 @@ test_that("sdf_register() works", { "tbl_pyspark" ) }) + +test_that("I() works", { + tbl_mtcars <- use_test_table_mtcars() + sc <- use_test_spark_connect() + expect_s3_class({ + tbl(sc, I("mtcars")) %>% + head() %>% + collect() + }, "data.frame") +})