From 1778bbc0f71321674e97b54bacc9384e9edb8732 Mon Sep 17 00:00:00 2001 From: Zac Davies <80654433+zacdav-db@users.noreply.github.com> Date: Tue, 11 Jun 2024 08:25:40 -0700 Subject: [PATCH] Allowing spark sql to write non-temporary tables (#1514) Co-authored-by: Zac Davies --- 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)