Skip to content

Table-Valued Functions

Table-Valued Functions (TFVs) are functions that return a table (as a LogicalPlan) that can be used anywhere that a regular (scalar) table is allowed.

Table functions behave similarly to views, but, as functions in general, table functions accept parameters.

Google BigQuery Documentation

Read up on table-valued functions in the official documentation of Google BigQuery (for a lack of a better documentation).

Spark SQL supports Logical Operators and Generator expressions as table-valued functions.

Name Logical Operator Generator Expression
range Range
explode Explode
explode_outer Explode
inline Inline
inline_outer Inline
json_tuple JsonTuple
posexplode PosExplode
posexplode_outer PosExplode
stack Stack

Custom table-valued functions can be registered using SparkSessionExtensions.

Spark SQL uses the SimpleTableFunctionRegistry to manage the built-in table-valued functions.