Description
This function enables the user to execute script using Script Table Operator on Teradata Vantage.
Usage
## S3 method for class 'ScriptTableOperator' td_execute_script(object, ...)
Arguments
object |
Required Argument. |
... |
Any other optional arguments, if required. |
Value
Named list containing tbl_teradata which can be referenced directly with the "$" operator using name: result.
See Also
Script, td_test_script
Examples
# Note - Refer to Teradata R User Guide for setting search path and required permissions. # Replace "<tdplyr_install_location>" with the absolute path of the install location of the # tdplyr library. One can get this location using '.libPaths()'. # Make sure to include 'tdplyr' in the path. For example, <r_pkg_install_location>/tdplyr. tdplyr_install_location <- "<tdplyr_install_location>" # Replace "<schema_name>" with the name of the schema to search the file for. schema_name <- "<schema_name>" set_session <- gettextf('SET SESSION SEARCHUIFDBPATH = "%s";', schema_name) script_command <- gettextf("Rscript ./%s/mapper.R", schema_name) # Get remote data source connection. con <- td_get_context()$connection # Set Search path, which is necessary for runninng td_execute_script() function. dbExecute(con, dplyr::sql(set_session)) # Load example data. loadExampleData("script_example", "barrier") # Create object(s) of class "tbl_teradata". barrier <- tbl(con, "barrier") # Create a ScriptTableOperator object that allows us to execute user script in Vantage. script_obj <- Script(data = barrier %>% select(Name), script.command = script_command, returns = list("word"= "VARCHAR(15)", "count_input"= "VARCHAR(2)") ) # Install the file 'mapper.R' found in the 'scripts' directory of tdplyr installation location. td_install_file(file.path.loc = file.path(tdplyr_install_location, "scripts", "mapper.R"), file.identifier = 'mapper') # Execute user script on vantage. td_execute_script(script_obj)