Skip to content

Commit

Permalink
Merge branch 'main' into date_count_between
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn authored Jul 6, 2024
2 parents 19bd18b + 860bd6a commit 08ffbeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* `across(everything())` doesn't select grouping columns created via `.by` in
`summarise()` (@mgirlich, #1493).
* New translations of clock function `date_count_between()` for SQL server, Redshift, Snowflake, Postgres, and Spark (@edward-burn, #1495).
* Spark SQL backend now supports persisting tables with
`compute(x, name = I("x.y.z"), temporary = FALSE)` (@zacdav-db, #1502).

# dbplyr 2.5.0

Expand Down
15 changes: 4 additions & 11 deletions R/backend-spark-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,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 @@ -158,14 +154,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 08ffbeb

Please sign in to comment.