Description
This function enables the user to set data and data related arguments without having to
re-create ScriptTableOperator object.
Note: All data related arguments that are not specified in this function are reset to
default values.
Usage
## S3 method for class 'ScriptTableOperator' td_set_data( object = NULL, data = NULL, data.hash.column = NULL, data.partition.column = NULL, data.order.column = NULL, is.local.order = FALSE, sort.ascending = TRUE, nulls.first = TRUE, ... )
Arguments
object |
Required Argument. |
data |
Required Argument. |
data.hash.column |
Optional Argument. |
data.partition.column |
Optional Argument.
Permitted Values: "ANY" OR one or more columns in "data"
tbl_teradata. |
data.order.column |
Optional Argument. |
is.local.order |
Optional Argument.
Note:
Default Value: FALSE |
sort.ascending |
Optional Argument. |
nulls.first |
Optional Argument. |
... |
Any other optional arguments, if required. |
Value
A named list of "ScriptTableOperator" class.
See Also
td_setup_test_env, td_test_script, td_execute_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>" 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(script.command = script_command, charset = "LATIN", returns = list("word"= "VARCHAR(15)", "count_input"= "VARCHAR(2)") ) # 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, script.name = "mapper.R", files.local.path = file.path(tdplyr_install_location, "scripts"), input.data.file = "barrier.csv" ) # Now in order to test/run script using actual data on Vantage user can set data and related # arguments without recreating ScriptTableOperator object. script_obj <- td_set_data(object = script_obj, data = barrier %>% select(Name) ) # Run the td_execute_script() function to execute the script on Vantage or td_test_script() # to test the script in the sandbox.