Skip to content

Commit

Permalink
dbAppendTableArrow
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 23, 2023
1 parent 410a6bd commit 474a067
Show file tree
Hide file tree
Showing 28 changed files with 228 additions and 15 deletions.
8 changes: 5 additions & 3 deletions R/11-dbAppendTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#' The `dbAppendTable()` method assumes that the table has been created
#' beforehand, e.g. with [dbCreateTable()].
#' The default implementation calls [sqlAppendTableTemplate()] and then
#' [dbExecute()] with the `param` argument. Backends compliant to
#' [dbExecute()] with the `param` argument.
#' Use [dbAppendTableArrow()] to append data from an Arrow stream.
#'
#' Backends compliant to
#' ANSI SQL 99 which use `?` as a placeholder for prepared queries don't need
#' to override it. Backends with a different SQL syntax which use `?`
#' as a placeholder for prepared queries can override [sqlAppendTable()].
Expand All @@ -14,8 +17,7 @@
#' Process the values with [sqlRownamesToColumn()] before calling this method.
#'
#' @inheritParams dbReadTable
#' @param value For `dbAppendTable()`, a [data.frame] (or coercible to data.frame).
#' For `dbAppendTableArrow()`, an object coercible to an Arrow RecordBatchReader.
#' @param value A [data.frame] (or coercible to data.frame).
#' @param row.names Must be `NULL`.
#' @inheritParams sqlAppendTableTemplate
#'
Expand Down
28 changes: 26 additions & 2 deletions R/21-dbAppendTableArrow.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
#' @name dbAppendTable
#' @aliases dbAppendTableArrow
#' Insert rows into a table from an Arrow stream
#'
#' The `dbAppendTableArrow()` method assumes that the table has been created
#' beforehand, e.g. with [dbCreateTableArrow()].
#' The default implementation calls [dbAppendTable()] for each chunk
#' of the stream.
#' Use [dbAppendTable()] to append data from a data.frame.
#'
#' @inheritParams dbReadTable
#' @param value An object coercible with [nanoarrow::as_nanoarrow_array_stream()].
#' @inheritParams sqlAppendTableTemplate
#'
#' @template methods
#' @templateVar method_name dbAppendTableArrow
#'
#' @inherit DBItest::spec_arrow_append_table_arrow return
#' @inheritSection DBItest::spec_arrow_append_table_arrow Failure modes
#' @inheritSection DBItest::spec_arrow_append_table_arrow Specification
#'
#' @family DBIConnection generics
#' @export
#' @examplesIf requireNamespace("RSQLite", quietly = TRUE) && requireNamespace("nanoarrow", quietly = TRUE)
#' con <- dbConnect(RSQLite::SQLite(), ":memory:")
#' dbCreateTableArrow(con, "iris", iris[0, ])
#' dbAppendTableArrow(con, "iris", iris[1:5, ])
#' dbReadTable(con, "iris")
#' dbDisconnect(con)
setGeneric("dbAppendTableArrow",
def = function(conn, name, value, ...) standardGeneric("dbAppendTableArrow")
)
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ reference:
- dbReadTableArrow
- dbWriteTableArrow
- dbCreateTableArrow
- dbAppendTableArrow

- title: Classes
desc: S4 classes defined by DBI.
Expand Down
1 change: 1 addition & 0 deletions man/DBIConnection-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions man/dbAppendTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

163 changes: 163 additions & 0 deletions man/dbAppendTableArrow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbCreateTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbCreateTableArrow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbDataType.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbDisconnect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbExecute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbExistsTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbGetException.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbGetInfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbGetQuery.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbIsReadOnly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbIsValid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbListFields.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dbListObjects.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 474a067

Please sign in to comment.