Table-valued Functions (TVF)
- a TVF that can be specified in a FROM clause, e.g. range;
- a TVF that can be specified in SELECT/LATERAL VIEW clauses, e.g. explode.
TVFs that can be specified in a FROM clause:
TVFs that can be specified in SELECT/LATERAL VIEW clauses:
Function | Argument Type(s) | Description |
---|---|---|
explode ( expr ) | Array/Map | Separates the elements of array expr into multiple rows, or the elements of map expr into multiple rows and columns. Unless specified otherwise, uses the default column name col for elements of the array or key and value for the elements of the map. |
explode_outer ( expr ) | Array/Map | Separates the elements of array expr into multiple rows, or the elements of map expr into multiple rows and columns. Unless specified otherwise, uses the default column name col for elements of the array or key and value for the elements of the map. |
inline ( expr ) | Expression | Explodes an array of structs into a table. Uses column names col1, col2, etc. by default unless specified otherwise. |
inline_outer ( expr ) | Expression | Explodes an array of structs into a table. Uses column names col1, col2, etc. by default unless specified otherwise. |
posexplode ( expr ) | Array/Map | Separates the elements of array expr into multiple rows with positions, or the elements of map expr into multiple rows and columns with positions. Unless specified otherwise, uses the column name pos for position, col for elements of the array or key and value for elements of the map. |
posexplode_outer ( expr ) | Array/Map | Separates the elements of array expr into multiple rows with positions, or the elements of map expr into multiple rows and columns with positions. Unless specified otherwise, uses the column name pos for position, col for elements of the array or key and value for elements of the map. |
stack ( n, expr1, …, exprk ) | Seq[Expression] | Separates expr1, …, exprk into n rows. Uses column names col0, col1, etc. by default unless specified otherwise. |
json_tuple ( jsonStr, p1, p2, …, pn ) | Seq[Expression] | Returns a tuple like the function get_json_object, but it takes multiple names. All the input parameters and output column types are string. |
parse_url ( url, partToExtract[, key] ) | Seq[Expression] | Extracts a part from a URL. |