Skip to content

Commit

Permalink
Allowing spark sql to write non-temporary tables (#1514)
Browse files Browse the repository at this point in the history
Co-authored-by: Zac Davies <[email protected]>
  • Loading branch information
zacdav-db and Zac Davies authored Jun 11, 2024
1 parent 8f2fcb0 commit 1778bbc
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions R/backend-spark-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 1778bbc

Please sign in to comment.