apache pig provides various built-in functions namely eval, load, store, math, string, bag and tuple functions.
eval functions
given below is the list of eval functions provided by apache pig.
| s.n. | function & description |
|---|---|
| 1 |
avg()
to compute the average of the numerical values within a bag. |
| 2 |
bagtostring()
to concatenate the elements of a bag into a string. while concatenating, we can place a delimiter between these values (optional). |
| 3 |
concat()
to concatenate two or more expressions of same type. |
| 4 |
count()
to get the number of elements in a bag, while counting the number of tuples in a bag. |
| 5 |
count_star()
it is similar to the count() function. it is used to get the number of elements in a bag. |
| 6 |
diff()
to compare two bags (fields) in a tuple. |
| 7 |
isempty()
to check if a bag or map is empty. |
| 8 |
max()
to calculate the highest value for a column (numeric values or chararrays) in a single-column bag. |
| 9 |
min()
to get the minimum (lowest) value (numeric or chararray) for a certain column in a single-column bag. |
| 10 |
plucktuple()
using the pig latin plucktuple() function, we can define a string prefix and filter the columns in a relation that begin with the given prefix. |
| 11 |
size()
to compute the number of elements based on any pig data type. |
| 12 |
subtract()
to subtract two bags. it takes two bags as inputs and returns a bag which contains the tuples of the first bag that are not in the second bag. |
| 13 |
sum()
to get the total of the numeric values of a column in a single-column bag. |
| 14 |
tokenize()
to split a string (which contains a group of words) in a single tuple and return a bag which contains the output of the split operation. |