Teradata Package for R Function Reference | 17.00 - translate_sql - 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

Product
Teradata Package for R
Release Number
17.00
Published
July 2021
Language
English (United States)
Last Update
2023-08-08
dita:id
B700-4007
NMT
no
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())