In this post the sample Apache Pig script will display all unique Job positions from Employee file data set.
Using Apache Pig current version r0.15.0.
Please refer to Apache Pig learning series intro... post for the file structures, visit the reference section shown at the bottom of the post for more.
@ Sample data: APACHE PIG ~ ALL SAMPLE TABLES and STRUCTURES
Employees data table:
@ Apache Pig Script:
2. Fetch all records having unique jobs from Employee dataset:
grunt>
data = LOAD '/Documents/tbl_EMP.txt' USING PigStorage(',') as (empno:int, ename:chararray, job:chararray, mgr:int, hiredate:chararray, sal:float, comm:float, deptno:int);
all_jobs = foreach data generate job;
/*get only unique data from extracted column*/
uniq_jobs = distinct all_jobs;
dump uniq_jobs;
@Apache Pig Output on Grunt Shell:
(CLERK)
(ANALYST)
(MANAGER)
(SALESMAN)
(PRESIDENT)
@ Apache Pig Reference/s:
https://pig.apache.org
http://pig.apache.org/docs/r0.14.0/
Thank you!
Related Posts: Apache Pig Exercises: 5. List employees in asc order of dept nbr. & desc of job title
In this post the sample Apache Pig script will display all Employee records iin asc order of dept nbr. and desc of job title.
The examples and exerci… Read More Apache Pig Exercises: 6. List all employees who are ‘Managers’
In this post the sample Apache Pig script will display all Employee who are Managers.
The examples and exercise scripts are created using Apache Pig … Read More Apache Pig Exercises: 9. List Empno, Ename, Sal, Daily Sal of all Employees in ascending order of AnnSal
In this post the sample Apache Pig script will display all unique job title in a descending order.
The examples and exercise scripts are created… Read More Apache Pig Exercises: 10. List Empno, Ename, Job, Hiredate, Experience of all Managers
In this post the sample Apache Pig script will display Empno, Ename, Job, Hiredate, Experience of all Managers
The examples and exercise scripts… Read More Apache Pig Exercises: 7. List all the unique job title in a descending order
In this post the sample Apache Pig script will display all unique job title in a descending order.
The examples and exercise scripts are created… Read More
0 comments:
Post a Comment