Teradata Package for R Function Reference | 17.20 - Pack - 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
ft:locale
en-US
ft:lastEdition
2024-05-03
dita:id
TeradataR_FxRef_Enterprise_1720
lifecycle
latest
Product Category
Teradata Vantage

Pack

Description

The td_pack_sqle() function packs data from multiple input tbl_teradata columns into a single column.

Usage

  td_pack_sqle (
      data = NULL,
      input.columns = NULL,
      output.column = NULL,
      delimiter = ",",
      include.column.name = TRUE,
      col.cast = FALSE,
      accumulate = NULL,
      ...
  )

Arguments

data

Required Argument.
Specifies the input tbl_teradata.
Types: tbl_teradata

input.columns

Optional Argument.
Specifies the names of the input columns to pack into a single output column. These names become the column names of the virtual columns.
By default, all input tbl_teradata columns are packed into a single output column. If you specify this argument, but do not specify all input tbl_teradata columns, the function copies the unspecified input table columns to the output table.
Types: character OR vector of Strings (character)

output.column

Required Argument.
Specifies the name to give to the packed output column.
Types: character

delimiter

Optional Argument.
Specifies the delimiter (a string) that separates the virtual columns in the packed data.
Default Value: ","
Types: character

include.column.name

Optional Argument.
Specifies whether to label each virtual column value with its column name (making the virtual column "input_column:value").
Default Value: TRUE
Types: logical

col.cast

Optional Argument.
Specifies whether to get better elapsed times with use cases involving numeric columns to be packed.
Default Value: FALSE
Types: logical

accumulate

Optional Argument.
Specifies the input tbl_teradata columns to copy to the
output table. By default, the function copies no input columns to the output table.
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 Strings (character) (Strings)

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

  • "<input.data.arg.name>.order.column" accepts character OR vector of Strings (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_pack_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("pack_example", "ville_temperature")
    
    # Create tbl_teradata object.
    ville_temperature <- tbl(con, "ville_temperature")
    
    # Check the list of available analytic functions.
    display_analytic_functions()
    
    # Example 1: Packs data from multiple input tbl_teradata columns
    #            into a single column.
    obj <- td_pack_sqle(data=ville_temperature,
            input.columns=c('city','state','period','temp_f'),
            output.column='packed_data',
            delimiter=',',
            accumulate='city',
            include.column.name=TRUE)
    
    # Print the result.
    print(obj$result)