Function Invocation

Description

A function invocation executes a builtin function or a user-defined function after associating arguments to the function’s parameters.

Spark supports positional parameter invocation as well as named parameter invocation.

Positional parameter invocation

Each argument is assigned to the matching parameter at the position it is specified.

This notation can be used by all functions unless it is explicitly documented that named parameter invocation is required.

If the function supports optional parameters, trailing parameters for which no arguments have been specified, are defaulted.

Named parameter invocation

Arguments are explicitly assigned to parameters using the parameter names published by the function.

This notation must be used for a select subset of built-in functions which allow numerous optional parameters, making positional parameter invocation impractical. These functions may allow a mixed invocation where a leading set of parameters are expected to be assigned by position and the trailing, optional set of parameters by name.

Syntax

function_name ( [ argExpr | table_argument ] [, ...]
                [ namedParameter => [ argExpr | table_argument ] [, ...] )

table_argument
  { TABLE ( { table_name | query } )
    [ table_partition ]
    [ table_order ]

table_partitioning
  { WITH SINGLE PARTITION |
    { PARTITION | DISTRIBUTE } BY { partition_expr | ( partition_expr [, ...] ) } }

table_ordering
  { { ORDER | SORT } BY { order_by_expr | ( order_by_expr [, ...] } }

Parameters