Skip to content

Commit

Permalink
fix: make_ijx_dimnames, allow for name creation and remove temp tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed2uiz committed Jul 12, 2024
1 parent 1c1cf8a commit 4fd3dfa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/dbMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,8 @@ save <- function(dbMatrix, name = '', overwrite = FALSE, ...){
#' @param colName_i name of column rownames to add to database
#' @param colName_j name of column colnames to add to database
#' @param overwrite whether to overwrite if table already exists in database
#' default: 'FALSE'.
#' default: 'FALSE'.'
#' @keywords internal
.make_ijx_dimnames <- function(dbMatrix,
name,
overwrite = FALSE,
Expand All @@ -1151,13 +1152,15 @@ save <- function(dbMatrix, name = '', overwrite = FALSE, ...){
con,
data.frame(i = seq_along(dimnames[[1]]), colName_i = dimnames[[1]]),
overwrite = TRUE,
name = "tmp_dimnames1",
temporary = TRUE
)

dimnames2_tbl <- dplyr::copy_to(
con,
data.frame(j = seq_along(dimnames[[2]]), colName_j = dimnames[[2]]),
overwrite = TRUE,
name = "tmp_dimnames2",
temporary = TRUE
)

Expand All @@ -1172,13 +1175,13 @@ save <- function(dbMatrix, name = '', overwrite = FALSE, ...){
x
) |>
dplyr::compute(
name = "dbMatrixWithDimnames",
name = name,
temporary = TRUE,
overwrite = overwrite
)

# DBI::dbRemoveTable(con, "dimnames1")
# DBI::dbRemoveTable(con, "dimnames2")
DBI::dbRemoveTable(con, "tmp_dimnames1")
DBI::dbRemoveTable(con, "tmp_dimnames2")

return(res)

Expand Down

0 comments on commit 4fd3dfa

Please sign in to comment.