Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Normal user-defined functions, such as concat(), take in a single input row and output a single output row. In contrast, table-generating functions transform a single input row to multiple output rows.

Return Type

(row-set)

Name(Signature)

Description

N rowsT

explode(ARRAYa ARRAY<T>)

Explode an array to multiple rows. Returns a row-set with a single column (col), one row for each element from the array.

int,Tposexplode(a ARRAY<T>)Explode an array to multiple rows with additional positional column of int type (position of items in the original array, starting with 0). Returns a row-set with two columns (pos,val), one row for each element from the array.

Tk,Tv

explode(m MAP<Tk,Tv>)

Explode a map to multiple rows. Returns a row-set with a two columns (key,value) ,

N rows

explode(MAP)

Returns one row for each key-value pair from the input map with two columns in each row: one for the key and another for the value. (As of Hive 0.8.0.) 0.8.0.).

T1,T2,...,Tn

inline(a ARRAY<STRUCT<f1:T1,f2:T2,...,fn:Tn>>)

Explode an array of structs to multiple rows. Returns a row-set with N columns (N = number of top level elements in the struct), one row per struct from the array

 

inline(ARRAY<STRUCT[,STRUCT]>)

Explodes an array of structs into a table. (As of Hive 0.10.)

Array Type

explode(array<TYPE> a)For each element in a, generates a row containing that element.

tuple

json_tuple(jsonStr, k1, k2, ...)

Takes a set of names (keys) and a JSON string, and returns a tuple of values. This is a more efficient version of the get_json_object UDF because it can get multiple keys with just one call.

tuple

parse_url_tuple(url, p1, p2, ...)

This is similar to the parse_url() UDF but can extract multiple parts at once out of a URL. Valid part names are: HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, USERINFO, QUERY:<KEY>.

N rows

posexplode(ARRAY)

Behaves like explode for arrays, but includes the position of items in the original array by returning a tuple of (pos, value). (As of Hive 0.13.0.)

N rows

stack(INT n, v_1, v_2, ..., v_k)

Breaks up v_1, ..., v_k into n rows. Each row will have k/n columns. n must be constant.

...