Learn R Programming

RPresto (version 1.4.7)

tbl.src_presto: dplyr integration to connect to a table in a database.

Description

Use src_presto to connect to an existing database, and tbl to connect to tables within that database. If you're unsure of the arguments to pass, please ask your database administrator for the values of these variables.

Automatically create a Presto remote database source to wrap around the PrestoConnection object via which DBI APIs can be called.

Usage

# S3 method for src_presto
tbl(src, from, ..., vars = NULL)

# S3 method for PrestoConnection tbl(src, from, ...)

# S3 method for src_presto copy_to( dest, df, name = deparse(substitute(df)), overwrite = FALSE, types = NULL, temporary = FALSE, unique_indexes = NULL, indexes = NULL, analyze = FALSE, ..., in_transaction = FALSE, with = NULL )

# S3 method for PrestoConnection copy_to( dest, df, name = deparse(substitute(df)), overwrite = FALSE, types = NULL, temporary = FALSE, unique_indexes = NULL, indexes = NULL, analyze = FALSE, ..., in_transaction = FALSE, with = NULL )

Arguments

src

A PrestoConnection object produced by DBI::dbConnect().

from

Either a string (giving a table name) or a literal dbplyr::sql() string.

...

Passed on to dbplyr::tbl_sql()

vars

Provide column names as a character vector to avoid retrieving them from the database.

dest

remote data source

df

local data frame

name

name for new remote table.

overwrite

If TRUE, will overwrite an existing table with name name. If FALSE, will throw an error if name already exists.

with

An optional WITH clause for the CREATE TABLE statement.

Examples

Run this code
if (FALSE) {
# First create a database connection with src_presto, then reference a tbl
# within that database
my_db <- src_presto(
  catalog = "memory",
  schema = "default",
  user = Sys.getenv("USER"),
  host = "http://localhost",
  port = 8080,
  session.timezone = "Asia/Kathmandu"
)
my_tbl <- tbl(my_db, "my_table")
}
if (FALSE) {
# First create a database connection, then reference a tbl within that
# database
my_con <- DBI::dbConnect(
  catalog = "memory",
  schema = "default",
  user = Sys.getenv("USER"),
  host = "http://localhost",
  port = 8080,
  session.timezone = "Asia/Kathmandu"
)
my_tbl <- tbl(my_con, "my_table")
}

Run the code above in your browser using DataLab