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 into multiple output rows. UDTF is one of the most advanced functions.

Row-set columns types

Name(Signature)

Description

OSS

T

explode(ARRAY<T> a)

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

GenericUDTFExplode


Tkey,Tvalue

explode(MAP<Tkey,Tvalue> m)

Explodes a map to multiple rows. Returns a row-set with two columns (key,value) , one row for each key-value pair from the input map.

int,T
posexplode(ARRAY<T> a)
Explodes an array to multiple rows with an additional positional column ofint 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.GenericUDTFPosExplode

T1,...,Tn

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

Explodes 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.

GenericUDTFInline

T1,...,Tn/r
stack(int r,T1  V1,...,Tn/r Vn)
Breaks up n values V1,...,Vninto r rows. Each row will have n/r columns. r must be constant.GenericUDTFStack
string1,...,stringn
json_tuple(string jsonStr, string k1,...,string kn)
Takes JSON string and a set of n keys, and returns a tuple of n values. This is a more efficient version of the get_json_object UDF because it can get multiple keys with just one call.GenericUDTFJSONTuple

string 1,...,stringn

parse_url_tuple(string urlStr, string p1,...,string pn)

Takes URLstring and a set of n URL parts, and returns a tuple of n values. 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>.

GenericUDTFParseUrlTuple

String Functions

There is no good engine without string manipulation functions. Apache Hive has rich built-instring functions. 

...