Changelog
Source:NEWS.md
RTrino 0.1.0
First release: a DBI backend for Trino over the cluster’s HTTP REST API.
Connections
-
Trino(),dbConnect(),dbDisconnect()anddbIsValid()manage a connection’s life cycle.dbConnect()probes/v1/info, so a wrong address or a rejected credential fails at connection time. Its arguments are validated before the coordinator is contacted, with plain messages. -
trino_auth_basic(),trino_auth_jwt()andtrino_auth_oauth2()supply credentials, andtrino_ssl()sets the TLS options, includingca_bundleto trust an internal certificate authority without turning verification off.dbConnect()refuses to send credentials to anhttp://host unlessallow_http_auth = TRUE. -
timeoutbounds each HTTP request (60 seconds by default) andquery_max_run_timebounds a query on the cluster. - 429, 502, 503 and 504 responses are retried after a short pause, as Trino’s protocol asks.
Queries and results
-
dbSendQuery(),dbFetch(),dbGetQuery(),dbExecute(),dbSendStatement(),dbHasCompleted()anddbClearResult()run queries, with automaticnextUripagination, chunked fetching throughdbFetch(n = ), and server-side cancellation when a running result is cleared. -
dbExecute()returns the number of rows Trino says a statement changed, and0for DDL.dbSendStatement()runs the statement to completion, so thatdbGetRowsAffected()answers straight away. -
dbColumnInfo()anddbFetch(n = 0)describe the columns before the first row is fetched. -
dbIsValid()on a result reports whether it has been cleared, not whether the query has finished, as DBI requires:dbColumnInfo()anddbGetRowCount()keep working untildbClearResult().dbHasCompleted()reports that every row has been consumed. - Query failures are raised as classed conditions,
trino_query_errorandtrino_canceled, carrying the server’serror_name,error_code,error_typeandquery_id, so a caller can react to a specific Trino error without matching on the message text. - Queries do not pause between the empty pages Trino returns while it queues and plans. A capped pause still guards against a server that returns empty pages instantly and forever.
- Passing
paramsis an error, anddbBind()says that parameters are not supported. Put values into a statement withDBI::sqlInterpolate()orglue::glue_sql():dbQuoteLiteral()writes typed Trino literals (DATE '...',TIMESTAMP '...',TRUE, doubles that read back exactly).
Types
-
BIGINTis returned as exactbit64::integer64by default (bigint = "numeric"or"character"for the alternatives), andDOUBLEbit for bit. Trino sends both as JSON numbers, which are converted without going through text. The lowestBIGINT, which bit64 keeps forNA, isNAwith a warning. - Timestamps keep their microseconds, and
TIMESTAMP WITH TIME ZONEis resolved per value whether the server sends a zone name or an offset. - A column of a type RTrino does not know warns once per result;
INTERVALcolumns are read as text, and a bareNULLas a logical. -
dbDataType()andtrino_type_to_r()map between R and Trino types.
Tables, writes and transactions
-
dbListTables(),dbExistsTable(),dbListFields()anddbGetInfo()read the catalog. Table names are strings of one to three parts,DBI::Id()or quoted identifiers, and are matched ignoring case, as Trino does.dbExistsTable()counts a row ininformation_schema.tables, so its cost does not grow with the size of the schema, and reportsFALSErather than an error for a name in a catalog that does not exist. -
dbWriteTable(),dbAppendTable()anddbCreateTable()write data frames. Rows go in asINSERT INTO ... VALUESstatements ofchunk_sizerows each (1000 by default), every value a literal, since Trino’s protocol has no parameter binding.dbWriteTable(overwrite = TRUE)renames the existing table rather than dropping it, and restores it if the write fails.dbRemoveTable()anddbRenameTable()drop and rename tables, andtemporary = TRUEis an error, because Trino has no temporary tables. -
dbBegin(),dbCommit(),dbRollback()anddbWithTransaction()run statements inside a Trino transaction. Whether aROLLBACKundoes a write depends on the connector behind the catalog;dbBegin()warns for the catalogs that hold no real storage (memory,system,tpch,tpcds,jmxandblackhole).
dplyr
-
dplyrpipelines are translated to Trino SQL through a dbplyr dialect, which requires dbplyr >= 2.6.0. The methods are registered when dbplyr is loaded rather than throughNAMESPACE, because aNAMESPACEdirective forsql_dialect(), which older versions lack, would make such a dbplyr fail to load. - Translations are written so that an expression computes in Trino what it computes in R:
/divides as a double,%%takes the sign of the divisor,as.integer()andas.integer64()truncate,grepl(),sub()andgsub()honourfixedandignore.caseand accept R’s\\1back-references, andpaste(),paste0()andstr_c()accept columns of any type.days(),weeks(),months(),years(),hours(),minutes()andseconds()build intervals, fordate + days(1). ADateorPOSIXctfrom R becomes a typed literal in a pipeline. -
filter_out(), from dplyr 1.2.0, uses Trino’s nativeIS DISTINCT FROMrather than theCASE WHENcomparison dbplyr falls back to. dplyr 1.2.0’swhen_any()/when_all()andrecode_values()/replace_values()/replace_when()are not translated, because dbplyr 2.6.0 has no translation for them on any backend. -
copy_to()andcompute()write throughdbWriteTable(), and needtemporary = FALSEand a table name.compute()does not runANALYZE, which not every connector supports. - Column discovery uses dbplyr’s default (
WHERE 0 = 1) rather thanLIMIT 0. Both plan without reading data on Trino, and the default avoids depending on dbplyr internals. -
simulate_trino()returns a connection that carries the dialect without a session, for inspecting translated SQL with no cluster to hand. - The vignette lists the few places where a translation still differs from R:
round()on halves, the approximatemedian()andquantile(),DECIMALbeyond 15 digits, andpaste()of aDOUBLE.
Testing
- The test suite runs offline against a fake coordinator that replays responses recorded from a real Trino (
dev/record-fixtures.R), so everything about how values are encoded is tested against payloads a cluster really sends. -
tests/testthat/test-live.Rruns against a real Trino whenRTRINO_TEST_URLis set, and CI runs it againsttrinodb/trino.