Argument Clauses for Java Functions - Aster Execution Engine

Teradata Aster® Developer Guide

Product
Aster Execution Engine
Release Number
7.00.02
Published
July 2017
Language
English (United States)
Last Update
2018-04-13
dita:mapPath
xnl1494366523182.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
ffu1489104705746
lifecycle
previous
Product Category
Software

Often it's useful to let the calling SQL query pass a runtime argument to the SQL-MapReduce function in order to modify the behavior of the function. To support this, the API provides the useArgumentClause method for declaring argument clauses. An argument clause can contain multiple values, and a function can accept multiple argument clauses. See SQL-MapReduce Query Syntax for an explanation of how the SQL user passes multiple clauses and values.

Do not confuse argument clauses with input data. Input data, provided in the ON clause, provides the data the function operates on, while an argument clause typically sets an operating parameter the analyst has chosen to use in this running of the function.

You declare argument clauses when you declare your RuntimeContract, as shown here:

public final class MyFunction implements RowFunction
{
   public MyFunction(RuntimeContract contract)
   {
       String mySingleValue =
          contract.useArgumentClause("mysingle").getSingleValue();
       List<String> myMultipleValues =
          contract.useArgumentClause("mymultiple").getValues();
       // ...
   }
   // ...
}

After you’ve defined the argument clauses shown in the example above, the user of your SQL-MapReduce function can pass arguments in his SQL query like this:

SELECT ...
FROM myfunction(
        ON mytable
        MYSINGLE ('some value')
        MYMULTIPLE ('a value', 'another value')
);

See SQL-MapReduce Query Syntax to see this in the context of other select clauses.

You cannot use parameter markers (?) in SQL-MapReduce invocations. (A parameter marker, as explained in the Microsoft SQL Server documentation is a question mark (?) placed in the location of an input or output expression in a SQL statement.)
For example, you cannot write:
SELECT *
FROM GetUIDropDown(
ON (SELECT 1)
      producttag(?)
      maxdropdownsize('500')
      clustersonly('0')
);

Workaround: SSRS allows the use of report parameters. In SSRS, set the parameter so that it does not allow blank values (that is, uncheck the Allow blank values check box). This forces the sending of a string, which allows the SQL-MapReduce function to run with unnamed parameters.