td_test_script() | Teradata Package for R - td_test_script() - 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
The td_test_script() exec.mode='sandbox' setting and corresponding usage of this function in Sandbox Container is a deprecated feature in this release. It is not guaranteed to work. It will be removed in future release versions.

The td_test_script() function enables a user to run script in Docker container environment outside Vantage. Input data for user script is read from file or Vantage.

  • It is the responsibility of the user to make sure the Docker environment is present in the client machine.
  • This function uses the container specified in the option sandbox.container.

    If this option is NULL, either set this option or run the function td_setup_sandbox_env().

  • quotechar functionality is not supported in td_test_script() function.
Required arguments:
  • files.local.path specifies the absolute local path where user script (specified in the argument script.name), all supporting files (specified in the argument supporting.files), and input data file (specified in the argument input.data.file) reside.
  • script.name specifies the name of the user script.

    This file should have a path relative to the location specified in the argument files.local.path.

  • input.data.file specifies the name of the input data file.

    This file should have a path relative to the location specified in the argument files.local.path.

    If this argument is not provided, data is read from AMP in the database. The data is taken from the data argument of ScriptTableOperator object.

  • supporting.files specifies one or more supporting files, like model files, to be copied to the container.

    These files should have a path relative to the location specified in the argument files.local.path.

  • script.args specifies command line arguments required by the user script.
Optional argument:
  • exec.mode specifies the mode in which the user wants to test the script.
    • If set to 'sandbox', which is the default value, the user script will run within the sandbox environment.
    • If set to 'local', the user script will run locally on the user's system.
Ellipsis arguments: Specifies the arguments used for reading data from all AMPs and arguments to specify different types of logon mechanisms. The following are the valid argument names. Any other arguments, if provided, are ignored.
  • data.row.limit specifies the number of rows to be taken from all AMPs when reading from Vantage. The default value is 1000.
  • password specifies the password to connect to Vantage where the data resides.
  • data.file.delimiter specifies the delimiter used in the input data file. The default value is ','.

    This argument can be specified when data is read from file.

  • data.file.header specifies whether the input data file contains header. The default value is TRUE.

    This argument can be specified when data is read from file.

  • logmech specifies the type of logon mechanism to establish a connection to Vantage.
    • TD2:

      The Teradata 2 (TD2) mechanism provides authentication using a database username and password.

      This is the default logon mechanism.

    • TDNEGO:

      TDNEGO is a security mechanism that automatically determines the actual mechanism required, based on policy, without user's involvement. The actual mechanism is determined by the TDGSS server configuration and the security policy's mechanism restrictions.

    • LDAP:

      LDAP is a directory-based mechanism. User logs on to a database with a directory username and password and is authenticated by the directory.

    • KRB5:

      KRB5 is a directory-based mechanism. User logs on to a database with a domain username and password and is authenticated by Kerberos (KRB5 mechanism).

      User must have a valid ticket-granting ticket in order to use this logon mechanism.
    • JWT:

      The JSON Web Token (JWT) authentication mechanism enables single sign-on (SSO) to Vantage after the user successfully authenticates to Teradata UDA User Service.

      User must use logdata parameter when using 'JWT' as the logon mechanism.
    tdplyr expects the client environments are already setup with appropriate security mechanisms and are in working conditions. See Teradata Vantage™ - Analytics Database Security Administration for more information.
  • logdata specifies parameters to the LOGMECH command beyond those needed by the logon mechanism, such as user ID, password and tokens (in case of 'JWT') to successfully authenticate the user.

Example 1: Test user script using the data from CSV file

This example tests the 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"
  )
       word count_input
1       Old           1
2 Macdonald           1
3       Had           1
4         A           1
5      Farm           1

Example 2: Test user script using data from Vantage

This example tests the 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>
  )
       word count_input
1       Old           1
2 Macdonald           1
3       Had           1
4         A           1
5      Farm           1