org.h2.expression.function.table

## Class TableFunction

- java.lang.Object
- - org.h2.expression.function.table.TableFunction

All Implemented Interfaces:
  ExpressionWithVariableParameters, NamedExpression, HasSQL

Direct Known Subclasses:
  ArrayTableFunction, CSVReadFunction, JavaTableFunction, LinkSchemaFunction

    public abstract class TableFunction
    extends java.lang.Object
    implements HasSQL, NamedExpression, ExpressionWithVariableParameters

A table value function.

### Field Summary

Fields
`protected Expression[]` `args`

### Fields inherited from interface org.h2.util.HasSQL

`ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS`

### Constructor Summary

Constructors
`protected` `TableFunction(Expression[] args)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `addParameter(Expression param)` Adds the parameter expression.
`void` `doneWithParameters()` This method must be called after all the parameters have been set.
`java.lang.StringBuilder` `getSQL(java.lang.StringBuilder builder, int sqlFlags)` Appends the SQL statement of this object to the specified builder.
`abstract ResultInterface` `getValue(SessionLocal session)` Get a result with.
`abstract ResultInterface` `getValueTemplate(SessionLocal session)` Get an empty result with the column names set.
`abstract boolean` `isDeterministic()` Whether the function always returns the same result for the same parameters.
`void` `mapColumns(ColumnResolver resolver, int level, int state)` Map the columns of the resolver to expression columns.
`void` `optimize(SessionLocal session)` Try to optimize this table function

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.h2.util.HasSQL

`getSQL, getTraceSQL`

### Methods inherited from interface org.h2.expression.function.NamedExpression

`getName`

### Field Detail

#### args

    protected Expression[] args

### Constructor Detail

#### TableFunction

    protected TableFunction(Expression[] args)

### Method Detail

#### addParameter

    public void addParameter(Expression param)

Description copied from interface: `ExpressionWithVariableParameters`
Adds the parameter expression.

Specified by:
  `addParameter` in interface `ExpressionWithVariableParameters`
Parameters:
  `param` - the expression

#### doneWithParameters

    public void doneWithParameters()
                            throws DbException

Description copied from interface: `ExpressionWithVariableParameters`
This method must be called after all the parameters have been set. It checks if the parameter count is correct when required by the implementation.

Specified by:
  `doneWithParameters` in interface `ExpressionWithVariableParameters`
Throws:
  `DbException` - if the parameter count is incorrect.

#### getValue

    public abstract ResultInterface getValue(SessionLocal session)

Get a result with.

Parameters:
  `session` - the session
Returns:
  the result

#### getValueTemplate

    public abstract ResultInterface getValueTemplate(SessionLocal session)

Get an empty result with the column names set.

Parameters:
  `session` - the session
Returns:
  the empty result

#### mapColumns

    public void mapColumns(ColumnResolver resolver,
                           int level,
                           int state)

Map the columns of the resolver to expression columns.

Parameters:
  `resolver` - the column resolver
  `level` - the subquery nesting level
  `state` - current state for nesting checks, initial value is `Expression.MAP_INITIAL`

#### optimize

    public void optimize(SessionLocal session)

Try to optimize this table function

Parameters:
  `session` - the session

#### isDeterministic

    public abstract boolean isDeterministic()

Whether the function always returns the same result for the same parameters.

Returns:
  true if it does

#### getSQL

    public java.lang.StringBuilder getSQL(java.lang.StringBuilder builder,
                                          int sqlFlags)

Description copied from interface: `HasSQL`
Appends the SQL statement of this object to the specified builder.

Specified by:
  `getSQL` in interface `HasSQL`
Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
Returns:
  the specified string builder