td_remove_context | Teradata Package for R - td_remove_context - Teradata Package for R

Teradata® Package for R User Guide

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-04-09
dita:mapPath
efv1707506846369.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
nqx1518630623256
Product Category
Teradata Vantage

Use the td_remove_context function to remove an existing context created using the td_create_context function or the td_set_context or dbConnect(tdplyr::NativeDriver(), ...) function. This performs removal (garbage collection) of all non-persistent work tables created by the analytic functions and closes the corresponding connection object.

If DBI::dbDisconnect is invoked on the connection object in the current context before calling this function, then a warning is displayed and garbage collection is not performed.

Example 1: Remove connection established using td_create_context()

td_create_context(dsn = "TeradataDSN")
# The nonpersistent work tables are garbage collected and the connection is disconnected
td_remove_context()

Example 2: Remove connection established using td_set_context()

# Establish connection to Teradata Vantage using the dbConnect API
con <- DBI::dbConnect(odbc::odbc(), dsn = "TeradataDSN")
# Use td_set_context to initialize a context with a given connection object.
td_set_context(con = con)
td_remove_context()