pig tutorial - apache pig tutorial - Apache Pig CONCAT() Function - pig latin - apache pig - pig hadoop
What is CONCAT() Function in Apache Pig ?
- The CONCAT() function is used to concatenate two strings to form a single string.
- The CONCAT() function concatenates two or more expressions together.
- The CONCAT() function returns a string that is the result of concatenating two or more string values.
- The CONCAT() function is used to add two or more strings.
- The CONCAT() function which is used in Apache Pig is used to concatenate two or more expressions of the same type.
Learn Apache Pig - Apache Pig tutorial - Apache Pig Concat() Function - Apache Pig examples - Apache Pig programs
Syntax
Example
wikitechy_employee_details.txt
- We have loaded this file wikitechy_employee_details.txt into Pig with the relation named wikitechy_employee_details as shown below.
Concatenating Two Strings
Method 1:
- We have loaded this file wikitechy_employee_details.txt into Pig with the relation named wikitechy_employee_details as shown below.
- We need to verify the contents of the wikitechy_employee_details relation by using the Dump operator which is given below:
- We need to verify the schema by using the describe operator as shown below
- In the schema which is given above by using the describe operator, we observe the name of the employee is represented using two chararray values namely firstname and lastname.
Verification
Method 2:
- We can use an optional delimiter which is used between the two expressions which is given below:
- We need to concatenate the first name and last name of the employee records in the wikitechy_employee_details relation by placing ‘_’ between them which is given below