Skip to contents

Extends dbplyr's base translation so that an R expression computes in Trino what it computes in R, or fails, rather than quietly computing something else:

Usage

sql_translation.sql_dialect_trino(con)

Arguments

con

A Trino SQL dialect object.

Value

A dbplyr SQL variant.

Details

  • / divides as a double, where Trino would truncate the quotient of two integers; %% takes the sign of the divisor, as in R.

  • as.integer() and as.integer64() truncate towards zero, where a cast would round.

  • paste(), paste0() and str_c() cast every argument to VARCHAR, which Trino's CONCAT_WS requires.

  • grepl(), sub() and gsub() honour fixed and ignore.case, and rewrite R's \\1 back-references into Trino's $1; sub() replaces the first match only.

  • days(), weeks(), months(), years(), hours(), minutes() and seconds() build intervals, so date + days(1) works where date + 1 does not.

  • Casts name Trino types, and median() and quantile() use approx_percentile, which is the percentile Trino offers over an arbitrary number of rows. Null-safe comparison uses Trino's native IS DISTINCT FROM rather than dbplyr's portable CASE WHEN spelling.