Skip to content

Commit

Permalink
dbCreateTableArrow
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 23, 2023
1 parent d6e0b45 commit f846693
Show file tree
Hide file tree
Showing 27 changed files with 198 additions and 12 deletions.
2 changes: 2 additions & 0 deletions R/12-dbCreateTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' The default `dbCreateTable()` method calls [sqlCreateTable()] and
#' [dbExecute()].
#' Use [dbCreateTableArrow()] to create a table from an Arrow schema.
#'
#' Backends compliant to ANSI SQL 99 don't need to override it.
#' Backends with a different SQL syntax can override `sqlCreateTable()`,
#' backends with entirely different ways to create tables need to
Expand Down
33 changes: 30 additions & 3 deletions R/22-dbCreateTableArrow.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
#' @name dbCreateTable
#' @aliases dbCreateTableArrow
#' @param value An object coercible to an Arrow RecordBatchReader.
#' Create a table in the database based on an Arrow object
#'
#' The default `dbCreateTableArrow()` method determines the R data types
#' of the Arrow schema associated with the Arrow object,
#' and calls [dbCreateTable()].
#' Backends who implement [dbAppendTableArrow()] should typically
#' also implement this generic.
#' Use [dbCreateTable()] to create a table from the column types
#' as defined in a data frame.
#'
#' @param value An object for which a schema can be determined via
#' [nanoarrow::infer_nanoarrow_schema()].
#' @inheritParams dbReadTable
#' @inheritParams sqlCreateTable
#'
#' @inherit DBItest::spec_arrow_create_table_arrow return
#' @inheritSection DBItest::spec_arrow_create_table_arrow Failure modes
#' @inheritSection DBItest::spec_arrow_create_table_arrow Additional arguments
#' @inheritSection DBItest::spec_arrow_create_table_arrow Specification
#'
#' @template methods
#' @templateVar method_name dbCreateTableArrow
#'
#' @family DBIConnection generics
#' @export
#' @examplesIf requireNamespace("RSQLite", quietly = TRUE) && requireNamespace("nanoarrow", quietly = TRUE)
#' con <- dbConnect(RSQLite::SQLite(), ":memory:")
#' ptype <- data.frame(a = numeric())
#' dbCreateTableArrow(con, "df", nanoarrow::infer_nanoarrow_schema(ptype))
#' dbReadTable(con, "df")
#' dbDisconnect(con)
setGeneric("dbCreateTableArrow",
def = function(conn, name, value, ...) standardGeneric("dbCreateTableArrow")
)
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ reference:
contents:
- dbReadTableArrow
- dbWriteTableArrow
- dbCreateTableArrow

- 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.

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

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

16 changes: 7 additions & 9 deletions man/dbCreateTable.Rd

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

136 changes: 136 additions & 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.

1 change: 1 addition & 0 deletions man/dbListResults.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/dbListTables.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/dbReadTable.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/dbReadTableArrow.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/dbRemoveTable.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/dbSendQuery.Rd

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

Loading

0 comments on commit f846693

Please sign in to comment.