Apache Pig provides few functions that SQL developers are familiar with. The behavior in much of the functions is the same. Such functions help to interpret, translate, quantify and format data.
The aim of this post is to let you know the functions that help view data in various character cases, such as Uppercase and Lowercase.
Syntax:
UPPER(expression)
It returns a string converted to upper case.
LOWER(expression)
It returns a string converted to lower case.
Examples:
grunt> emp = LOAD ‘Desktop/Docs/emp.csv’ USING PigStorage(‘,’) as (empno:int,ename:chararray,job:chararray,mgr:int,hiredate:chararray,sal:double,comm:double,deptno:int);
grunt> empcaps = FOREACH emp GENERATE empno, UPPER (ename);
grunt> emplowcase = FOREACH emp GENERATE empno, LOWER (ename);
grunt> dump empcaps;
grunt> dump emplowcase;
Hope you find this article helpful.
Please subscribe for more interesting updates.
One comment