0

I have gone through the official documentation of Teradata.

I am planning to write a table function (UDF in C++) which accepts 2 columns as input, processes the input and converts it to a std::map< string,string > or array of structs and passes it to some other function which accepts input as array of structs/std::map< string,string >. My questions are:

  1. If I pass 2 columns from a table, how can know the number of rows in new temporary table??How can I accept the values, passed as a column from Teradata query statement into the UDF??
  2. Are the things, given in the appendix of the documentation such as phase checking,like TBL_BUILD, TBL_PRE_INIT etc., mandatory to be included in the code, for building of the table and other purposes??
Aman Vaishya
  • 179
  • 12

1 Answers1

0

You cannot return any data structures from a table UDF. For each row, you have value stack entries to put your values for returning columns. And each value must be a Teradata recognized data type.

Also, you need to be careful with STL libraries. In fact, avoid dealing with memory allocation / deallocation and use stack instead. This is because if you have any memory leaks or memory fragmentation, then from time to time you will have to restart your server, which is not good for a production system.

Since the table UDF is called for each row and phase, the only way to save your data is via the context. You also do not want to have spend too much time processing for each row, as that will be a major performance issue.

You may want to take a look at table operator if you intend to maintain a complicated in-memory structure.

user1456982
  • 125
  • 6