File: dbReadTableArrow.R

package info (click to toggle)
dbi 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,740 kB
  • sloc: makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#' Read database tables as Arrow objects
#'
#' @description
#' `r lifecycle::badge('experimental')`
#'
#' Reads a database table as an Arrow object.
#' Use [dbReadTable()] instead to obtain a data frame.
#'
#' @details
#' This function returns an Arrow object.
#' Convert it to a data frame with [as.data.frame()] or
#' use [dbReadTable()] to obtain a data frame.
#'
#' @template methods
#' @templateVar method_name dbReadTableArrow
#'
#' @inherit DBItest::spec_arrow_read_table_arrow return
#' @inheritSection DBItest::spec_arrow_read_table_arrow Failure modes
#' @inheritSection DBItest::spec_arrow_read_table_arrow Specification
#'
#' @inheritParams dbGetQuery
#' @inheritParams dbReadTable
#' @family DBIConnection generics
#' @export
#' @examplesIf requireNamespace("RSQLite", quietly = TRUE) && requireNamespace("nanoarrow", quietly = TRUE)
#' # Read data as Arrow table
#' con <- dbConnect(RSQLite::SQLite(), ":memory:")
#'
#' dbWriteTable(con, "mtcars", mtcars[1:10, ])
#' dbReadTableArrow(con, "mtcars")
#'
#' dbDisconnect(con)
setGeneric("dbReadTableArrow", def = function(conn, name, ...) {
  require_arrow()
  otel_local_active_span(
    "dbReadTableArrow",
    conn,
    label = .dbi_get_collection_name(name, conn),
    attributes = list(db.collection.name = .dbi_get_collection_name(name, conn))
  )
  standardGeneric("dbReadTableArrow")
})