Skip to contents

Posts the statement to /v1/statement and returns immediately with a TrinoResult cursor; the rows are pulled by dbFetch(). A statement that fails during planning raises an error here, because Trino reports it in the response to the initial POST.

Usage

# S4 method for class 'TrinoConnection,character'
dbSendQuery(conn, statement, ...)

Arguments

conn

A TrinoConnection object.

statement

A single SQL statement, without a trailing semicolon.

...

Unused, for compatibility with the generic.

Value

A TrinoResult object.

Details

Query parameters are not supported: passing params is an error rather than being silently ignored. Put values into the statement with DBI::sqlInterpolate() or glue::glue_sql(), which quote them with DBI::dbQuoteLiteral() as Trino literals.

Examples

if (FALSE) { # nzchar(Sys.getenv("RTRINO_TEST_URL"))
con <- DBI::dbConnect(RTrino::Trino(), host = Sys.getenv("RTRINO_TEST_URL"),
                      catalog = "tpch", schema = "tiny")
res <- DBI::dbSendQuery(con, "SELECT 1 AS n")
DBI::dbFetch(res)
DBI::dbClearResult(res)

# Values go into the SQL as literals, quoted for Trino
sql <- DBI::sqlInterpolate(
  con, "SELECT count(*) AS n FROM orders WHERE orderdate >= ?since",
  since = as.Date("1998-01-01")
)
DBI::dbGetQuery(con, sql)

DBI::dbDisconnect(con)
}