Teradata Package for R Function Reference | 17.20 - SQL Translation - Teradata Package for R - Look here for syntax, methods and examples for the functions included in the Teradata Package for R.

Teradata® Package for R Function Reference

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for R
Release Number
17.20
Published
March 2024
Language
English (United States)
Last Update
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
Product Category
Teradata Vantage
SQL Translation Extensions

Description

An important feature that 'dbplyr' provides is the ability to take expressions in R and map them to corresponding expressions in SQL. tdplyr maps certain window, aggregate, and scalar functions to SQL expressions when summarize, mutate, or filter is used.

Details

See vignette('sql-translation', package = 'tdplyr') for a list of all the mappings. Note that functions not explicitly mapped above will be translated to sql literally.

Examples


  translate_sql(mean(x, na.rm = TRUE), window = FALSE, con = dbplyr::simulate_teradata())
  translate_sql(sdp(distinct(x), na.rm = TRUE), window = FALSE, con = dbplyr::simulate_teradata())

  translate_sql(mean(x, na.rm = TRUE), con = dbplyr::simulate_teradata())
  translate_sql(sdp(x, na.rm = TRUE), con = dbplyr::simulate_teradata())

  # The DISTINCT clause is not permitted in window aggregate functions
  tryCatch({
    translate_sql(sum(distinct(x), na.rm = TRUE), con = dbplyr::simulate_teradata())
  },error=function(e) {
    geterrmessage()
  })

  # The DISTINCT clause is allowed in aggregate functions
  translate_sql(sdp(distinct(x), na.rm = TRUE), window = FALSE, con = dbplyr::simulate_teradata())