[Solved-2 Solutions] How to access an array element in pig ?
What is array
- An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string.
- Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.
Problem :
How to access an array element in pig ?
Solution 1:
- Pig is a scripting language and not relational one like SQL, it is well suited to work with groups with operators nested inside a FOREACH.
- Array elements can be accessed with help of an operators and foreach statement .
Example:
Solution 2:
The below code helps for accessing the array element