Teradata Package for R Function Reference | 17.20 - ConvertTo - 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

ConvertTo

Description

The td_convert_to_sqle() function converts the specified input tbl_teradata columns to specified data types.

Usage

  td_convert_to_sqle (
      data = NULL,
      target.columns = NULL,
      target.datatype = NULL,
      accumulate = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

target.columns

Required Argument.
Specifies the input tbl_teradata columns which needs to be casted/converted to a different data type.
Types: character OR vector of Strings (character)

target.datatype

Required Argument.
Specifies target data type(s) into which "target.columns" need to be converted. If one value is provided, it applies to all "target.columns".
If more than one value is specified, each "target.datatype" value applies to corresponding "target.columns" value (in the order specified by the user).
Types: character OR vector of Strings (character)

accumulate

Optional Argument.
Specifies the name(s) of input tbl_teradata column(s) to
copy to the output. By default, the function copies all input columns to the output.
Types: character OR vector of Strings (character)

...

Specifies the generic keyword arguments SQLE functions accept. Below
are the generic keyword arguments:

persist:
Optional Argument.
Specifies whether to persist the results of the
function in a table or not. When set to TRUE, results are persisted in a table; otherwise, results are garbage collected at the end of the session.
Default Value: FALSE
Types: logical

volatile:
Optional Argument.
Specifies whether to put the results of the
function in a volatile table or not. When set to TRUE, results are stored in a volatile table, otherwise not.
Default Value: FALSE
Types: logical

Function allows the user to partition, hash, order or local order the input data. These generic arguments are available for each argument that accepts tbl_teradata as input and can be accessed as:

  • "<input.data.arg.name>.partition.column" accepts character or vector of character (Strings)

  • "<input.data.arg.name>.hash.column" accepts character or vector of character (Strings)

  • "<input.data.arg.name>.order.column" accepts character or vector of character (Strings)

  • "local.order.<input.data.arg.name>" accepts logical

Note:
These generic arguments are supported by tdplyr if the underlying SQL Engine function supports, else an exception is raised.

Value

Function returns an object of class "td_convert_to_sqle" which is a named list containing object of class "tbl_teradata".
Named list member(s) can be referenced directly with the "$" operator using the name(s):result

Examples

  
    
    # Get the current context/connection.
    con <- td_get_context()$connection
    
    # Load the example data.
    loadExampleData("tdplyr_example", "titanic")
    
    # Create tbl_teradata object.
    titanic <- tbl(con, "titanic")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1 : Convert datatype of 'fare' to integer.
    convertto_out <- td_convert_to_sqle(data = titanic,
                                        target.columns = c("fare"),
                                        target.datatype = c("integer"),
                                        accumulate=c('passenger', 'name', 'ticket')
                                        )
    
    # Print the result.
    print(convertto_out$result)