Using the built-in User Defined Table Function (UDTF)

Normal functions take one row as input and provide one row as transformed output. On the other side, built-in table-generating functions take one row as input and produce multiple output rows.

How to do it…

The built-in table-generating functions could be used directly in the query. The following are some examples of the table-generating functions available in Hive:

Function Name

Return Type

Description

explode(ARRAY)

N rows

It will return n of rows where n is the size of an array. This function represents each element of an array as a row.

explode(MAP)

N rows

It will return n number of rows where n is the size of a map. This function represents each key-value element of the map as a ...

Get Apache Hive Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.