16.20 - Table Operators - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
April 2020
Content Type
Programming Reference
Publication ID
English (United States)

The guidelines for implementing Java table operators are similar to the guidelines for implementing C/C++ table operators. For more information, see Table Operators.

From the Java perspective, the input and output streams come preopened and you do not have to close the input or output stream because the end of the function is an implicit close. You can close a stream only once. Also, you do not have to read the entire input stream. If you get End Of Data on the input stream, an exception is thrown.

Calling .first() on a TeradataResultSet() rewinds the cursor before the first row instead of to the first row as specified in the Java documentation for java.sql.ResultSet. Therefore, TeradataResultSet.first() is more like java.sql.ResultSet.beforeFirst().
Teradata provides the following Java application classes to support table operators:
  • ArrayTypeInfo
  • ColumnDefinition
  • InputInfo
  • An extension of ResultSet
  • RuntimeContract
  • StreamFormat
  • UDTBaseInfo
  • AMPInfo
  • NodeInfo

The core class for Java SQLTABLE parameter style is RuntimeContract. You define a class with a constructor and an iterator method that is used during the row processing. The constructor acts as the contract function.

Java table operators run in the protected mode Java server just like regular Java UDFs. This environment is multithreaded so you must write the user code to be thread safe.

The rows provided to the table operator are buffered for input and output to improve performance.