pig tutorial - apache pig tutorial - Apache Pig - Eval Functions - pig latin - apache pig - pig hadoop
What is Eval Functions in Apache Pig ?
- Eval functions extend the Java class ‘org.apache.pig.EvalFunc and it is parameterized with the return type of the UDF which is a Java String which is a part of java class
- Eval Functions will take one record and returns one result, which will be invoked for every record that will pass through the execution pipeline.
- Eval Function takes the tuple which contains the fields for the script which is passed to the UDF (User Defined Function) as an input.
- Eval function is invoked on every input tuple and the input is done into the function which is a tuple with input parameters where they are passed to the function which is done in the Pig script.
Learn apache pig - apache pig tutorial - eval function in apache pig - apache pig examples - apache pig programs
An example which is given below done to explain the Eval Functions
Example:
The table which is given below give us the eval functions and their description
Function | Syntax | Description |
---|---|---|
AVG | AVG(expression | Computes the average of the numeric values in a single-column bag. |
CONCAT | CONCAT (expression, expression) | Concatenates two expressions of identical type. |
COUNT | COUNT(expression) | Computes the number of elements in a bag, it ignores null. |
COUNT_STAR | COUNT_STAR(expression) | Computes the number of elements in a bag, it includes null. |
DIFF | DIFF (expression, expression) | Compares two fields in a tuple, any tuples that are in one bag but not the other are returned in a bag. |
IsEmpty | IsEmpty(expression) | Checks if a bag or map is empty |
MAX | MAX(expression) | Computes the maximum of the numeric values or chararrays in a single-column bag |
MIN | MIN(expression) | Computes the minimum of the numeric values or chararrays in a single-column bag. |
SIZE | SIZE(expression) | Computes the number of elements based on any Pig data type. SIZE includes NULL values in the size computation |
SUM | SUM(expression) | Computes the sum of the numeric values in a single-column bag. |
TOKENIZE | TOKENIZE(expression [, ‘field_delimiter’]) | Splits a string and outputs a bag of words. |