Description
This function enables the user to run script in docker container environment outside Vantage. Input data for user script is read from file or Vantage.
Usage
## S3 method for class 'ScriptTableOperator' td_test_script( object = NULL, files.local.path = NULL, script.name = NULL, input.data.file = NULL, supporting.files = NULL, script.args = NULL, ... )
Arguments
object |
Required Argument. |
files.local.path |
Required Argument. |
script.name |
Required Argument. |
input.data.file |
Optional Argument. |
supporting.files |
Optional Arguument. |
script.args |
Optional Argument. |
... |
Specifies the arguments used for reading data from all AMPs.
Any other arguments, if provided, are ignored. |
Value
A R data.frame containing the output of user script.
See Also
td_setup_test_env, Script
Examples
# 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>" # Replace "<path_to_docker_image>" with the local path to the downloaded docker image file. docker_image_location <- "<path_to_docker_image>" # Replace "<password>" with the password of the user to fetch data from Vantage. password <- "<password>" script_command <- gettextf("Rscript ./%s/mapper.R", schema_name) # Get remote data source connection. con <- td_get_context()$connection # 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)") ) ## Run the user script locally within docker container using data from csv file. # Setup the environment by providing path to the docker image file. td_setup_test_env(docker.image.location = docker_image_location) # Example 1: Test user script mentioned in the argument "script.name" using the data # provided in the argument "input.data.file". td_test_script(object = script_obj, files.local.path = file.path(tdplyr_install_location, "scripts"), script.name = "mapper.R", input.data.file = "barrier.csv" ) # Example 2: Test user script mentioned in the argument "script.name" using the data # from AMPs in the database. td_test_script(object = script_obj, files.local.path = file.path(tdplyr_install_location, "scripts"), script.name = "mapper.R", password = password )