The attach_attributes() function takes an existing tbl_teradata object and attaches the following attributes:
- databaseName - The name of the database in which the table exists.
- sourceDefinition - Name of the source of input, that is, table name or sql query.
- sourceType - Type of input source, that is, table or query.
- object - Full name of the table when source type is table, else NULL.
- baseQuery - Base Query for the tbl.
- columnDataType - DataTypes of the columns.
- columnNames - Names of the columns.
The tbl_teradata object name is a required argument of this function.
Example Setup
- Get remote data source connection.
con <- td_get_context()$connection
- Load the required tables.
loadExampleData("antiselect_example", "antiselect_input")
- Create objects of class "tbl_teradata" with and without metadata.
tbl_antiselect <- tbl(con, "antiselect_input") tbl_antiselect_wo_metadata <- tbl(con, "antiselect_input", ignore.metadata=T)
Example 1: Attach the attributes to the 'tbl_antiselect'
attach_attributes(tbl_antiselect)
Retrieve the attributes using the attributes() function.:
antiselect_attr <- attributes(tbl_antiselect)
Example 2: Attach the attributes to the 'tbl_antiselect_wo_metadata'
attach_attributes(tbl_antiselect_wo_metadata)
Retrieve the attributes using the attributes() function.:
antiselect_attr <- attributes(tbl_antiselect_wo_metadata)