From 7efeebdd80deb79a28e737a09cc46b9c01bd0786 Mon Sep 17 00:00:00 2001 From: Zac Davies Date: Mon, 10 Jun 2024 22:11:16 -0700 Subject: [PATCH] Allowing spark sql to write non-temporary tables --- R/backend-spark-sql.R | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/R/backend-spark-sql.R b/R/backend-spark-sql.R index 8cd9288d1..cabb0d1c3 100644 --- a/R/backend-spark-sql.R +++ b/R/backend-spark-sql.R @@ -126,12 +126,8 @@ simulate_spark_sql <- function() simulate_dbi("Spark SQL") analyze = TRUE, in_transaction = FALSE) { - if (temporary) { - sql <- sql_values_subquery(con, values, types = types, lvl = 1) - db_compute(con, table, sql, overwrite = overwrite) - } else { - NextMethod() - } + sql <- sql_values_subquery(con, values, types = types, lvl = 1) + db_compute(con, table, sql, overwrite = overwrite, temporary = temporary) } #' @export @@ -146,14 +142,11 @@ simulate_spark_sql <- function() simulate_dbi("Spark SQL") analyze = TRUE, in_transaction = FALSE) { - if (!temporary) { - cli::cli_abort("Spark SQL only support temporary tables") - } - sql <- glue_sql2( con, "CREATE ", if (overwrite) "OR REPLACE ", - "TEMPORARY VIEW {.tbl {table}} AS \n", + if (temporary) "TEMPORARY VIEW" else "TABLE", + " {.tbl {table}} AS \n", "{.from {sql}}" ) DBI::dbExecute(con, sql)