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: 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: 27 List Employee names starting with 'S' and ending 'H' with 5 characters length
In this post the sample Apache Pig script will List Employee names starting with 'S' and ending 'H' with 5 characters length.Using Apache Pig version… 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: 11. List Empno, Ename, Sal, Exp of all Employees working for Manager 7839
In this post the sample Apache Pig script will Empno, Ename, Sal, Exp of all Employees working for Manager 7839.
The examples and exercise scrip… Read More Apache Pig Exercises: 12. List details of Employees whose Commission is more than their salary
In this post the sample Apache Pig script will display the details of the emps whose Commission is more than their salary.
The examples and exer… Read More
0 comments:
Post a Comment