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

What is equalsIgnoreCase?

  • The equalsIgnoreCase() Method is used to compare a specified String to another String, ignoring case considerations.
  • Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.
  • If both are equal this function returns the Boolean value true else it returns the value false.


  • Given below is the syntax of the function EqualsIgnoreCase()
grunt> EqualsIgnoreCase(string1, string2)


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


003,Charu,23, London
005, Hansa,22,Bhuwaneshwar 
006, Hena,21,Chennai
007,Robert,24, Bhuwaneshwar
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 emp_data as shown below.
grunt> emp_data = LOAD 'hdfs://localhost:9000/pig_data/emp.txt' USING PigStorage(',')as (id:int, name:chararray, age:int, city:chararray);
  • Given below is an example of the EqualsIgnoreCase() function. In this example we are comparing the names of every employees with the string value ‘Aadav’.
grunt> equals_data = FOREACH emp_data GENERATE (id,name), EqualsIgnoreCase(name, 'Aadav');
  • The above statement compares the string “Aadav” (case insensitive) with the names of the employees, if the value matches it returns true else it returns false. In short, this statement searches the employee record whose name is ‘Aadav’
  • The result of the statement will be stored in the relation named equals_data. Verify the content of the relation equals_data, using the Dump operator as shown below.
grunt> Dump equals_data;

Related Searches to Apache Pig EqualsIgnoreCase()