Skip to content

Commit 1778bbc

Browse files
zacdav-dbZac Davies
andauthored
Allowing spark sql to write non-temporary tables (#1514)
Co-authored-by: Zac Davies <[email protected]>
1 parent 8f2fcb0 commit 1778bbc

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

R/backend-spark-sql.R

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,8 @@ simulate_spark_sql <- function() simulate_dbi("Spark SQL")
126126
analyze = TRUE,
127127
in_transaction = FALSE) {
128128

129-
if (temporary) {
130-
sql <- sql_values_subquery(con, values, types = types, lvl = 1)
131-
db_compute(con, table, sql, overwrite = overwrite)
132-
} else {
133-
NextMethod()
134-
}
129+
sql <- sql_values_subquery(con, values, types = types, lvl = 1)
130+
db_compute(con, table, sql, overwrite = overwrite, temporary = temporary)
135131
}
136132

137133
#' @export
@@ -146,14 +142,11 @@ simulate_spark_sql <- function() simulate_dbi("Spark SQL")
146142
analyze = TRUE,
147143
in_transaction = FALSE) {
148144

149-
if (!temporary) {
150-
cli::cli_abort("Spark SQL only support temporary tables")
151-
}
152-
153145
sql <- glue_sql2(
154146
con,
155147
"CREATE ", if (overwrite) "OR REPLACE ",
156-
"TEMPORARY VIEW {.tbl {table}} AS \n",
148+
if (temporary) "TEMPORARY VIEW" else "TABLE",
149+
" {.tbl {table}} AS \n",
157150
"{.from {sql}}"
158151
)
159152
DBI::dbExecute(con, sql)

0 commit comments

Comments
 (0)