Case Conversion in Apache Pig

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.

It returns a string converted to upper case.

It returns a string converted to lower case.

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s