pig tutorial - apache pig tutorial - Apache Pig LCFIRST() - pig latin - apache pig - pig hadoop




What is LCFIRST?

  • This function is used to covert the first character of the given string into lowercase.

Syntax:

  • Following is the syntax of the LCFIRST() function.
grunt> LCFIRST(expression) 

Example:

  • Assume that there is a file named wikitechy_emp.txt in the HDFS directory /pig_data/as shown below.
  • This file contains the employee details such as id, name, age, and city.

wikitechy_emp.txt

001,Aadav,32,Tokyo
002,Aadhi,33,Kolkata
003,Charu,23, London
004,Daya,35,London 
005, Hansa,22,Bhuwaneshwar 
006, Hena,21,Chennai
007,Robert,24, Bhuwaneshwar
008,Kali,20,Kolkata
009,Leena,22, Chennai
010,Mahi,22, newyork
011,Priya,23, Tokyo
012,Rahul,20, newyork
  • And, we have loaded this file into Pig with a relation named wikitechy_emp_data as shown below.
grunt> wikitechy_emp_data = LOAD 'hdfs://localhost:9000/pig_data/wikitechy_emp.txt' USING PigStorage(',')
   as (id:int, name:chararray, age:int, city:chararray);
  • Given below is an example of the LCFIRST() function. In this example, we have converted all the first letters of the names of the employees to lowercase.
grunt> Lcfirst_data = FOREACH wikitechy_emp_data GENERATE (id,name), LCFIRST(name);
  • The result of the statement will be stored in the relation named Lcfirst_data. Verify the content of the relation Lcfirst_data, using the Dump operator as shown below.
grunt> Dump Lcfirst_data;
  • ((1,Aadav),aadav)
  • ((2,Aadhi),aadhi)
  • ((3,Charu),charu)
  • ((4,Daya),daya)
  • ((5,Hansa),hansa)
  • ((6,Hena),hena)
  • ((7,Robert),robert)
  • ((8,Kali),kali)
  • ((9,Leena),leena)
  • ((10,Mahi),mahi)
  • ((11,Priya),priya)
  • 12,Rahul,rahul

  • Related Searches to Apache Pig LCFIRST()

    Adblocker detected! Please consider reading this notice.

    We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

    We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

    We need money to operate the site, and almost all of it comes from our online advertising.

    Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

    ×