Jupyter Extension makes Script Table Operators easy with Magics

Teradata SQL Extension for Jupyter
Teradata Employee

Jupyter Extension makes Script Table Operators easy with Magics

Teradata SQL Extension for Jupyter provides magic commands to help users install and run Script Table Operators (STO). Teradata Script Table Operators can be used to execute Linux commands inside the database.  Moving the analytics to the data is a desirable feature for R and Python users who want the ability to process large amounts of data on the Teradata Database with scripts written in these external languages. In-database analytics can be particularly useful for R users, who otherwise need to export large volumes of data to compute clusters for their analytic processing requirements. 


Magic commands are built-in to the Teradata SQL Notebook to provide custom execution processing and simplify the user experience. The following commands are provided for STOs:


  • %pyinfo or %rinfo - Show information about the version of Python or R installed on the active Vantage database
  • %runsto – Run Script Table Operator provides options for running STOs.
  • %installfile, %showfile, %rmfile – install, show, and remove an STO file on the active Vantage connection


The best way to  demonstrate the Script Table Operators is to view the following series of snippets from a Teradata SQL Notebook.

The first animation shows initial magics to get started with Script Table Operators. 


Next, load and run an STO python script file and then view the loaded file.




Now that the STO has been installed, you can run the STO using the %runsto magic. 



Another option is to run the STO and insert the output into a table.



Another feature that was added to the STO magics was the ability to show any errors that occurred when running the STO. Without this feature, it can be a difficult task to gather the error messages from the error logs on the amps.

The next snippet demonstrates an STO with an error and displaying the errors in the %runsto magic.




And finally, the Teradata SQL notebook includes magics to show, install, and remove STO files.




There is also a sample Script Table Operator Notebook (ScriptTableOperatorSample.ipynb) that you can download into your JupyterLab installation. NOTE: You must grant the user the appropriate privileges to install and run STOs.