Debug UDF Script Output

This section explains how to debug the output from a UDF script.

For any UDF script and virtual schema adapter script (except LUA scripts), you can debug the output of the script by redirecting the standard output and standard error file descriptor to any socket on another machine.

Prerequisite

  • Python 2.x or 3.x installed
  • PyEXASOL installed if you are using Python 3.x

Procedure

For Python 2.x

If you are using Python 2.x, follow these steps to view the debug output:

  1. Download the UDF Debug Python script and run this script in the command line interface on the machine where you want to view the output.
  2. On running this script you will see an output like the example below:

    python udf_debug.py
    >>> bind the output server to 10.242.2.21:3000
  3. By running this script, a service is started on the machine where you want to view the debug output. This service listens to the specified port and displays the debug output.

  4. Next, you need to activate the redirection by executing the session/system parameter SCRIPT_OUTPUT_ADDRESS. In the SQL client of your choice, execute the following statement:
  5. ALTER SESSION SET SCRIPT_OUTPUT_ADDRESS='<host>:<port>';

    Replace <host> and <port> with the IP address and port number of the server. For example, 10.242.2.21:3000.

    The default port specified is 3000.

  6. On successful redirection, the debug output is displayed on the terminal:

    python udf_debug.py
    >>> bind the output server to 10.242.2.21:3000
    10.242.2.21:52698> The value of num is 18
  7. In the above example output, '10.242.2.21' is the IP address of the server that sends the output and '52698' is the VM id.

  8. You can disable the output redirection by setting the parameter SCRIPT_OUTPUT_ADDRESS to an empty value as shown below:
  9. ALTER SESSION SET SCRIPT_OUTPUT_ADDRESS='';

When you call a UDF script, make sure the port specified is accessible. If it is not accessible, the output address cannot be opened, and an error is displayed.

For Python 3.x

If you are using Python 3.x, you must first install PyEXASOL on your machine. You can install PyEXASOL by following the instructions provided in the PyEXASOL GitHub repository.

Next, you can activate the redirection by following the instructions provided in the UDF script output GitHub document.