Learn R Programming

RPresto (version 1.3.5)

dbGetInfo,PrestoDriver-method: Metadata about database objects

Description

Metadata about database objects

For the '>PrestoResult object, the implementation returns the additional stats field which can be used to implement things like progress bars. See the examples section.

Usage

# S4 method for PrestoDriver
dbGetInfo(dbObj)

# S4 method for PrestoConnection dbGetInfo(dbObj)

# S4 method for PrestoResult dbGetInfo(dbObj)

Arguments

dbObj

A '>PrestoDriver, '>PrestoConnection or '>PrestoResult object

Value

[PrestoResult] A list with elements

statement

The SQL sent to the database

row.count

Number of rows fetched so far

has.completed

Whether all data has been fetched

stats

Current stats on the query

Examples

Run this code
# NOT RUN {
  conn <- dbConnect(Presto(), 'localhost', 7777, 'onur', 'datascience')
  result <- dbSendQuery(conn, 'SELECT * FROM jonchang_iris')
  iris <- data.frame()
  progress.bar <- NULL
  while (!dbHasCompleted(result)) {
    chunk <- dbFetch(result)
    if (!NROW(iris)) {
      iris <- chunk
    } else if (NROW(chunk)) {
      iris <- rbind(iris, chunk)
    }
    stats <- dbGetInfo(result)[['stats']]
    if (is.null(progress.bar)) {
      progress.bar <- txtProgressBar(0, stats[['totalSplits']], style=3)
    } else {
      setTxtProgressBar(progress.bar, stats[['completedSplits']])
    }
  }
  close(progress.bar)
# }

Run the code above in your browser using DataLab