DBI Connector to Presto

Implements a 'DBI' compliant interface to Presto. Presto is an open source distributed SQL query engine for running interactive analytic queries against data sources of all sizes ranging from gigabytes to petabytes: < https://prestodb.io/>.

RPresto is a DBI-based adapter for the open source distributed SQL query engine Presto for running interactive analytic queries.


RPresto is both on CRAN and github. For the CRAN version, you can use


You can install the github development version via



The standard DBI approach works with RPresto:

con <- dbConnect(
res <- dbSendQuery(con, 'SELECT 1')
# dbFetch without arguments only returns the current chunk, so we need to
# loop until the query completes.
while (!dbHasCompleted(res)) {
    chunk <- dbFetch(res)
res <- dbSendQuery(con, 'SELECT CAST(NULL AS VARCHAR)')
# Due to the unpredictability of chunk sizes with presto, we do not support
# custom number of rows
# testthat::expect_error(dbFetch(res, 5))
# To get all rows using dbFetch, pass in a -1 argument
print(dbFetch(res, -1))
# An alternative is to use dbGetQuery directly
# `source` for iris.sql()
source(system.file('tests', 'testthat', 'utilities.R', package='RPresto'))
iris <- dbGetQuery(con, paste("SELECT * FROM", iris.sql()))

We also include dplyr integration.

db <- src_presto(
# Assuming you have a table like iris in the database
iris <- tbl(db, 'iris')
iris %>%
  group_by(species) %>%
  summarise(mean_sepal_length = mean(as(sepal_length, 0.0))) %>%
  arrange(species) %>%

How RPresto works

Presto exposes its interface via a REST based API1. We utilize the httr package to make the API calls and use jsonlite to reshape the data into a data.frame. Note that as of now, only read operations are supported.

RPresto has been tested on Presto 0.100.


RPresto is BSD-licensed. We also provide an additional patent grant.

[1] See https://github.com/prestodb/presto/wiki/HTTP-Protocol for a description of the API.


RPresto 1.3.3

  • Fix tests for compatibility with dbplyr 1.4.0.
  • Send headers with all http requests (#103).
  • Add support for as.<data_type> style casting for dplyr (#97).
  • Add Code of Conduct.

RPresto 1.3.2

  • Use the new delayed S3 registration mechanism in 3.6.0 for dplyr method implementations.
  • Bump minimum dplyr version required to 0.7.0.

RPresto 1.3.1

  • Presto now might return data in POST response (#89)
  • Presto now might not always return column information in each response (#93)
  • Better error message for unknown column types (#86, #87)
  • Adapt to presto changes for type casting translation (#88)
  • Add CHAR data type (#91)

RPresto 1.3.0

  • Fix Rcpp compilation under Windows (#79)
  • SET/RESET SESSION queries are now correctly respected when used under dbGetQuery. PrestoConnection no longer has parameters slot but dbConnect remains backward compatible. Manual change to parameter is still possible via [email protected]$setParameter() (#77)
  • Adapt to changes in dplyr version 0.7.0, mainly around the remote backend support being split to dbplyr. This should be backwards compatible back to dplyr 0.4.3 (#76)
  • Add support for the REAL data type (#70)
  • Allow specifying the connection source (#68)
  • Drop RCurl dependency (#67)
  • Return DECIMAL data types as characters as opposed to numeric's previously (#64, fixes #60)
  • Add support for new integer data types (INTEGER, SMALLINT, TINYINT) (#59, fixes #56)
  • Migrate the json to data.frame construction from pure R to Rcpp for 10x speed gains! (thanks @saurfang) (#57, #58)
  • Fix dbListFields to use the nextUri instead of infoUri (#55)
  • Don't drop data for duplicate column names (#53)

RPresto 1.2.1

  • Handle responses with no column information (fixes #49)
  • Add retries for GET and POST responses with error status codes
  • Skip test cases for ones that need locale modification if we cannot set the locale for the OS.
  • Adapt to changes in the upcoming dplyr and testthat versions.

RPresto 1.2.0

  • Add a session.timezone parameter to dbConnect and src_presto which defaults to UTC. This affects the timestamps returned for Presto data types "TIMESTAMP". We handle the ambiguity by assigning a time zone to every POSIXct column returned. Note that if you are doing as.character() directly on these columns, the values you obtain will be different from what happened before.
  • Fix the way we handle zero row multiple column query results. This will affect LIMIT 0 queries specifically.

RPresto 1.1.1

  • Minor dplyr related fixes
  • Drop the R version requirement from 3.1.1 to 3.1.0
  • Speed-up in binding chunks if dplyr is available.
  • Handle special values like Infinity, NaN.

RPresto 1.1.0

  • Add optional dplyr support. One can initiate a connection via src_presto.
  • Minor documentation fixes.

RPresto 1.0.0

  • Initial release to github

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.3.7 by Thomas J. Leeper, 3 months ago


Report a bug at https://github.com/prestodb/RPresto/issues

Browse source code at https://github.com/cran/RPresto

Authors: Onur Ismail Filiz [aut] , Sergey Goder [aut] , Thomas J. Leeper [ctb, cre] , John Myles White [ctb] , Jarod G.R. Meng [ctb]

Documentation:   PDF Manual  

Task views: Databases with R

BSD_3_clause + file LICENSE license

Imports DBI, httr, openssl, jsonlite, stringi, stats, Rcpp, utils, purrr

Depends on methods

Suggests testthat, dplyr, dbplyr

Linking to Rcpp

Suggested by resourcer.

See at CRAN