pig tutorial - apache pig tutorial - Apache Pig ENDSWITH() - pig latin - apache pig - pig hadoop
What is ENDSWITH() method in Apache Pig ?
- The endsWith() method determines whether a string ends with the characters of a specified string.
- This method returns true if the string ends with the characters, and false if not. Note: The endsWith() method is case sensitive.
- This function accepts two String parameters, it is used to verify whether the first string ends with the second string.
- 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.
- And, we have loaded this file into Pig with a relation named wikitechy_emp_data as shown below.
- Following is an example of ENDSWITH() function, in this example we are verifying, weather the name of every employee ends with the character i.
- The above statement verifies weather the name of the employee ends with the letter i. Since the names of the employees Aadhi,Kali and Mahi ends with the letter i for these two tuples ENDSWITH() function returns the Boolean value ‘true’ and for remaining tuples the value will be ‘false’.
- The result of the statement will be stored in the relation named emp_endswith. Verify the content of the relation emp_endswith, using the Dump operator as shown below.